|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +env: |
| 13 | + APP_NAME: dustrown |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build ${{ matrix.target }} |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - os: ubuntu-24.04 |
| 24 | + target: x86_64-unknown-linux-gnu |
| 25 | + artifact_name: dustrown-linux-x86_64 |
| 26 | + archive_name: dustrown-linux-x86_64.tar.gz |
| 27 | + - os: windows-2022 |
| 28 | + target: x86_64-pc-windows-msvc |
| 29 | + artifact_name: dustrown-windows-x86_64 |
| 30 | + archive_name: dustrown-windows-x86_64.zip |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Install Rust toolchain |
| 37 | + uses: dtolnay/rust-toolchain@stable |
| 38 | + with: |
| 39 | + targets: ${{ matrix.target }} |
| 40 | + |
| 41 | + - name: Cache Cargo |
| 42 | + uses: Swatinem/rust-cache@v2 |
| 43 | + |
| 44 | + - name: Install Linux dependencies |
| 45 | + if: runner.os == 'Linux' |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y \ |
| 49 | + libgtk-3-dev \ |
| 50 | + libwebkit2gtk-4.1-dev \ |
| 51 | + libsoup-3.0-dev |
| 52 | +
|
| 53 | + - name: Build release binary |
| 54 | + run: cargo build --release --locked --target ${{ matrix.target }} |
| 55 | + |
| 56 | + - name: Package Linux artifact |
| 57 | + if: runner.os == 'Linux' |
| 58 | + run: | |
| 59 | + mkdir -p dist |
| 60 | + cp "target/${{ matrix.target }}/release/${APP_NAME}" dist/ |
| 61 | + cp README.md dist/ |
| 62 | + tar -C dist -czf "${{ matrix.archive_name }}" "${APP_NAME}" README.md |
| 63 | +
|
| 64 | + - name: Package Windows artifact |
| 65 | + if: runner.os == 'Windows' |
| 66 | + shell: pwsh |
| 67 | + run: | |
| 68 | + New-Item -ItemType Directory -Force -Path dist | Out-Null |
| 69 | + Copy-Item "target/${{ matrix.target }}/release/${env:APP_NAME}.exe" -Destination dist/ |
| 70 | + Copy-Item "README.md" -Destination dist/ |
| 71 | + Compress-Archive -Path "dist/${env:APP_NAME}.exe", "dist/README.md" -DestinationPath "${{ matrix.archive_name }}" |
| 72 | +
|
| 73 | + - name: Upload build artifact |
| 74 | + uses: actions/upload-artifact@v4 |
| 75 | + with: |
| 76 | + name: ${{ matrix.artifact_name }} |
| 77 | + path: ${{ matrix.archive_name }} |
| 78 | + |
| 79 | + release: |
| 80 | + name: Publish GitHub release |
| 81 | + if: startsWith(github.ref, 'refs/tags/v') |
| 82 | + runs-on: ubuntu-24.04 |
| 83 | + needs: build |
| 84 | + steps: |
| 85 | + - name: Download Linux artifact |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + name: dustrown-linux-x86_64 |
| 89 | + path: release-assets |
| 90 | + |
| 91 | + - name: Download Windows artifact |
| 92 | + uses: actions/download-artifact@v4 |
| 93 | + with: |
| 94 | + name: dustrown-windows-x86_64 |
| 95 | + path: release-assets |
| 96 | + |
| 97 | + - name: Create GitHub release |
| 98 | + uses: softprops/action-gh-release@v2 |
| 99 | + with: |
| 100 | + files: | |
| 101 | + release-assets/*.tar.gz |
| 102 | + release-assets/*.zip |
0 commit comments