|
1 | 1 | name: Release |
2 | | - |
3 | 2 | on: |
4 | 3 | push: |
5 | 4 | tags: |
6 | 5 | - "v*.*.*" |
7 | 6 |
|
8 | 7 | jobs: |
9 | | - build-and-publish: |
| 8 | + create-release: |
10 | 9 | runs-on: ubuntu-latest |
11 | | - env: |
12 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 10 | + outputs: |
| 11 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 12 | + steps: |
| 13 | + - name: Create GitHub Release |
| 14 | + id: create_release |
| 15 | + uses: softprops/action-gh-release@v1 |
| 16 | + env: |
| 17 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + with: |
| 19 | + tag_name: ${{ github.ref_name }} |
| 20 | + draft: false |
| 21 | + prerelease: false |
| 22 | + |
| 23 | + build-and-publish: |
| 24 | + needs: create-release |
13 | 25 | strategy: |
14 | 26 | matrix: |
15 | 27 | include: |
16 | 28 | # Linux |
17 | 29 | - os: ubuntu-latest |
18 | 30 | target: x86_64-unknown-linux-gnu |
19 | 31 | ext: tar.gz |
| 32 | + bin: coto |
20 | 33 | - os: ubuntu-latest |
21 | 34 | target: aarch64-unknown-linux-gnu |
22 | 35 | ext: tar.gz |
| 36 | + bin: coto |
23 | 37 | # macOS |
24 | 38 | - os: macos-latest |
25 | 39 | target: x86_64-apple-darwin |
26 | 40 | ext: tar.gz |
| 41 | + bin: coto |
27 | 42 | - os: macos-latest |
28 | 43 | target: aarch64-apple-darwin |
29 | 44 | ext: tar.gz |
| 45 | + bin: coto |
30 | 46 | # Windows |
31 | 47 | - os: windows-latest |
32 | 48 | target: x86_64-pc-windows-msvc |
33 | 49 | ext: zip |
34 | | - |
| 50 | + bin: coto.exe |
| 51 | + runs-on: ${{ matrix.os }} |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
35 | 54 | steps: |
36 | | - - name: Checkout |
37 | | - uses: actions/checkout@v4 |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + |
| 57 | + # for Linux only: install cross |
| 58 | + - name: Install cross |
| 59 | + if: matrix.os == 'ubuntu-latest' |
| 60 | + run: cargo install cross --locked |
38 | 61 |
|
39 | | - - name: Install Rust toolchain |
| 62 | + # Install Rust toolchain with the correct target |
| 63 | + - name: Setup Rust toolchain |
40 | 64 | uses: actions-rs/toolchain@v1 |
41 | 65 | with: |
42 | 66 | toolchain: stable |
43 | 67 | target: ${{ matrix.target }} |
44 | 68 | override: true |
45 | 69 |
|
46 | | - - name: Build release binary |
| 70 | + - name: Build release binary (Linux) |
| 71 | + if: matrix.os == 'ubuntu-latest' |
| 72 | + run: cross build --release --target ${{ matrix.target }} |
| 73 | + |
| 74 | + - name: Build release binary (non-Linux) |
| 75 | + if: matrix.os != 'ubuntu-latest' |
47 | 76 | run: cargo build --release --target ${{ matrix.target }} |
48 | 77 |
|
49 | | - - name: Package |
| 78 | + - name: Package (Unix) |
| 79 | + if: matrix.os != 'windows-latest' |
50 | 80 | run: | |
51 | 81 | mkdir -p dist |
52 | | - BIN="coto${{ matrix.os == 'windows-latest' && '.exe' || '' }}" |
53 | 82 | PACKAGE="coto-${{ matrix.target }}.${{ matrix.ext }}" |
54 | | - if [[ "${{ matrix.ext }}" == "zip" ]]; then |
55 | | - zip -j dist/$PACKAGE target/${{ matrix.target }}/release/$BIN |
56 | | - else |
57 | | - tar czf dist/$PACKAGE -C target/${{ matrix.target }}/release $BIN |
58 | | - fi |
| 83 | + tar czf dist/$PACKAGE -C target/${{ matrix.target }}/release ${{ matrix.bin }} |
59 | 84 |
|
60 | | - - name: Create GitHub Release |
61 | | - if: matrix.os == 'ubuntu-latest' |
62 | | - uses: softprops/action-gh-release@v1 |
63 | | - with: |
64 | | - tag_name: ${{ github.ref_name }} |
65 | | - files: dist/* |
| 85 | + - name: Package (Windows) |
| 86 | + if: matrix.os == 'windows-latest' |
| 87 | + shell: pwsh |
| 88 | + run: | |
| 89 | + mkdir -p dist |
| 90 | + Compress-Archive -Path "target/${{ matrix.target }}/release/${{ matrix.bin }}" -DestinationPath "dist/coto-${{ matrix.target }}.${{ matrix.ext }}" |
66 | 91 |
|
67 | | - - name: Upload assets |
68 | | - if: matrix.os != 'ubuntu-latest |
| 92 | + - name: Upload artifacts to release |
69 | 93 | uses: softprops/action-gh-release@v1 |
70 | 94 | with: |
71 | 95 | tag_name: ${{ github.ref_name }} |
|
0 commit comments