Skip to content

Commit 35a8ab9

Browse files
committed
release: automate GitHub releases
1 parent 01e2272 commit 35a8ab9

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,38 @@ jobs:
9898
# npm generates provenance attestations automatically during trusted
9999
# publishing from GitHub Actions.
100100
run: npx changeset publish
101+
102+
github-release:
103+
name: Create GitHub Release
104+
needs: [prepare-release, publish]
105+
if: needs.prepare-release.outputs.has_changesets == 'false' && needs.publish.result == 'success'
106+
runs-on: ubuntu-latest
107+
108+
permissions:
109+
contents: write
110+
111+
steps:
112+
- name: Checkout code
113+
# actions/checkout v6.0.2
114+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
115+
116+
- name: Determine release version
117+
id: version
118+
run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT"
119+
120+
- name: Create GitHub release if missing
121+
env:
122+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
VERSION: ${{ steps.version.outputs.version }}
124+
run: |
125+
tag="v${VERSION}"
126+
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
127+
echo "GitHub release $tag already exists; skipping."
128+
exit 0
129+
fi
130+
131+
gh release create "$tag" \
132+
--repo "$GITHUB_REPOSITORY" \
133+
--target "$GITHUB_SHA" \
134+
--title "TKO ${VERSION}" \
135+
--generate-notes

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ GitHub Actions workflows (`.github/workflows/`):
106106
| `test-headless.yml` | PRs | Matrix test (Chrome, Firefox, jQuery) |
107107
| `lint-and-typecheck.yml` | PRs | Prettier + ESLint + tsc (combined) |
108108
| `publish-check.yml` | PRs | Verify packages are publishable |
109-
| `release.yml` | Push to main | Changeset version PRs + npm publish |
109+
| `release.yml` | Push to main | Changeset version PRs + npm publish + GitHub release |
110110
| `deploy-docs.yml` | Push to main | Deploy tko.io to GitHub Pages |
111111
| `codeql-analysis.yml` | Weekly + main push | Security scanning |
112112

@@ -127,6 +127,7 @@ This creates a changeset file in `.changeset/` that gets committed with your PR.
127127
2. If unreleased changesets exist, the action opens a "Version Packages" PR
128128
3. Review the PR (it bumps versions and updates changelogs)
129129
4. Merge it to publish to npm via GitHub Actions OIDC trusted publishing
130+
5. After a successful publish, CI creates the matching GitHub Release and tag
130131

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ It's available as `@tko/build.knockout`, and over CDN:
5555
| $ `make test` | Run all tests with electron. See below. |
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 |
58-
| 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 |
58+
| 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 |
5959
| $ `make test-coverage` | Run all tests and create a code coverage report |
6060

6161
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
@@ -71,6 +71,7 @@ to npm.
7171
- Builds all packages and runs tests
7272
- If unreleased changesets exist, opens/updates a version PR
7373
- If version PR is merged, publishes to npm
74+
- After a successful publish, creates the matching GitHub Release and tag
7475
- Uses npm trusted publishing via GitHub Actions OIDC
7576
- Requires trusted publisher configuration for the public `@tko/*` packages on npm
7677

0 commit comments

Comments
 (0)