Release Desktop Builds #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Desktop Builds | |
| on: | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: Release tag to publish, for example v1.0.0 | |
| required: true | |
| type: string | |
| release_name: | |
| description: Optional GitHub release title | |
| required: false | |
| type: string | |
| draft: | |
| description: Create the release as a draft when dispatched manually | |
| required: false | |
| default: true | |
| type: boolean | |
| prerelease: | |
| description: Mark the release as a prerelease when dispatched manually | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: release-${{ github.event.release.tag_name || inputs.tag_name || github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build-release: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: macos-latest | |
| args: '--target aarch64-apple-darwin' | |
| rustTargets: 'aarch64-apple-darwin,x86_64-apple-darwin' | |
| - platform: macos-latest | |
| args: '--target x86_64-apple-darwin' | |
| rustTargets: 'aarch64-apple-darwin,x86_64-apple-darwin' | |
| - platform: windows-latest | |
| args: '' | |
| rustTargets: '' | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: | | |
| package-lock.json | |
| ui/package-lock.json | |
| - name: Install root dependencies | |
| run: npm ci | |
| - name: Install UI dependencies | |
| run: npm --prefix ui ci | |
| - name: Set up Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.rustTargets }} | |
| - name: Restore Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: | | |
| src-tauri -> target | |
| - name: Resolve release metadata | |
| id: release_meta | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| tag_name="${{ github.event.release.tag_name }}" | |
| release_name="${{ github.event.release.name }}" | |
| draft_value="${{ github.event.release.draft }}" | |
| prerelease_value="${{ github.event.release.prerelease }}" | |
| else | |
| tag_name="${{ inputs.tag_name }}" | |
| release_name="${{ inputs.release_name }}" | |
| draft_value="${{ inputs.draft }}" | |
| prerelease_value="${{ inputs.prerelease }}" | |
| fi | |
| if [[ -z "$tag_name" ]]; then | |
| echo "Release tag name is required." >&2 | |
| exit 1 | |
| fi | |
| if [[ -z "$release_name" ]]; then | |
| release_name="Shot ${tag_name}" | |
| fi | |
| echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" | |
| echo "release_name=$release_name" >> "$GITHUB_OUTPUT" | |
| echo "draft_value=$draft_value" >> "$GITHUB_OUTPUT" | |
| echo "prerelease_value=$prerelease_value" >> "$GITHUB_OUTPUT" | |
| - name: Resolve build options | |
| id: build_options | |
| shell: bash | |
| run: | | |
| resolved_args='${{ matrix.args }}' | |
| include_updater_json=false | |
| if [[ -n '${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}' ]]; then | |
| include_updater_json=true | |
| fi | |
| { | |
| echo "include_updater_json=$include_updater_json" | |
| echo 'resolved_args<<EOF' | |
| echo "$resolved_args" | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Disable updater artifacts for unsigned builds | |
| shell: bash | |
| env: | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | |
| run: | | |
| if [[ -n "$TAURI_SIGNING_PRIVATE_KEY" ]]; then | |
| exit 0 | |
| fi | |
| node <<'NODE' | |
| const fs = require('fs'); | |
| const filePath = 'src-tauri/tauri.conf.json'; | |
| const config = JSON.parse(fs.readFileSync(filePath, 'utf8')); | |
| config.bundle = { | |
| ...(config.bundle || {}), | |
| createUpdaterArtifacts: false, | |
| }; | |
| fs.writeFileSync(filePath, `${JSON.stringify(config, null, 2)}\n`); | |
| NODE | |
| - name: Build and publish desktop release | |
| uses: tauri-apps/tauri-action@v0.6.2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | |
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} | |
| APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} | |
| APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| with: | |
| projectPath: . | |
| tagName: ${{ steps.release_meta.outputs.tag_name }} | |
| releaseName: ${{ steps.release_meta.outputs.release_name }} | |
| releaseBody: Desktop installers and updater artifacts for Shot. | |
| releaseCommitish: ${{ github.sha }} | |
| releaseDraft: ${{ steps.release_meta.outputs.draft_value }} | |
| prerelease: ${{ steps.release_meta.outputs.prerelease_value }} | |
| tauriScript: npm run tauri -- | |
| includeUpdaterJson: ${{ steps.build_options.outputs.include_updater_json }} | |
| args: ${{ steps.build_options.outputs.resolved_args }} | |
| uploadPlainBinary: false | |
| updaterJsonPreferNsis: true | |
| assetNamePattern: 'Shot_[version]_[platform]_[arch][ext]' |