From 29b714d9c49e62ba029608fdd4d0115e5f9d763e Mon Sep 17 00:00:00 2001 From: "Paul H. Liu" Date: Fri, 15 Oct 2021 08:57:25 -0700 Subject: [PATCH 1/2] Add binary release build --- .github/workflows/release.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..258688d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + name: linux + binary_path: target/x86_64-unknown-linux-musl/release + binary_files: icx icx-proxy + - os: macos-latest + binary_path: target/release + binary_files: icx icx-proxy + name: macos + steps: + - uses: actions/checkout@master + + - name: Setup environment variables + run: | + echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + echo "OPENSSL_STATIC=yes" >> $GITHUB_ENV + binaries=$(echo ${{ matrix.binary_files }} | xargs -n1 echo "--bin"|xargs) + echo "cargo_build_ARGS<> $GITHUB_ENV + echo "--locked --release $binaries" >> $GITHUB_ENV + echo "END" >> $GITHUB_ENV + + - name: Static build + uses: gmiam/rust-musl-action@master + with: + args: cargo build --target x86_64-unknown-linux-musl ${{ env.cargo_build_ARGS }} + if: contains(matrix.os, 'ubuntu') + + - name: Strip binaries + run: | + cd ${{ matrix.binary_path }} + sudo chown -R $(whoami) . + strip ${{ matrix.binary_files }} + if: contains(matrix.os, 'ubuntu') + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + if: contains(matrix.os, 'macos') + + - name: Dynamic build + run: | + cargo build ${{ env.cargo_build_ARGS }} + cd ${{ matrix.binary_path }} + otool -L ${{ matrix.binary_files }} + if: contains(matrix.os, 'macos') + + - name: Create tarball of binaries + run: tar -zcC ${{ matrix.binary_path }} -f binaries.tar.gz ${{ matrix.binary_files }} + + - name: Upload tarball + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: binaries.tar.gz + asset_name: binaries-${{ matrix.name }}.tar.gz + tag: ${{ env.SHA_SHORT }} From 36bb6d9f33018c0d6d4a7ddf40c95670980e4ef0 Mon Sep 17 00:00:00 2001 From: "Paul H. Liu" Date: Fri, 15 Oct 2021 14:33:47 -0700 Subject: [PATCH 2/2] Support rust version --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 258688d9..04e6e4fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,10 +16,12 @@ jobs: name: linux binary_path: target/x86_64-unknown-linux-musl/release binary_files: icx icx-proxy + rust: 1.50.0 # gmiam/rust-musl-action@master is only at 1.50.0 now - os: macos-latest + name: macos binary_path: target/release binary_files: icx icx-proxy - name: macos + rust: 1.52.1 steps: - uses: actions/checkout@master @@ -49,7 +51,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + toolchain: ${{ matrix.rust }} override: true if: contains(matrix.os, 'macos')