|
| 1 | +name: Cross Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + extract-version: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + - name: Export Crate Package Version |
| 12 | + run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')" >> $GITHUB_OUTPUT |
| 13 | + id: export |
| 14 | + outputs: |
| 15 | + VERSION: ${{ steps.export.outputs.VERSION }} |
| 16 | + |
| 17 | + build: |
| 18 | + name: build release |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + arch: |
| 22 | + [ |
| 23 | + aarch64-unknown-linux-gnu, |
| 24 | + x86_64-unknown-linux-gnu, |
| 25 | + x86_64-apple-darwin, |
| 26 | + aarch64-apple-darwin, |
| 27 | + x86_64-pc-windows-gnu, |
| 28 | + ] |
| 29 | + include: |
| 30 | + - arch: aarch64-unknown-linux-gnu |
| 31 | + platform: ubuntu-20.04 |
| 32 | + profile: maxperf |
| 33 | + - arch: x86_64-unknown-linux-gnu |
| 34 | + platform: ubuntu-20.04 |
| 35 | + profile: maxperf |
| 36 | + - arch: x86_64-apple-darwin |
| 37 | + platform: macos-latest |
| 38 | + profile: maxperf |
| 39 | + - arch: aarch64-apple-darwin |
| 40 | + platform: macos-latest |
| 41 | + profile: maxperf |
| 42 | + - arch: x86_64-pc-windows-gnu |
| 43 | + platform: ubuntu-20.04 |
| 44 | + profile: maxperf |
| 45 | + |
| 46 | + runs-on: ${{ matrix.platform }} |
| 47 | + needs: extract-version |
| 48 | + env: |
| 49 | + VERSION: ${{ needs.extract-version.outputs.VERSION }} |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - run: rustup update stable |
| 53 | + - run: rustup target add ${{ matrix.arch }} |
| 54 | + - uses: Swatinem/rust-cache@v2 |
| 55 | + with: |
| 56 | + cache-on-failure: true |
| 57 | + - name: Apple M1 setup |
| 58 | + if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} |
| 59 | + run: | |
| 60 | + echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV |
| 61 | + echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV |
| 62 | + - name: Build for ${{ matrix.arch }} |
| 63 | + run: | |
| 64 | + cargo install cross |
| 65 | + env PROFILE=${{ matrix.profile }} make build-${{ matrix.arch }} |
| 66 | + - name: Move cross-compiled binary |
| 67 | + if: matrix.arch != 'x86_64-pc-windows-gnu' |
| 68 | + run: | |
| 69 | + mkdir artifacts |
| 70 | + mv target/${{ matrix.arch }}/${{ matrix.profile }}/* ./artifacts |
| 71 | + - name: Create artifacts |
| 72 | + run: tar --directory=artifacts -czf release-${{ env.VERSION }}-${{ matrix.arch }}.tar.gz $(ls -U artifacts/ | head -1) |
| 73 | + shell: bash |
| 74 | + |
| 75 | + release: |
| 76 | + name: Release on Github |
| 77 | + runs-on: ubuntu-latest |
| 78 | + permissions: |
| 79 | + contents: write |
| 80 | + needs: [build, extract-version] |
| 81 | + env: |
| 82 | + VERSION: ${{ needs.extract-version.outputs.VERSION }} |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + - uses: ncipollo/release-action@v1 |
| 86 | + with: |
| 87 | + artifacts: "artifacts/*" |
| 88 | + tag: v${{ env.VERSION }} |
0 commit comments