Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Commit 5e94d44

Browse files
feat: Reproducible build and deb packaging (#11)
Completely rework release builds 🤞 Move rust toolchain install for clarity Add `remap-path-prefix` build flag Add `cargo-deb` steps
1 parent f645c9e commit 5e94d44

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

.github/workflows/release.yml

+38-34
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,17 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
include:
15-
- os: ubuntu-latest
16-
name: linux
17-
binary_path: target/x86_64-unknown-linux-musl/release
18-
binary_files: icx-proxy
19-
rust: 1.50.0 # gmiam/rust-musl-action@master is only at 1.50.0 now
20-
- os: macos-latest
21-
name: macos
22-
binary_path: target/release
23-
binary_files: icx-proxy
24-
rust: 1.55.0
14+
rust: [ '1.55.0' ]
15+
os: [ ubuntu-latest, macos-latest ]
16+
2517
steps:
26-
- uses: actions/checkout@master
18+
- uses: actions/checkout@v2
2719

2820
- name: Setup environment variables
2921
run: |
3022
echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
3123
echo "OPENSSL_STATIC=yes" >> $GITHUB_ENV
32-
binaries=$(echo ${{ matrix.binary_files }} | xargs -n1 echo "--bin"|xargs)
33-
echo "cargo_build_ARGS<<END" >> $GITHUB_ENV
34-
echo "--locked --release $binaries" >> $GITHUB_ENV
35-
echo "END" >> $GITHUB_ENV
36-
37-
- name: Static build
38-
uses: gmiam/rust-musl-action@master
39-
with:
40-
args: cargo build --target x86_64-unknown-linux-musl ${{ env.cargo_build_ARGS }}
41-
if: contains(matrix.os, 'ubuntu')
42-
43-
- name: Strip binaries
44-
run: |
45-
cd ${{ matrix.binary_path }}
46-
sudo chown -R $(whoami) .
47-
strip ${{ matrix.binary_files }}
48-
if: contains(matrix.os, 'ubuntu')
24+
echo ICX_VERSION=$(cargo metadata | jq -r '.["packages"][] | select(.name == "icx-proxy")["version"]') >> $GITHUB_ENV
4925
5026
- name: Install Rust toolchain
5127
uses: actions-rs/toolchain@v1
@@ -55,15 +31,33 @@ jobs:
5531
override: true
5632
if: contains(matrix.os, 'macos')
5733

58-
- name: Dynamic build
34+
- name: Linux hack
5935
run: |
60-
cargo build ${{ env.cargo_build_ARGS }}
61-
cd ${{ matrix.binary_path }}
62-
otool -L ${{ matrix.binary_files }}
36+
echo "1.58.1" >./rust-toolchain
37+
if: contains(matrix.os, 'ubuntu')
38+
39+
- name: Linux build
40+
uses: dfinity/rust-musl-action@master
41+
with:
42+
args: |
43+
cargo install cargo-deb --target x86_64-unknown-linux-musl
44+
echo "1.55.0" >./rust-toolchain
45+
rustup target add x86_64-unknown-linux-musl
46+
RUSTFLAGS="--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" cargo deb --target x86_64-unknown-linux-musl -- --locked
47+
if: contains(matrix.os, 'ubuntu')
48+
49+
- name: macOS build
50+
env:
51+
RUSTFLAGS: --remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity
52+
run: |
53+
cargo build --locked --release
54+
cd target/release
55+
otool -L icx-proxy
6356
if: contains(matrix.os, 'macos')
6457

6558
- name: Create tarball of binaries
66-
run: tar -zcC ${{ matrix.binary_path }} -f binaries.tar.gz ${{ matrix.binary_files }}
59+
run: tar -zcC target/release -f binaries.tar.gz icx-proxy
60+
if: contains(matrix.os, 'macos')
6761

6862
- name: Upload tarball
6963
uses: svenstaro/upload-release-action@v2
@@ -72,3 +66,13 @@ jobs:
7266
file: binaries.tar.gz
7367
asset_name: binaries-${{ matrix.name }}.tar.gz
7468
tag: ${{ env.SHA_SHORT }}
69+
if: contains(matrix.os, 'macos')
70+
71+
- name: Upload deb
72+
uses: svenstaro/upload-release-action@v2
73+
with:
74+
repo_token: ${{ secrets.GITHUB_TOKEN }}
75+
file: target/x86_64-unknown-linux-musl/debian/icx-proxy_${{ env.ICX_VERSION }}_amd64.deb
76+
asset_name: icx-proxy.deb
77+
tag: ${{ env.SHA_SHORT }}
78+
if: contains(matrix.os, 'ubuntu')

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
rust: [ '1.52.1' ]
14+
rust: [ '1.55.0' ]
1515
os: [ ubuntu-latest, macos-latest, windows-latest ]
1616

1717
steps:

0 commit comments

Comments
 (0)