|
8 | 8 |
|
9 | 9 | # Keep pull request builds for testing |
10 | 10 | pull_request: |
| 11 | + workflow_dispatch: |
11 | 12 |
|
12 | 13 | permissions: |
13 | 14 | contents: write |
14 | 15 |
|
15 | 16 | jobs: |
16 | | - release: |
17 | | - name: release ${{ matrix.target }} |
18 | | - runs-on: ubuntu-latest |
| 17 | + build: |
| 18 | + name: Build |
| 19 | + needs: test |
| 20 | + runs-on: ${{ matrix.os }} |
19 | 21 | strategy: |
20 | | - fail-fast: false |
21 | 22 | matrix: |
22 | 23 | include: |
23 | | - - target: x86_64-pc-windows-gnu |
24 | | - archive: zip |
25 | | - - target: x86_64-unknown-linux-musl |
26 | | - archive: tar.gz tar.xz tar.zst |
27 | | - - target: x86_64-apple-darwin |
28 | | - archive: zip |
29 | | - - target: aarch64-unknown-linux-gnu |
30 | | - archive: tar.gz tar.xz tar.zst |
31 | | - - target: aarch64-apple-darwin |
32 | | - archive: zip |
| 24 | + - os: ubuntu-latest |
| 25 | + target: x86_64-unknown-linux-gnu |
| 26 | + artifact_name: app-linux-amd64 |
| 27 | + asset_name: app-linux-amd64.tar.gz |
| 28 | + compress_cmd: tar -czf |
| 29 | + compress_ext: .tar.gz |
| 30 | + |
| 31 | + - os: ubuntu-latest |
| 32 | + target: aarch64-unknown-linux-gnu |
| 33 | + artifact_name: app-linux-arm64 |
| 34 | + asset_name: app-linux-arm64.tar.gz |
| 35 | + compress_cmd: tar -czf |
| 36 | + compress_ext: .tar.gz |
| 37 | + |
| 38 | + - os: windows-latest |
| 39 | + target: x86_64-pc-windows-msvc |
| 40 | + artifact_name: app-windows-amd64 |
| 41 | + asset_name: app-windows-amd64.zip |
| 42 | + compress_cmd: 7z a |
| 43 | + compress_ext: .zip |
| 44 | + |
| 45 | + - os: macos-latest |
| 46 | + target: x86_64-apple-darwin |
| 47 | + artifact_name: app-macos-amd64 |
| 48 | + asset_name: app-macos-amd64.tar.gz |
| 49 | + compress_cmd: tar -czf |
| 50 | + compress_ext: .tar.gz |
| 51 | + |
| 52 | + - os: macos-latest |
| 53 | + target: aarch64-apple-darwin |
| 54 | + artifact_name: app-macos-arm64 |
| 55 | + asset_name: app-macos-arm64.tar.gz |
| 56 | + compress_cmd: tar -czf |
| 57 | + compress_ext: .tar.gz |
33 | 58 |
|
34 | 59 | steps: |
35 | | - - uses: actions/checkout@master |
36 | | - - name: Compile and release |
37 | | - uses: rust-build/[email protected] |
38 | | - id: compile |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Setup Rust toolchain |
| 63 | + uses: dtolnay/rust-toolchain@master |
| 64 | + with: |
| 65 | + toolchain: stable |
| 66 | + targets: ${{ matrix.target }} |
| 67 | + |
| 68 | + - name: Set up cargo cache |
| 69 | + uses: Swatinem/rust-cache@v2 |
| 70 | + with: |
| 71 | + key: ${{ matrix.target }} |
| 72 | + |
| 73 | + - name: Install cross-compilation dependencies (Linux ARM) |
| 74 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 75 | + run: | |
| 76 | + sudo apt-get update |
| 77 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 78 | + |
| 79 | + - name: Build release binary |
| 80 | + run: cargo build --release --target ${{ matrix.target }} |
| 81 | + |
| 82 | + - name: Prepare artifact |
| 83 | + shell: bash |
| 84 | + run: | |
| 85 | + mkdir -p dist |
| 86 | + if [[ "${{ matrix.os }}" == "windows-latest" ]]; then |
| 87 | + cp target/${{ matrix.target }}/release/your_app_name.exe dist/your_app_name.exe |
| 88 | + else |
| 89 | + cp target/${{ matrix.target }}/release/your_app_name dist/your_app_name |
| 90 | + chmod +x dist/your_app_name |
| 91 | + fi |
| 92 | + cd dist |
| 93 | + ${{ matrix.compress_cmd }} ../${{ matrix.asset_name }} * |
| 94 | + |
| 95 | + - name: Upload artifacts |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: ${{ matrix.artifact_name }} |
| 99 | + path: ${{ matrix.asset_name }} |
| 100 | + retention-days: 7 |
| 101 | + |
| 102 | + release: |
| 103 | + name: Create Release |
| 104 | + needs: build |
| 105 | + runs-on: ubuntu-latest |
| 106 | + if: startsWith(github.ref, 'refs/tags/') |
| 107 | + |
| 108 | + steps: |
| 109 | + - name: Download all artifacts |
| 110 | + uses: actions/download-artifact@v4 |
| 111 | + |
| 112 | + - name: Create Release |
| 113 | + uses: softprops/action-gh-release@v1 |
| 114 | + with: |
| 115 | + files: | |
| 116 | + app-linux-amd64/app-linux-amd64.tar.gz |
| 117 | + app-linux-arm64/app-linux-arm64.tar.gz |
| 118 | + app-windows-amd64/app-windows-amd64.zip |
| 119 | + app-macos-amd64/app-macos-amd64.tar.gz |
| 120 | + app-macos-arm64/app-macos-arm64.tar.gz |
39 | 121 | env: |
40 | 122 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
41 | | - with: |
42 | | - TOOLCHAIN_VERSION: 1.83.0 |
43 | | - RUSTTARGET: ${{ matrix.target }} |
44 | | - ARCHIVE_TYPES: ${{ matrix.archive }} |
|
0 commit comments