Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Manual version bump: commits the new version to a release/vX.Y.Z branch and opens a PR into the branch it was run from.
# Merging that PR (by a person) triggers release.yml, which builds the installer and creates the draft release.
# Needs Settings → Actions → General → "Allow GitHub Actions to create and approve pull requests".
# The branch is pushed and the PR opened with a token of the repository's own GitHub App (vars.RELEASE_APP_CLIENT_ID,
# secrets.RELEASE_APP_PRIVATE_KEY; Contents and Pull requests read/write), not GITHUB_TOKEN, so that the PR
# triggers ci.yml like any other PR and gets the checks the main ruleset requires (D-60).
name: Bump version

on:
Expand All @@ -17,9 +19,7 @@ on:
required: false

permissions:
contents: write
pull-requests: write
actions: write # to start ci.yml on the release branch (D-52)
contents: read # every write uses the App token (D-60)

concurrency:
group: bump
Expand All @@ -38,10 +38,20 @@ jobs:
echo "::error::Run this workflow from a branch (got $REF_TYPE $REF_NAME)."
exit 1

# The commit step pushes the release branch with the checkout's credentials.
- name: Get a token of the release App
id: app-token
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write

# The commit step pushes the release branch with the checkout's credentials, the App token.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # zizmor: ignore[artipacked]
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
Expand Down Expand Up @@ -107,13 +117,17 @@ jobs:

- name: Commit, push and open the PR
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
CURRENT: ${{ steps.ver.outputs.current }}
NEXT: ${{ steps.ver.outputs.next }}
BASE: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Commit as the App's bot user, so that the commit and the PR show the same author.
bot="$APP_SLUG[bot]"
bot_id=$(gh api "users/$bot" --jq .id)
git config user.name "$bot"
git config user.email "$bot_id+$bot@users.noreply.github.com"
git switch -c "release/v$NEXT"
git add package.json package-lock.json src-tauri/tauri.conf.json src-tauri/Cargo.toml src-tauri/Cargo.lock
git commit -m "Release v$NEXT"
Expand All @@ -124,15 +138,7 @@ jobs:
if ! url=$(gh pr create --base "$BASE" --head "release/v$NEXT" --title "Release v$NEXT" --body "$body"); then
# Remove the branch again so that a rerun is not stopped by the "branch already exists" check.
git push origin --delete "release/v$NEXT" || true
echo "::error::Could not open the PR, so release/v$NEXT was deleted again. If the error says GitHub Actions is not permitted to create pull requests, turn on Settings → Actions → General → \"Allow GitHub Actions to create and approve pull requests\" and run this workflow again."
echo "::error::Could not open the PR, so release/v$NEXT was deleted again. Check that the release App is installed on this repository with Pull requests read/write, then run this workflow again."
exit 1
fi
echo "PR: $url" >> "$GITHUB_STEP_SUMMARY"

