name: release-app # The normal way to release is to start this workflow by hand (`plan2code-publish` does it) with # the version and the release notes. It builds first and creates the release LAST, so the vX.Y.Z # tag, which is what the app's update check looks for, only appears once every file is attached # and nobody is offered an upgrade that has no binary yet. A release published by hand, or a v* # tag pushed ahead of one, still starts it as a fallback; the tag then exists before the files. # # Builds the desktop app on four systems and attaches one file per system, named # plan2code-app---[.exe], plus one checksum file # (plan2code-app--SHA256SUMS.txt). install.js fetches the matching file and checks it # against that list. Linux ships the plain binary, not an AppImage: docs/desktop-app.md documents # its WebKitGTK 4.1 dependency instead. The first release is unsigned: docs/desktop-app.md says # how to allow it. on: workflow_dispatch: inputs: version: description: 'Version to release, without the v (it must match CHANGELOG.md, version.json and package.json)' required: true type: string title: description: 'Release title (defaults to the tag)' required: false type: string notes: description: 'Release notes (Markdown)' required: false type: string release: types: [published] push: tags: ['v*'] # Read-only by default: the build jobs run dependency install scripts and build scripts, so # only the publish job holds a write token. permissions: contents: read # A release published after its tag push starts a second run for the same tag: queue it behind # the first so two builds never upload over each other. concurrency: group: release-app-${{ github.event.release.tag_name || (inputs.version && format('v{0}', inputs.version)) || github.ref_name }} cancel-in-progress: false env: # The release tag: the published release's, the version a manual run was given, or the pushed tag. TAG: ${{ github.event.release.tag_name || (inputs.version && format('v{0}', inputs.version)) || github.ref_name }} jobs: build: name: build (${{ matrix.label }}) runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - { runner: windows-latest, label: windows-x64, built: plan2code-app.exe, suffix: .exe } - { runner: macos-latest, label: macos-arm64, built: plan2code-app, suffix: '' } - { runner: macos-15-intel, label: macos-x64, built: plan2code-app, suffix: '' } - { runner: ubuntu-latest, label: linux-x64, built: plan2code-app, suffix: '' } defaults: run: shell: bash steps: - uses: actions/checkout@v4.2.2 with: persist-credentials: false - uses: actions/setup-node@v4.4.0 with: node-version: 22 cache: npm cache-dependency-path: plan2code-app/package-lock.json - name: Check the versions agree with the release tag run: node scripts/check-versions.mjs --tag "$TAG" - name: Install the pinned Rust toolchain working-directory: plan2code-app run: rustup toolchain install "$(grep channel rust-toolchain.toml | cut -d '"' -f2)" --profile minimal - name: Cache the Cargo registry and build output uses: actions/cache@v6.1.0 with: path: | ~/.cargo/registry ~/.cargo/git plan2code-app/target key: cargo-release-${{ matrix.label }}-${{ hashFiles('plan2code-app/Cargo.lock') }} restore-keys: | cargo-release-${{ matrix.label }}- - name: Name this week for the apt cache if: runner.os == 'Linux' id: week run: echo "week=$(date +%G-%V)" >> "$GITHUB_OUTPUT" - name: Cache the Linux system packages # Keep the downloaded .deb files (the WebKit packages are hundreds of MB, and the runner's # mirror is sometimes slow), as app.yml does. The key rolls over weekly. if: runner.os == 'Linux' uses: actions/cache@v6.1.0 with: path: ~/apt-archives key: apt-tauri-release-${{ runner.os }}-${{ steps.week.outputs.week }} restore-keys: | apt-tauri-release-${{ runner.os }}- - name: Install Linux system packages if: runner.os == 'Linux' run: | mkdir -p "$HOME/apt-archives/partial" sudo apt-get update sudo apt-get -o Dir::Cache::archives="$HOME/apt-archives" install -y libwebkit2gtk-4.1-dev build-essential libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev # apt ran as root: hand the folder back so the cache step can read and save it. sudo chown -R "$(id -u):$(id -g)" "$HOME/apt-archives" - name: Install the app's packages working-directory: plan2code-app run: npm ci # One plain executable per system: the web page is built into it, so it needs no installer. - name: Build working-directory: plan2code-app run: npm run tauri -- build --no-bundle - name: Name the file run: | VERSION="$(node -p "require('./plan2code-app/src-tauri/tauri.conf.json').version")" mkdir -p dist cp "plan2code-app/target/release/${{ matrix.built }}" "dist/plan2code-app-${VERSION}-${{ matrix.label }}${{ matrix.suffix }}" - uses: actions/upload-artifact@v4.6.2 with: name: app-${{ matrix.label }} path: dist/* if-no-files-found: error publish: name: attach to the release needs: build runs-on: ubuntu-latest permissions: contents: write env: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4.2.2 - uses: actions/download-artifact@v4.3.0 with: path: dist pattern: app-* merge-multiple: true - name: Verify every system's file is here run: | VERSION="$(node -p "require('./plan2code-app/src-tauri/tauri.conf.json').version")" cd dist missing=0 for name in "plan2code-app-${VERSION}-windows-x64.exe" "plan2code-app-${VERSION}-macos-arm64" "plan2code-app-${VERSION}-macos-x64" "plan2code-app-${VERSION}-linux-x64"; do if [ ! -f "$name" ]; then echo "::error::missing release asset $name" missing=1 fi done [ "$missing" -eq 0 ] - name: Write the checksum file run: | VERSION="$(node -p "require('./plan2code-app/src-tauri/tauri.conf.json').version")" cd dist sha256sum plan2code-app-* > "plan2code-app-${VERSION}-SHA256SUMS.txt" cat "plan2code-app-${VERSION}-SHA256SUMS.txt" - name: Attach to the release, creating it last env: RELEASE_TITLE: ${{ inputs.title }} RELEASE_NOTES: ${{ inputs.notes }} # No release yet (a manual run, or a bare tag push): create it as a DRAFT with every file # attached, then publish it, so the tag appears only when the files are already there. # A release that already exists (published by hand) just gets the files. A draft left # by an earlier failed run is reused. Releases made with the workflow's own token do not # start another run. run: | state="$(gh release list --limit 100 --json tagName,isDraft -q ".[] | select(.tagName==\"$TAG\") | .isDraft")" if [ -z "$state" ]; then notes_file="$(mktemp)" if [ -n "$RELEASE_NOTES" ]; then printf '%s' "$RELEASE_NOTES" > "$notes_file" notes_args=(--notes-file "$notes_file") else notes_args=(--generate-notes) fi gh release create "$TAG" dist/* --draft --target "$GITHUB_SHA" --title "${RELEASE_TITLE:-$TAG}" "${notes_args[@]}" state=true else gh release upload "$TAG" dist/* --clobber fi if [ "$state" = "true" ]; then gh release edit "$TAG" --draft=false fi