|
| 1 | +name: Release |
| 2 | + |
1 | 3 | on: |
2 | 4 | release: |
3 | 5 | types: [created] |
4 | 6 |
|
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + |
5 | 10 | jobs: |
6 | 11 | release: |
7 | | - name: release ${{ matrix.target }} |
8 | | - runs-on: ubuntu-latest |
| 12 | + name: Release ${{ matrix.target }} |
| 13 | + runs-on: ${{ matrix.os }} |
9 | 14 | strategy: |
10 | 15 | fail-fast: false |
11 | 16 | matrix: |
12 | 17 | include: |
13 | | - - target: x86_64-pc-windows-gnu |
| 18 | + # x86_64 targets |
| 19 | + - os: ubuntu-latest |
| 20 | + target: x86_64-unknown-linux-musl |
| 21 | + use_cross: false |
| 22 | + archive: tar.gz |
| 23 | + - os: macos-latest |
| 24 | + target: x86_64-apple-darwin |
| 25 | + use_cross: false |
14 | 26 | archive: zip |
15 | | - - target: x86_64-unknown-linux-musl |
16 | | - archive: tar.gz tar.xz tar.zst |
17 | | - - target: x86_64-apple-darwin |
| 27 | + |
| 28 | + # aarch64 (ARM64) targets |
| 29 | + - os: ubuntu-latest |
| 30 | + target: aarch64-unknown-linux-musl |
| 31 | + use_cross: true |
| 32 | + archive: tar.gz |
| 33 | + - os: macos-latest |
| 34 | + target: aarch64-apple-darwin |
| 35 | + use_cross: false |
18 | 36 | archive: zip |
| 37 | + |
19 | 38 | steps: |
20 | | - - uses: actions/checkout@master |
21 | | - - name: Compile and release |
22 | | - uses: rust-build/[email protected] |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Install Rust |
| 43 | + uses: dtolnay/rust-toolchain@stable |
| 44 | + with: |
| 45 | + targets: ${{ matrix.target }} |
| 46 | + |
| 47 | + - name: Install cross |
| 48 | + if: matrix.use_cross |
| 49 | + run: | |
| 50 | + cargo install cross --git https://github.com/cross-rs/cross |
| 51 | + echo "CARGO=cross" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + - name: Set cargo |
| 54 | + if: "!matrix.use_cross" |
| 55 | + run: echo "CARGO=cargo" >> $GITHUB_ENV |
| 56 | + |
| 57 | + - name: Build |
| 58 | + run: | |
| 59 | + cd temoc |
| 60 | + ${{ env.CARGO }} build --release --target ${{ matrix.target }} |
| 61 | +
|
| 62 | + - name: Package (tar.gz) |
| 63 | + if: matrix.archive == 'tar.gz' |
| 64 | + run: | |
| 65 | + cd temoc/target/${{ matrix.target }}/release |
| 66 | + tar czf ../../../../temoc-${{ matrix.target }}.tar.gz temoc |
| 67 | + cd ../../../.. |
| 68 | + echo "ASSET=temoc-${{ matrix.target }}.tar.gz" >> $GITHUB_ENV |
| 69 | +
|
| 70 | + - name: Package (zip - Unix) |
| 71 | + if: matrix.archive == 'zip' && runner.os != 'Windows' |
| 72 | + run: | |
| 73 | + cd temoc/target/${{ matrix.target }}/release |
| 74 | + if [ -f temoc ]; then |
| 75 | + zip ../../../../temoc-${{ matrix.target }}.zip temoc |
| 76 | + else |
| 77 | + zip ../../../../temoc-${{ matrix.target }}.zip temoc.exe |
| 78 | + fi |
| 79 | + cd ../../../.. |
| 80 | + echo "ASSET=temoc-${{ matrix.target }}.zip" >> $GITHUB_ENV |
| 81 | +
|
| 82 | + - name: Package (zip - Windows) |
| 83 | + if: matrix.archive == 'zip' && runner.os == 'Windows' |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + cd temoc/target/${{ matrix.target }}/release |
| 87 | + 7z a ../../../../temoc-${{ matrix.target }}.zip temoc.exe |
| 88 | + cd ../../../.. |
| 89 | + echo "ASSET=temoc-${{ matrix.target }}.zip" >> $GITHUB_ENV |
| 90 | +
|
| 91 | + - name: Upload Release Asset |
| 92 | + uses: softprops/action-gh-release@v1 |
| 93 | + if: startsWith(github.ref, 'refs/tags/') |
| 94 | + with: |
| 95 | + files: ${{ env.ASSET }} |
23 | 96 | env: |
24 | 97 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
25 | | - with: |
26 | | - SRC_DIR: ./temoc/ |
27 | | - RUSTTARGET: ${{ matrix.target }} |
28 | | - ARCHIVE_TYPES: ${{ matrix.archive }} |
|
0 commit comments