Skip to content

Commit 678b7bb

Browse files
committed
chore: add-patch-release-docs-and-workflow
1 parent 8d50e40 commit 678b7bb

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Release Patch
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch-name:
6+
description: 'Name for the patch branch (typically like "patch-release-1.0.1")'
7+
required: true
8+
9+
env:
10+
NX_CLOUD_ENCRYPTION_KEY: ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
11+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
12+
NX_CLOUD_DISTRIBUTED_EXECUTION: true
13+
PNPM_CACHE_FOLDER: .pnpm-store
14+
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
15+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
16+
CI: true
17+
18+
jobs:
19+
create-and-publish-patch:
20+
permissions:
21+
contents: write # to create release (changesets/action)
22+
issues: write # to post issue comments (changesets/action)
23+
pull-requests: write # to create pull request (changesets/action)
24+
id-token: write # give id token write for provenance
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
token: ${{ secrets.GH_TOKEN }}
31+
32+
# Check out the provided branch - fail if it doesn't exist
33+
- name: Checkout patch branch
34+
run: |
35+
git checkout ${{ github.event.inputs.branch-name }}
36+
37+
# Setup environment
38+
- uses: pnpm/action-setup@v4
39+
with:
40+
run_install: false
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: '22.14.0'
44+
cache: 'pnpm'
45+
46+
- run: pnpm install --frozen-lockfile
47+
48+
# This line enables distribution for NX
49+
- run: pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
50+
51+
- run: pnpm exec playwright install
52+
53+
- uses: nrwl/nx-set-shas@v4
54+
55+
- name: Setup pnpm config
56+
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
57+
58+
- name: Version packages
59+
run: pnpm exec changeset version
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
62+
63+
# Build and test affected packages
64+
- name: Build and test
65+
run: pnpm exec nx affected -t build lint test e2e-ci
66+
67+
- name: Publish patch
68+
run: |
69+
echo "//registry.npmjs.org/:_authToken=$NPM_ACCESS_TOKEN" > .npmrc
70+
pnpm publish -r
71+
env:
72+
NPM_CONFIG_PROVENANCE: 'true'
73+
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
74+
75+
# Use changeset tag to create git tags according to changesets config
76+
- name: Create and push git tags
77+
run: |
78+
git config --global user.email "actions@github.com"
79+
git config --global user.name "GitHub Actions"
80+
pnpm exec changeset tag
81+
git push --follow-tags
82+
83+
# Build and publish docs for the patch
84+
- name: Build docs
85+
run: pnpm generate-docs
86+
87+
- name: Publish api docs
88+
uses: JamesIves/github-pages-deploy-action@v4.7.3
89+
with:
90+
folder: docs
91+
commit-message: 'chore: release-api-docs-patch'

contributing_docs/releases.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,54 @@ We provide verdaccio two ways:
9595
topological graph.
9696

9797
- Publishing to a hosted private registry: Please message @ryanbas21 on slack.
98+
99+
# Patch Releases
100+
101+
In the event a patch release is required, we should always fix the bug on `main` before releasing any code.
102+
103+
This follows the trunk based development style of releasing which is best suited for changesets.
104+
105+
Once the bug is confirmed fixed, we can cherry-pick the fix from main, onto the latest release branch.
106+
107+
This cherry-pick should contain a changeset, if it does not, we will need to add one.
108+
109+
Once we have that new release branch confirmed working, and it has a changeset, we can push the branch to github.
110+
111+
We can then use the workflow_dispatch github workflow, called patch-release.yml, pass in the branch to release from as an input.
112+
113+
This will kickoff the release workflow, including building, testing, linting, etc.
114+
115+
Once passing, we will attempt to publish with provenance from CI (signing the packages).
116+
117+
It is worth noting that we could be on 1.0.1 on `npm` and our `main` branch may be on versions `1.0.0`. But because we push the tag up, changesets should respect the tag, and versions should be triggered based on the tag in the Release PR
118+
119+
## Patch Release Process
120+
121+
- Identify and fix the bug on main first
122+
This allows us to properly reproduce and verify the fix
123+
It ensures proper code review through your normal PR process
124+
The fix gets merged to main and will be included in future releases
125+
126+
- After the fix is merged to main, cherry-pick it to a patch branch
127+
128+
- Create a branch from the last release tag (e.g., v1.0.0)
129+
130+
- Cherry-pick the bugfix commit(s) from main to this patch branch
131+
132+
- Add a changeset file describing the patch change
133+
134+
- Push the patch branch and run the patch workflow
135+
136+
- This will publish the patch version (e.g., 1.0.1)
137+
138+
- No need to merge back to main
139+
140+
Since the fix already exists on main, there's no need to merge back
141+
This prevents any potential merge conflicts or duplication
142+
143+
This approach provides several benefits:
144+
145+
- Ensures the bug is properly identified and fixed first
146+
- Maintains normal code review process
147+
- Creates a clean git history with the fix clearly flowing from main to the patch branch
148+
- Avoids duplication of changes or complicated merge operations

0 commit comments

Comments
 (0)