|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + name: linux |
| 17 | + binary_path: target/x86_64-unknown-linux-musl/release |
| 18 | + binary_files: icx 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 icx-proxy |
| 24 | + rust: 1.52.1 |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@master |
| 27 | + |
| 28 | + - name: Setup environment variables |
| 29 | + run: | |
| 30 | + echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV |
| 31 | + 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') |
| 49 | + |
| 50 | + - name: Install Rust toolchain |
| 51 | + uses: actions-rs/toolchain@v1 |
| 52 | + with: |
| 53 | + profile: minimal |
| 54 | + toolchain: ${{ matrix.rust }} |
| 55 | + override: true |
| 56 | + if: contains(matrix.os, 'macos') |
| 57 | + |
| 58 | + - name: Dynamic build |
| 59 | + run: | |
| 60 | + cargo build ${{ env.cargo_build_ARGS }} |
| 61 | + cd ${{ matrix.binary_path }} |
| 62 | + otool -L ${{ matrix.binary_files }} |
| 63 | + if: contains(matrix.os, 'macos') |
| 64 | + |
| 65 | + - name: Create tarball of binaries |
| 66 | + run: tar -zcC ${{ matrix.binary_path }} -f binaries.tar.gz ${{ matrix.binary_files }} |
| 67 | + |
| 68 | + - name: Upload tarball |
| 69 | + uses: svenstaro/upload-release-action@v2 |
| 70 | + with: |
| 71 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + file: binaries.tar.gz |
| 73 | + asset_name: binaries-${{ matrix.name }}.tar.gz |
| 74 | + tag: ${{ env.SHA_SHORT }} |
0 commit comments