|
| 1 | +name: Desktop Pet Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'desktop-v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - platform: macos-latest |
| 18 | + rust-target: aarch64-apple-darwin |
| 19 | + tauri-args: --target aarch64-apple-darwin |
| 20 | + - platform: macos-latest |
| 21 | + rust-target: x86_64-apple-darwin |
| 22 | + tauri-args: --target x86_64-apple-darwin |
| 23 | + - platform: ubuntu-22.04 |
| 24 | + rust-target: x86_64-unknown-linux-gnu |
| 25 | + tauri-args: "" |
| 26 | + - platform: windows-latest |
| 27 | + rust-target: x86_64-pc-windows-msvc |
| 28 | + tauri-args: "" |
| 29 | + |
| 30 | + runs-on: ${{ matrix.platform }} |
| 31 | + defaults: |
| 32 | + run: |
| 33 | + shell: bash |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Setup Node |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: '20' |
| 43 | + |
| 44 | + - name: Setup Rust |
| 45 | + uses: dtolnay/rust-toolchain@stable |
| 46 | + with: |
| 47 | + targets: ${{ matrix.rust-target }} |
| 48 | + |
| 49 | + - name: Rust cache |
| 50 | + uses: swatinem/rust-cache@v2 |
| 51 | + with: |
| 52 | + workspaces: desktop/src-tauri |
| 53 | + |
| 54 | + - name: Install Linux dependencies |
| 55 | + if: runner.os == 'Linux' |
| 56 | + run: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y \ |
| 59 | + libwebkit2gtk-4.1-dev \ |
| 60 | + libappindicator3-dev \ |
| 61 | + librsvg2-dev \ |
| 62 | + patchelf \ |
| 63 | + libgtk-3-dev \ |
| 64 | + libsoup-3.0-dev \ |
| 65 | + libjavascriptcoregtk-4.1-dev \ |
| 66 | + libxdo-dev \ |
| 67 | + libfuse2 \ |
| 68 | + libssl-dev |
| 69 | +
|
| 70 | + - name: Install frontend dependencies |
| 71 | + working-directory: desktop |
| 72 | + run: npm install |
| 73 | + |
| 74 | + - name: Build Tauri app |
| 75 | + working-directory: desktop |
| 76 | + run: npx tauri build ${{ matrix.tauri-args }} |
| 77 | + |
| 78 | + - name: Determine version and arch |
| 79 | + id: meta |
| 80 | + run: | |
| 81 | + VERSION=$(grep -o '"version": *"[^"]*"' desktop/src-tauri/tauri.conf.json | head -1 | cut -d'"' -f4) |
| 82 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 83 | +
|
| 84 | + case "${{ matrix.rust-target }}" in |
| 85 | + aarch64-apple-darwin) echo "arch=aarch64" >> "$GITHUB_OUTPUT"; echo "os=macos" >> "$GITHUB_OUTPUT" ;; |
| 86 | + x86_64-apple-darwin) echo "arch=x64" >> "$GITHUB_OUTPUT"; echo "os=macos" >> "$GITHUB_OUTPUT" ;; |
| 87 | + x86_64-unknown-linux-gnu) echo "arch=x64" >> "$GITHUB_OUTPUT"; echo "os=linux" >> "$GITHUB_OUTPUT" ;; |
| 88 | + x86_64-pc-windows-msvc) echo "arch=x64" >> "$GITHUB_OUTPUT"; echo "os=windows" >> "$GITHUB_OUTPUT" ;; |
| 89 | + esac |
| 90 | +
|
| 91 | + - name: Collect and rename artifacts (macOS) |
| 92 | + if: runner.os == 'macOS' |
| 93 | + run: | |
| 94 | + mkdir -p artifacts |
| 95 | + DMG=$(find desktop/src-tauri/target -name '*.dmg' | head -1) |
| 96 | + cp "$DMG" "artifacts/cccc-desktop-pet_${{ steps.meta.outputs.version }}_${{ steps.meta.outputs.arch }}.dmg" |
| 97 | +
|
| 98 | + - name: Collect and rename artifacts (Windows) |
| 99 | + if: runner.os == 'Windows' |
| 100 | + run: | |
| 101 | + mkdir -p artifacts |
| 102 | + EXE=$(find desktop/src-tauri/target -name '*-setup.exe' | head -1) |
| 103 | + cp "$EXE" "artifacts/cccc-desktop-pet_${{ steps.meta.outputs.version }}_${{ steps.meta.outputs.arch }}-setup.exe" |
| 104 | +
|
| 105 | + - name: Collect and rename artifacts (Linux) |
| 106 | + if: runner.os == 'Linux' |
| 107 | + run: | |
| 108 | + mkdir -p artifacts |
| 109 | + DEB=$(find desktop/src-tauri/target -name '*.deb' | head -1) |
| 110 | + cp "$DEB" "artifacts/cccc-desktop-pet_${{ steps.meta.outputs.version }}_${{ steps.meta.outputs.arch }}.deb" |
| 111 | +
|
| 112 | + - name: Upload build artifacts |
| 113 | + uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + name: desktop-${{ matrix.rust-target }} |
| 116 | + path: artifacts/* |
| 117 | + if-no-files-found: error |
| 118 | + |
| 119 | + release: |
| 120 | + needs: build |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + - name: Download all artifacts |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + path: all-artifacts |
| 127 | + pattern: desktop-* |
| 128 | + merge-multiple: true |
| 129 | + |
| 130 | + - name: List artifacts |
| 131 | + run: ls -lR all-artifacts/ |
| 132 | + |
| 133 | + - name: Create GitHub Release |
| 134 | + uses: softprops/action-gh-release@v2 |
| 135 | + with: |
| 136 | + files: all-artifacts/* |
| 137 | + generate_release_notes: true |
| 138 | + draft: false |
| 139 | + prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }} |
0 commit comments