Skip to content

Commit 2113227

Browse files
committed
release: split publish and release workflows
1 parent 030d929 commit 2113227

File tree

5 files changed

+24
-33
lines changed

5 files changed

+24
-33
lines changed
File renamed without changes.

.github/workflows/release.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
if: needs.prepare-release.outputs.has_changesets == 'false'
6767
runs-on: ubuntu-latest
6868

69+
outputs:
70+
release_version: ${{ steps.version.outputs.version }}
71+
6972
permissions:
7073
contents: read
7174
id-token: write
@@ -88,6 +91,10 @@ jobs:
8891
- name: Install dependencies
8992
run: npm ci
9093

94+
- name: Determine release version
95+
id: version
96+
run: echo "version=$(node -p 'require(\"./builds/reference/package.json\").version')" >> "$GITHUB_OUTPUT"
97+
9198
- name: Build all packages
9299
run: make
93100

@@ -99,39 +106,23 @@ jobs:
99106
# publishing from GitHub Actions.
100107
run: npx changeset publish
101108

102-
github-release:
103-
name: Create GitHub Release
109+
dispatch-github-release:
110+
name: Dispatch GitHub Release Workflow
104111
needs: [prepare-release, publish]
105112
if: needs.prepare-release.outputs.has_changesets == 'false' && needs.publish.result == 'success'
106113
runs-on: ubuntu-latest
107114

108115
permissions:
109-
contents: write
116+
actions: write
110117

111118
steps:
112-
- name: Checkout code
113-
# actions/checkout v6.0.2
114-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
115-
with:
116-
persist-credentials: false
117-
118-
- name: Determine release version
119-
id: version
120-
run: echo "version=$(node -p 'require(\"./builds/reference/package.json\").version')" >> "$GITHUB_OUTPUT"
121-
122-
- name: Create GitHub release if missing
119+
- name: Dispatch GitHub release workflow
123120
env:
124121
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125-
VERSION: ${{ steps.version.outputs.version }}
122+
VERSION: ${{ needs.publish.outputs.release_version }}
126123
run: |
127-
tag="v${VERSION}"
128-
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
129-
echo "GitHub release $tag already exists; skipping."
130-
exit 0
131-
fi
132-
133-
gh release create "$tag" \
124+
gh workflow run github-release.yml \
134125
--repo "$GITHUB_REPOSITORY" \
135-
--target "$GITHUB_SHA" \
136-
--title "TKO ${VERSION}" \
137-
--generate-notes
126+
--ref "$GITHUB_REF_NAME" \
127+
-f version="$VERSION" \
128+
-f target_sha="$GITHUB_SHA"

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ 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 + GitHub release |
110-
| `github-release-repair.yml` | Manual | Recreate or repair a GitHub release/tag boundary after publish |
109+
| `release.yml` | Push to main | Changeset version PRs + npm publish + dispatch GitHub release workflow |
110+
| `github-release.yml` | Manual + post-publish dispatch | Create or repair a GitHub release/tag boundary after publish |
111111
| `deploy-docs.yml` | Push to main | Deploy tko.io to GitHub Pages |
112112
| `codeql-analysis.yml` | Weekly + main push | Security scanning |
113113

@@ -128,8 +128,8 @@ This creates a changeset file in `.changeset/` that gets committed with your PR.
128128
2. If unreleased changesets exist, the action opens a "Version Packages" PR
129129
3. Review the PR (it bumps versions and updates changelogs)
130130
4. Merge it to publish to npm via GitHub Actions OIDC trusted publishing
131-
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
131+
5. After a successful publish, CI dispatches `github-release.yml` to create the matching GitHub Release and tag
132+
6. If release creation ever needs repair after publish, run `github-release.yml` manually with the version and merged commit SHA
133133

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

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ 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 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 |
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 dispatches the GitHub release workflow |
59+
| GitHub release workflow | Manual or post-publish workflow to create or repair the GitHub Release/tag boundary |
6060
| $ `make test-coverage` | Run all tests and create a code coverage report |
6161

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

plans/build-and-release-certainty.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ 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
74+
- After a successful publish, dispatches `github-release.yml` to create 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
77+
- Includes a manual `github-release.yml` workflow for rerunnable release/tag repair if GitHub release creation ever needs a retry after publish
7878

7979
---
8080

0 commit comments

Comments
 (0)