|
| 1 | +name: 🚀 Release Trunk |
| 2 | +on: |
| 3 | + push: |
| 4 | + paths: |
| 5 | + - ".github/workflows/cli-release.yml" |
| 6 | + - "cli/**" |
| 7 | + - "!cli/README.md" |
| 8 | + - "!cli/.gitignore" |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | +defaults: |
| 12 | + run: |
| 13 | + shell: bash |
| 14 | + working-directory: ./cli/ |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + name: 🦀 ${{ matrix.toolchain }} on linux/${{ matrix.arch }} |
| 18 | + runs-on: |
| 19 | + # https://runs-on.com/runners/linux/ |
| 20 | + - runs-on=${{ github.run_id }}-${{ matrix.toolchain }}-${{ matrix.arch }} |
| 21 | + - runner=large-${{ matrix.arch }} |
| 22 | + - cpu=8 |
| 23 | + - ram=16 |
| 24 | + continue-on-error: ${{ matrix.toolchain == 'nightly' }} |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + arch: [amd64, arm64] |
| 29 | + toolchain: [stable, beta, nightly] |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - name: Setup Rust |
| 33 | + uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 34 | + with: |
| 35 | + toolchain: ${{ matrix.toolchain }} |
| 36 | + cache-key: ${{ matrix.arch }} |
| 37 | + components: rustfmt, clippy, llvm-tools |
| 38 | + - name: Build Binary |
| 39 | + run: cargo build --release |
| 40 | + - name: Get the Version |
| 41 | + if: env.VERSION == '' |
| 42 | + run: echo "VERSION=$(grep "^version" Cargo.toml | sed -r 's/version[^"]+"([^"]+).*/\1/')" >> $GITHUB_ENV |
| 43 | + - name: Determine Archive Name |
| 44 | + run: | |
| 45 | + echo "ARCHIVE=trunk-v$VERSION-linux-${{ matrix.arch }}" >> $GITHUB_ENV |
| 46 | + - name: Package Archive |
| 47 | + run: | |
| 48 | + set -ex |
| 49 | + printf "Packaging %s\n" "$ARCHIVE" |
| 50 | + mkdir "$ARCHIVE" |
| 51 | + cp target/release/trunk "$ARCHIVE"/ |
| 52 | + cp {README.md,../LICENSE} "$ARCHIVE"/ |
| 53 | + tar czvf "$ARCHIVE.tar.gz" "$ARCHIVE" |
| 54 | + - name: Upload Artifacts |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + path: "${{ env.ARCHIVE }}.*" |
| 58 | + name: "${{ env.ARCHIVE }}" |
| 59 | + overwrite: true |
| 60 | + if: matrix.toolchain == 'stable' && github.ref_name == 'main' |
| 61 | + - name: Publish GitHub Release |
| 62 | + uses: softprops/action-gh-release@v2 |
| 63 | + with: |
| 64 | + draft: true |
| 65 | + name: "Release ${{ env.VERSION }}" |
| 66 | + files: "trunk-*" |
| 67 | + if: matrix.toolchain == 'stable' && github.ref_name == 'main' |
0 commit comments