| @@ -0,0 +1,117 @@ |
| 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - "v*.*.*" |
| 7 | |
| 8 | defaults: |
| 9 | run: |
| 10 | shell: bash |
| 11 | |
| 12 | jobs: |
| 13 | prep-release: |
| 14 | runs-on: 'ubuntu-slim' |
| 15 | permissions: |
| 16 | contents: write |
| 17 | steps: |
| 18 | - name: Checkout |
| 19 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 20 | with: |
| 21 | persist-credentials: false |
| 22 | |
| 23 | - name: Create draft release |
| 24 | run: | |
| 25 | gh release create ${TAG} --draft=true --target ${{ github.sha }} --title ${TAG} |
| 26 | env: |
| 27 | TAG: ${{ github.ref_name }} |
| 28 | GH_TOKEN: ${{ github.token }} |
| 29 | |
| 30 | build: |
| 31 | needs: prep-release |
| 32 | strategy: |
| 33 | matrix: |
| 34 | platform: [ubuntu-latest, windows-latest, macos-latest] |
| 35 | arch: [x86_64, aarch64] |
| 36 | exclude: |
| 37 | - platform: windows-latest |
| 38 | arch: aarch64 |
| 39 | include: |
| 40 | - platform: ubuntu-latest |
| 41 | arch: x86_64 |
| 42 | triple: unknown-linux-musl |
| 43 | - platform: ubuntu-latest |
| 44 | arch: aarch64 |
| 45 | triple: unknown-linux-gnu |
| 46 | - platform: macos-latest |
| 47 | triple: apple-darwin |
| 48 | - platform: windows-latest |
| 49 | triple: pc-windows-msvc |
| 50 | fail-fast: false |
| 51 | runs-on: ${{ matrix.platform }} |
| 52 | permissions: |
| 53 | contents: write |
| 54 | env: |
| 55 | TARGET: ${{ matrix.arch }}-${{ matrix.triple }} |
| 56 | steps: |
| 57 | - name: Checkout |
| 58 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 59 | with: |
| 60 | persist-credentials: false |
| 61 | - name: Install Rust (stable) |
| 62 | uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 |
| 63 | with: |
| 64 | toolchain: stable |
| 65 | targets: ${{ env.TARGET }} |
| 66 | - name: Install C cross-compilation toolchain |
| 67 | if: matrix.platform == 'ubuntu-latest' |
| 68 | run: | |
| 69 | sudo apt-get update |
| 70 | sudo apt install -f -y build-essential crossbuild-essential-arm64 musl-dev |
| 71 | # Cross-compilation env vars for x86_64-unknown-linux-musl |
| 72 | echo CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc >> $GITHUB_ENV |
| 73 | echo AR_x86_64_unknown_linux_musl=x86_64-linux-gnu-ar >> $GITHUB_ENV |
| 74 | echo CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc >> $GITHUB_ENV |
| 75 | echo CXX_x86_64_unknown_linux_musl=x86_64-linux-gnu-g++ >> $GITHUB_ENV |
| 76 | # Cross-compilation env vars for aarch64-unknown-linux-gnu |
| 77 | echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc >> $GITHUB_ENV |
| 78 | echo AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar >> $GITHUB_ENV |
| 79 | echo CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc >> $GITHUB_ENV |
| 80 | echo CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ >> $GITHUB_ENV |
| 81 | - name: 'Build: binary' |
| 82 | run: | |
| 83 | cargo +stable build --profile=release-lto --locked --target=${{ env.TARGET }} |
| 84 | - name: 'Package: tgz' |
| 85 | run: | |
| 86 | cargo +stable install --locked cargo-tar |
| 87 | cargo +stable tar --profile=release-lto --target ${{ env.TARGET }} |
| 88 | - name: 'Upload: tgz' |
| 89 | run: | |
| 90 | gh release upload ${TAG} ./target/tar/iamb*-${{ env.TARGET }}.tar.gz |
| 91 | env: |
| 92 | TAG: ${{ github.ref_name }} |
| 93 | GH_TOKEN: ${{ github.token }} |
| 94 | - name: 'Package: deb' |
| 95 | if: matrix.platform == 'ubuntu-latest' |
| 96 | run: | |
| 97 | cargo +stable install --locked cargo-deb |
| 98 | cargo +stable deb --profile=release-lto --no-strip --target ${{ env.TARGET }} |
| 99 | - name: 'Upload: deb' |
| 100 | if: matrix.platform == 'ubuntu-latest' |
| 101 | run: | |
| 102 | gh release upload ${TAG} ./target/${{ env.TARGET }}/debian/iamb*.deb |
| 103 | env: |
| 104 | TAG: ${{ github.ref_name }} |
| 105 | GH_TOKEN: ${{ github.token }} |
| 106 | - name: 'Package: rpm' |
| 107 | if: matrix.platform == 'ubuntu-latest' |
| 108 | run: | |
| 109 | cargo +stable install --locked cargo-generate-rpm |
| 110 | cargo +stable generate-rpm --profile=release-lto --target ${{ env.TARGET }} |
| 111 | - name: 'Upload: rpm' |
| 112 | if: matrix.platform == 'ubuntu-latest' |
| 113 | run: | |
| 114 | gh release upload ${TAG} ./target/${{ env.TARGET }}/generate-rpm/iamb*.rpm |
| 115 | env: |
| 116 | TAG: ${{ github.ref_name }} |
| 117 | GH_TOKEN: ${{ github.token }} |