# A PR opened with GITHUB_TOKEN does not trigger pull_request workflows, but workflow_dispatch does.
# The CI run on the branch head reports the checks that the main ruleset requires (D-52).
- name: Run CI on the release branch
env:
GH_TOKEN: ${{ github.token }}
NEXT: ${{ steps.ver.outputs.next }}
run: gh workflow run ci.yml --ref "release/v$NEXT"
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Tooling: Oxfmt (`.oxfmtrc.json`: `printWidth` 120, trailing commas, Prettier-com
Supply chain (D-43): `.npmrc` sets `min-release-age=7`, `strict-allow-scripts` (approve a new install script with `npm approve-scripts <pkg>` after reading it) and `allow-git=none`; it needs npm 11.19+, which `devEngines` enforces. Cargo has no such setting, so `scripts/cargo-release-age.mjs` checks `Cargo.lock` against the index `pubtime` (`--fix` moves crates back). Workflow actions are pinned to commit SHAs (tag in a comment). The Rust toolchain is pinned in `rust-toolchain.toml` for local, CI and release builds; Dependabot (`.github/dependabot.yml`, 7-day cooldown) opens weekly update PRs for npm, Cargo and actions (D-53).

CI (D-50, since the repo went public): `.github/workflows/ci.yml` runs on every PR into `main` and every push to `main`, in three parallel jobs: `Frontend` (ubuntu: `deps:check`, `format:check`, `lint`, `test`), `Rust` (windows: `cargo fmt --check`, clippy and `cargo test` with `--locked`, no debug info; D-51) and `Supply chain` (ubuntu: cargo-deny and zizmor; D-53). The first two cover `npm run check`; still run it before pushing. The `main` ruleset "Require CI" makes both jobs required for merging (D-52); renaming a job in `ci.yml` means updating the ruleset too. If you add a check to `npm run check`, add it to `ci.yml` too. The release workflows (D-42) push nothing to `main`:
- `.github/workflows/bump.yml`, run by hand (`gh workflow run bump.yml -f bump=patch`, or `-f version=0.2.0`): writes the new version into `package.json`/`package-lock.json`, `tauri.conf.json` and `Cargo.toml`/`Cargo.lock` on a `release/vX.Y.Z` branch and opens a PR. It then starts `ci.yml` on that branch by `workflow_dispatch`, since a PR opened with `GITHUB_TOKEN` triggers no workflows.
- `.github/workflows/bump.yml`, run by hand (`gh workflow run bump.yml -f bump=patch`, or `-f version=0.2.0`): writes the new version into `package.json`/`package-lock.json`, `tauri.conf.json` and `Cargo.toml`/`Cargo.lock` on a `release/vX.Y.Z` branch and opens a PR. It pushes and opens the PR with a token of the repository's own GitHub App (`vars.RELEASE_APP_CLIENT_ID`, `secrets.RELEASE_APP_PRIVATE_KEY`), so the PR runs `ci.yml` like any other; a PR opened with `GITHUB_TOKEN` would not (D-60).
- `.github/workflows/release.yml`, run when a push to `main` changes the version in `package.json` (merging that PR), or by hand to release the current version: runs `npm run check`, builds the NSIS installer, pushes the `vX.Y.Z` tag and creates a draft release with the installer and `SHA256SUMS.txt`. A version with a `-` suffix becomes a pre-release.

E2E against the real engine (`src-tauri/tests/real_engine.rs`; each section is skipped when its env var is not set):
Expand Down
6 changes: 3 additions & 3 deletions docs/decisions/D-42-release-workflows.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# D-42 Releases: a bump PR, then a draft release on merge

- **Status**: Accepted (2026-11-27); CI and required checks added by D-50/D-52, toolchain pin moved to
`rust-toolchain.toml` by D-53, time limit and cache by D-55
`rust-toolchain.toml` by D-53, time limit and cache by D-55,
release PR opened with a GitHub App token by D-60
- **Code**: `.github/workflows/bump.yml`, `.github/workflows/release.yml`

## Context
Expand Down Expand Up @@ -31,7 +32,6 @@ Neither workflow pushes to `main`.

## Consequences

- "Allow GitHub Actions to create and approve pull requests" must be on. A tag ruleset on `v*` would block the tag
push.
- The release PR is opened by the repository's GitHub App (D-60). A tag ruleset on `v*` would block the tag push.
- Releases are published by hand from the draft. The installer is not code-signed and there is no updater
([#55](https://github.com/eddybean/speechorus/issues/55)).
6 changes: 3 additions & 3 deletions docs/decisions/D-52-required-checks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# D-52 CI is required to merge into `main`

- **Status**: Accepted (2026-11-28)
- **Status**: Accepted (2026-11-28); partly superseded by D-60 (how the release PR gets the checks)
- **Code**: the repository ruleset "Require CI" (GitHub settings), `.github/workflows/bump.yml`

## Decision
Expand All @@ -9,8 +9,8 @@
`Frontend (format, typecheck, Oxlint, Vitest)` and `Rust (rustfmt, clippy, cargo test)` from GitHub Actions. The
branch need not be up to date with `main`. Repository admins may bypass it (for a broken CI). The disabled ruleset
"main" is left as it was.
- The release PR from `bump.yml` must get these checks too. A PR opened with `GITHUB_TOKEN` triggers no
`pull_request` workflow, so `bump.yml` starts `ci.yml` on the release branch with `workflow_dispatch`.
- The release PR from `bump.yml` must get these checks too. It is opened with a GitHub App token, so it runs
`ci.yml` like any other PR (D-60).

## Consequences

Expand Down
36 changes: 36 additions & 0 deletions docs/decisions/D-60-bump-app-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# D-60 The release PR is opened with a GitHub App token, not `GITHUB_TOKEN`

- **Status**: Accepted (2026-11-28)
- **Code**: `.github/workflows/bump.yml`; the repository's GitHub App (Actions variable `RELEASE_APP_CLIENT_ID`, secret
`RELEASE_APP_PRIVATE_KEY`)

## Context

The release PR must get the checks that the "Require CI" ruleset requires (D-52). `bump.yml` opened it with
`GITHUB_TOKEN` and then started `ci.yml` on the branch with `workflow_dispatch`. On the v0.1.7 release PR (#42) that
dispatched run passed, but GitHub also created a `pull_request` CI run by `github-actions[bot]` and left it at
"awaiting approval" (`action_required`). That suite blocked the merge until someone approved it or bypassed the
ruleset.

## Decision

- `bump.yml` gets an installation token of the repository's own GitHub App with `actions/create-github-app-token`
(pinned by SHA), asking for Contents and Pull requests write only. The App has just those permissions, no webhook,
and is installed on this repository only.
- The checkout (whose credentials the push uses), the push of `release/vX.Y.Z` and `gh pr create` use that token. The
commit is made as the App's bot user, so the commit and the PR show the same author.
- The workflow's own `GITHUB_TOKEN` is cut to `contents: read`, and the `workflow_dispatch` step is removed: a PR
opened by an App runs `ci.yml` on `pull_request` like any other PR.

## Alternatives not taken

- Keeping the dispatch and approving or bypassing each time: every release needs a manual step, and bypassing
becomes a habit that hides a real failure.
- A personal access token: tied to one person's account, with an expiry to manage and wider access than needed.
- A release tool (release-please, changesets): changes the whole release flow (D-42) for what is a token problem.

## Consequences

- "Allow GitHub Actions to create and approve pull requests" (D-42) is no longer needed.
- If the App is uninstalled or its key is revoked, `bump.yml` fails at the token step; a new key goes into
`RELEASE_APP_PRIVATE_KEY`.
3 changes: 2 additions & 1 deletion docs/decisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ Sections that have nothing to say may be left out. Mention the user only for dec
| [D-56](D-56-react-19-ureq-3.md) | React 19 and ureq 3, and what each needed | dependencies |
| [D-58](D-58-memory-guard.md) | A free-memory check before the engine starts | engine |
| [D-59](D-59-explicit-downloads.md) | Models are resolved from `speech models`; only the catalog downloads | engine, models |
| [D-60](D-60-bump-app-token.md) | The release PR is opened with a GitHub App token, not `GITHUB_TOKEN` | CI, release |

Next free ID: D-61 (D-60 is taken by the `bump.yml` GitHub App token change).
Next free ID: D-61.

## Retired

Expand Down