Skip to content

fix(desktop): improve generation defaults and empty state (#403) #30

fix(desktop): improve generation defaults and empty state (#403)

fix(desktop): improve generation defaults and empty state (#403) #30

Workflow file for this run

name: Release-plz
on:
push:
branches: [main]
permissions: {}
jobs:
# Creates/updates the "chore: release vX.Y.Z" PR (workspace version bump),
# then finishes it with a scripted commit: CHANGELOG.md [Unreleased]
# promotion and the desktop-app version sync (desktop/src-tauri is excluded
# from the workspace, so release-plz never touches it).
#
# Both jobs mint a GitHub App token (release-plz-mold) instead of using
# GITHUB_TOKEN: events created with the default token never trigger other
# workflows (GitHub's recursion guard), so CI would not run on the release
# PR and the tag push would not trigger release.yml. The follow-up sync
# commit is pushed with the same app token for the same reason — required
# status checks bind to the PR HEAD SHA, which the sync commit becomes.
release-plz-pr:
name: Release PR
if: github.repository_owner == 'utensils'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.RELEASE_PLZ_APP_ID }}
private-key: ${{ secrets.RELEASE_PLZ_APP_PRIVATE_KEY }}
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Run release-plz release-pr
id: release-plz
uses: release-plz/action@v0.5
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Sync release PR (changelog promotion + desktop version)
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
RELEASE_PR_JSON: ${{ steps.release-plz.outputs.pr }}
run: |
set -euo pipefail
if [ -z "$RELEASE_PR_JSON" ]; then
echo "release-plz returned no PR; nothing to sync."
exit 0
fi
number=$(jq -r '.number // empty' <<< "$RELEASE_PR_JSON")
branch=$(jq -r '.head_branch // empty' <<< "$RELEASE_PR_JSON")
if [ -z "$number" ] || [ -z "$branch" ]; then
echo "release-plz did not create or update a PR; nothing to sync."
exit 0
fi
git fetch "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
"+refs/heads/$branch:refs/heads/$branch"
git checkout "$branch"
scripts/release/sync-release-pr.sh
if ! git diff --quiet; then
git config user.name "release-plz-mold[bot]"
git config user.email "302347651+release-plz-mold[bot]@users.noreply.github.com"
git commit -am "chore(release): promote changelog and sync desktop version"
git push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:$branch"
else
echo "Release PR files already in sync."
fi
current_body=$(mktemp)
rendered_body=$(mktemp)
trap 'rm -f "$current_body" "$rendered_body"' EXIT
gh pr view "$number" --repo "$GITHUB_REPOSITORY" --json body --jq .body > "$current_body"
version=$(sed -n '/^\[workspace\.package\]/,/^\[/s/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)
if [ -z "$version" ]; then
echo "error: could not read [workspace.package] version from Cargo.toml" >&2
exit 1
fi
scripts/release/render-release-pr-body.sh CHANGELOG.md "$version" "$current_body" > "$rendered_body"
if ! cmp -s "$current_body" "$rendered_body"; then
gh pr edit "$number" --repo "$GITHUB_REPOSITORY" --body-file "$rendered_body"
else
echo "Release PR body already in sync."
fi
# After the release PR merges, creates and pushes the vX.Y.Z tag, which
# triggers release.yml (binaries, desktop DMG, GitHub release, crates.io,
# Docker, AUR) and flakehub-publish-tagged.yml. publish + git_release are
# disabled in release-plz.toml, so this job only tags.
#
# Deliberately NO concurrency group: cancelling a release mid-flight can
# skip it entirely (release-plz docs).
release-plz-release:
name: Release (tag)
if: github.repository_owner == 'utensils'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.RELEASE_PLZ_APP_ID }}
private-key: ${{ secrets.RELEASE_PLZ_APP_PRIVATE_KEY }}
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Run release-plz release
uses: release-plz/action@v0.5
with:
command: release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}