|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 13 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + create-release: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + version: ${{ steps.get_version.outputs.version }} |
| 20 | + release_id: ${{ steps.create_release.outputs.id }} |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Get version from tauri.conf.json |
| 26 | + id: get_version |
| 27 | + run: | |
| 28 | + VERSION=$(jq -r '.version' src-tauri/tauri.conf.json) |
| 29 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 30 | +
|
| 31 | + - name: Create draft release |
| 32 | + id: create_release |
| 33 | + uses: softprops/action-gh-release@v2 |
| 34 | + with: |
| 35 | + tag_name: v${{ steps.get_version.outputs.version }} |
| 36 | + name: ZeroLimit v${{ steps.get_version.outputs.version }} |
| 37 | + draft: true |
| 38 | + generate_release_notes: true |
| 39 | + |
| 40 | + build-windows-x64: |
| 41 | + needs: create-release |
| 42 | + runs-on: windows-latest |
| 43 | + steps: |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Setup Node.js |
| 48 | + uses: actions/setup-node@v4 |
| 49 | + with: |
| 50 | + node-version: 20 |
| 51 | + |
| 52 | + - name: Setup pnpm |
| 53 | + uses: pnpm/action-setup@v4 |
| 54 | + |
| 55 | + - name: Setup Rust |
| 56 | + uses: dtolnay/rust-toolchain@stable |
| 57 | + |
| 58 | + - name: Cache Cargo |
| 59 | + uses: actions/cache@v4 |
| 60 | + with: |
| 61 | + path: | |
| 62 | + ~/.cargo/bin/ |
| 63 | + ~/.cargo/registry/index/ |
| 64 | + ~/.cargo/registry/cache/ |
| 65 | + ~/.cargo/git/db/ |
| 66 | + src-tauri/target/ |
| 67 | + key: ${{ runner.os }}-cargo-x64-${{ hashFiles('**/Cargo.lock') }} |
| 68 | + restore-keys: | |
| 69 | + ${{ runner.os }}-cargo-x64- |
| 70 | +
|
| 71 | + - name: Install frontend dependencies |
| 72 | + run: pnpm install |
| 73 | + |
| 74 | + - name: Build Tauri (x64) |
| 75 | + run: pnpm tauri build --target x86_64-pc-windows-msvc |
| 76 | + |
| 77 | + - name: Prepare portable executable |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + VERSION="${{ needs.create-release.outputs.version }}" |
| 81 | + cp src-tauri/target/x86_64-pc-windows-msvc/release/zero-limit.exe "ZeroLimit_${VERSION}_portable.exe" |
| 82 | +
|
| 83 | + - name: Upload artifacts to release |
| 84 | + uses: softprops/action-gh-release@v2 |
| 85 | + with: |
| 86 | + tag_name: v${{ needs.create-release.outputs.version }} |
| 87 | + draft: true |
| 88 | + files: | |
| 89 | + src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe |
| 90 | + src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe.sig |
| 91 | + src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi |
| 92 | + src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi.sig |
| 93 | + ZeroLimit_*_portable.exe |
| 94 | +
|
| 95 | + build-windows-arm64: |
| 96 | + needs: create-release |
| 97 | + runs-on: windows-latest |
| 98 | + steps: |
| 99 | + - name: Checkout |
| 100 | + uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - name: Setup Node.js |
| 103 | + uses: actions/setup-node@v4 |
| 104 | + with: |
| 105 | + node-version: 20 |
| 106 | + |
| 107 | + - name: Setup pnpm |
| 108 | + uses: pnpm/action-setup@v4 |
| 109 | + |
| 110 | + - name: Setup Rust |
| 111 | + uses: dtolnay/rust-toolchain@stable |
| 112 | + with: |
| 113 | + targets: aarch64-pc-windows-msvc |
| 114 | + |
| 115 | + - name: Cache Cargo |
| 116 | + uses: actions/cache@v4 |
| 117 | + with: |
| 118 | + path: | |
| 119 | + ~/.cargo/bin/ |
| 120 | + ~/.cargo/registry/index/ |
| 121 | + ~/.cargo/registry/cache/ |
| 122 | + ~/.cargo/git/db/ |
| 123 | + src-tauri/target/ |
| 124 | + key: ${{ runner.os }}-cargo-arm64-${{ hashFiles('**/Cargo.lock') }} |
| 125 | + restore-keys: | |
| 126 | + ${{ runner.os }}-cargo-arm64- |
| 127 | +
|
| 128 | + - name: Install frontend dependencies |
| 129 | + run: pnpm install |
| 130 | + |
| 131 | + - name: Build Tauri (ARM64) |
| 132 | + run: pnpm tauri build --target aarch64-pc-windows-msvc |
| 133 | + |
| 134 | + - name: Prepare portable executable |
| 135 | + shell: bash |
| 136 | + run: | |
| 137 | + VERSION="${{ needs.create-release.outputs.version }}" |
| 138 | + cp src-tauri/target/aarch64-pc-windows-msvc/release/zero-limit.exe "ZeroLimit_${VERSION}_arm64_portable.exe" |
| 139 | +
|
| 140 | + - name: Upload artifacts to release |
| 141 | + uses: softprops/action-gh-release@v2 |
| 142 | + with: |
| 143 | + tag_name: v${{ needs.create-release.outputs.version }} |
| 144 | + draft: true |
| 145 | + files: | |
| 146 | + src-tauri/target/aarch64-pc-windows-msvc/release/bundle/nsis/*.exe |
| 147 | + src-tauri/target/aarch64-pc-windows-msvc/release/bundle/nsis/*.exe.sig |
| 148 | + src-tauri/target/aarch64-pc-windows-msvc/release/bundle/msi/*.msi |
| 149 | + src-tauri/target/aarch64-pc-windows-msvc/release/bundle/msi/*.msi.sig |
| 150 | + ZeroLimit_*_portable.exe |
| 151 | +
|
| 152 | + publish-release: |
| 153 | + needs: [create-release, build-windows-x64, build-windows-arm64] |
| 154 | + runs-on: ubuntu-latest |
| 155 | + steps: |
| 156 | + - name: Checkout |
| 157 | + uses: actions/checkout@v4 |
| 158 | + |
| 159 | + - name: Download release assets |
| 160 | + uses: robinraju/release-downloader@v1 |
| 161 | + with: |
| 162 | + tag: v${{ needs.create-release.outputs.version }} |
| 163 | + fileName: "*.sig" |
| 164 | + out-file-path: signatures |
| 165 | + |
| 166 | + - name: Generate latest.json |
| 167 | + run: | |
| 168 | + VERSION="${{ needs.create-release.outputs.version }}" |
| 169 | + REPO="${{ github.repository }}" |
| 170 | + DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
| 171 | +
|
| 172 | + # Read signature files |
| 173 | + X64_SIG=$(cat signatures/*x64*.exe.sig 2>/dev/null || echo "") |
| 174 | + ARM64_SIG=$(cat signatures/*arm64*.exe.sig 2>/dev/null || echo "") |
| 175 | +
|
| 176 | + cat > latest.json << EOF |
| 177 | + { |
| 178 | + "version": "$VERSION", |
| 179 | + "notes": "See release notes on GitHub", |
| 180 | + "pub_date": "$DATE", |
| 181 | + "platforms": { |
| 182 | + "windows-x86_64": { |
| 183 | + "signature": "$X64_SIG", |
| 184 | + "url": "https://github.com/$REPO/releases/download/v$VERSION/ZeroLimit_${VERSION}_x64-setup.exe" |
| 185 | + }, |
| 186 | + "windows-aarch64": { |
| 187 | + "signature": "$ARM64_SIG", |
| 188 | + "url": "https://github.com/$REPO/releases/download/v$VERSION/ZeroLimit_${VERSION}_arm64-setup.exe" |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | + EOF |
| 193 | +
|
| 194 | + - name: Upload latest.json |
| 195 | + uses: softprops/action-gh-release@v2 |
| 196 | + with: |
| 197 | + tag_name: v${{ needs.create-release.outputs.version }} |
| 198 | + draft: false |
| 199 | + files: latest.json |
0 commit comments