Skip to content

Commit 030d929

Browse files
committed
release: harden GitHub release automation
1 parent 35a8ab9 commit 030d929

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Create GitHub Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Release version without the leading v (for example 4.0.1)
8+
required: true
9+
type: string
10+
target_sha:
11+
description: Commit SHA to tag and release
12+
required: true
13+
type: string
14+
15+
jobs:
16+
create-github-release:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: write
21+
22+
steps:
23+
- name: Create GitHub release if missing
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
VERSION: ${{ inputs.version }}
27+
TARGET_SHA: ${{ inputs.target_sha }}
28+
run: |
29+
tag="v${VERSION}"
30+
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
31+
echo "GitHub release $tag already exists; skipping."
32+
exit 0
33+
fi
34+
35+
gh release create "$tag" \
36+
--repo "$GITHUB_REPOSITORY" \
37+
--target "$TARGET_SHA" \
38+
--title "TKO ${VERSION}" \
39+
--generate-notes

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ jobs:
112112
- name: Checkout code
113113
# actions/checkout v6.0.2
114114
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
115+
with:
116+
persist-credentials: false
115117

116118
- name: Determine release version
117119
id: version
118-
run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT"
120+
run: echo "version=$(node -p 'require(\"./builds/reference/package.json\").version')" >> "$GITHUB_OUTPUT"
119121

120122
- name: Create GitHub release if missing
121123
env:

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ GitHub Actions workflows (`.github/workflows/`):
107107
| `lint-and-typecheck.yml` | PRs | Prettier + ESLint + tsc (combined) |
108108
| `publish-check.yml` | PRs | Verify packages are publishable |
109109
| `release.yml` | Push to main | Changeset version PRs + npm publish + GitHub release |
110+
| `github-release-repair.yml` | Manual | Recreate or repair a GitHub release/tag boundary after publish |
110111
| `deploy-docs.yml` | Push to main | Deploy tko.io to GitHub Pages |
111112
| `codeql-analysis.yml` | Weekly + main push | Security scanning |
112113

@@ -128,6 +129,7 @@ This creates a changeset file in `.changeset/` that gets committed with your PR.
128129
3. Review the PR (it bumps versions and updates changelogs)
129130
4. Merge it to publish to npm via GitHub Actions OIDC trusted publishing
130131
5. After a successful publish, CI creates the matching GitHub Release and tag
132+
6. If release creation ever needs repair after publish, run `github-release-repair.yml` with the version and merged commit SHA
131133

132134
Avoid manual workstation publishes. If release CI is unavailable, fix the
133135
workflow or npm trusted publisher configuration rather than bypassing it with a

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ It's available as `@tko/build.knockout`, and over CDN:
5656
| $ `make test-headless` | Run all tests with chromium. See below. |
5757
| $ `npx changeset add` | Add a changeset for package behavior changes in your PR |
5858
| Release workflow | On merge to `main`, CI opens or updates a version PR; when that version PR is merged and there are no remaining changesets, CI publishes from GitHub Actions via npm trusted publishing and creates the matching GitHub Release |
59+
| GitHub release repair | Manual workflow to recreate the GitHub Release/tag boundary if publish succeeded but release creation needs a retry |
5960
| $ `make test-coverage` | Run all tests and create a code coverage report |
6061

6162
Checkout the `Makefile` for more commands that can be executed with `make {command}`.

plans/build-and-release-certainty.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ to npm.
7474
- After a successful publish, creates the matching GitHub Release and tag
7575
- Uses npm trusted publishing via GitHub Actions OIDC
7676
- Requires trusted publisher configuration for the public `@tko/*` packages on npm
77+
- Includes a manual `github-release-repair.yml` workflow for rerunnable release/tag repair if GitHub release creation ever needs a retry after publish
7778

7879
---
7980

0 commit comments

Comments
 (0)