Skip to content

Commit 7ddd608

Browse files
authored
chore: additional release automation (#9231)
* chore: add additional automated release capabilities * "publish: stash of uncommitted changes by release script" * beta script * remove emtpy file * update beta publishing * "publish: stash of uncommitted changes by release script" * update scripts * update documentation
1 parent 0c32d70 commit 7ddd608

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1892
-805
lines changed

.github/workflows/beta-release.yml

-47
This file was deleted.
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Promote LTS Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The existing version to promote (e.g. `4.0.0`)'
8+
type: string
9+
channel:
10+
description: 'The NPM Distribution Tag (e.g. `lts` or `lts-4-8`)'
11+
type: string
12+
update-branch:
13+
description: 'Whether to update the associated LTS branch to the same commit as the tag'
14+
default: true
15+
type: boolean
16+
17+
env:
18+
TURBO_API: http://127.0.0.1:9080
19+
TURBO_TOKEN: this-is-not-a-secret
20+
TURBO_TEAM: myself
21+
22+
jobs:
23+
release:
24+
name: Run Release Script
25+
runs-on: ubuntu-latest
26+
environment: deployment
27+
steps:
28+
- name: Enforce Branch
29+
# Note: we always checkout main in actions/checkout, but this enforces
30+
# good hygiene.
31+
if: github.ref != 'refs/heads/main'
32+
run: |
33+
echo "Releases may only be performed from the main branch."
34+
exit 1
35+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
36+
with:
37+
fetch-depth: 1
38+
fetch-tags: true
39+
progress: false
40+
token: ${{ secrets.GH_DEPLOY_TOKEN }}
41+
- uses: ./.github/actions/setup
42+
with:
43+
install: true
44+
repo-token: ${{ secrets.GH_DEPLOY_TOKEN }}
45+
- name: Make sure git user is setup
46+
run: |
47+
git config --local user.email ${{ secrets.GH_DEPLOY_EMAIL }}
48+
git config --local user.name ${{ secrets.GH_DEPLOY_NAME }}
49+
- name: Publish with script
50+
run: bun release exec promote --v=${{ github.event.inputs.version }} --t=${{ github.event.inputs.channel }} -u ${{ github.event.inputs.update-branch }}
51+
env:
52+
FORCE_COLOR: 2
53+
CI: true
54+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish Beta Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
# This input is used to determine whether to start/continue a beta-cycle vs mirror from canary.
7+
#
8+
# A beta-cycle "forks" from canary. It starts by updating the beta branch to the current state
9+
# of main (canary). Thereafter any updates to the beta branch are cherry-picked from main or PR'd
10+
# to the beta branch.
11+
#
12+
# The (default) mirror approach instead directly copies the canary release to the beta branch
13+
# each time. This is useful when the changes in canary are relatively minor or safe to release
14+
# and
15+
# and then publishing a beta release. A mirror is a direct copy of the canary release.
16+
kind:
17+
description: 'Whether to start/continue a beta-cycle vs mirror from canary'
18+
required: true
19+
default: 'mirror'
20+
type: choice
21+
options:
22+
- beta-cycle # start or continue a beta-cycle.
23+
- mirror # mirror code from canary. This is the default.
24+
# At cycle start we must always reset the beta branch to main.
25+
is-cycle-start:
26+
description: 'Whether this is the start of a new release cycle (either kind)'
27+
required: true
28+
default: false
29+
type: boolean
30+
31+
env:
32+
TURBO_API: http://127.0.0.1:9080
33+
TURBO_TOKEN: this-is-not-a-secret
34+
TURBO_TEAM: myself
35+
36+
jobs:
37+
release:
38+
name: Run publish script
39+
runs-on: ubuntu-latest
40+
environment: deployment
41+
steps:
42+
- name: Enforce Branch
43+
# Note: we always checkout beta in actions/checkout, but this enforces
44+
# good hygiene.
45+
if: github.ref != 'refs/heads/main'
46+
run: |
47+
echo "Releases may only be performed from the main branch."
48+
exit 1
49+
- name: Make sure git user is setup
50+
run: |
51+
git config --local user.email ${{ secrets.GH_DEPLOY_EMAIL }}
52+
git config --local user.name ${{ secrets.GH_DEPLOY_NAME }}
53+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
54+
with:
55+
fetch-tags: true
56+
progress: false
57+
token: ${{ secrets.GH_DEPLOY_TOKEN }}
58+
fetch-depth: 3
59+
ref: beta
60+
- run: git fetch origin main --depth=1
61+
- name: Get last beta version from package.json
62+
if: github.event.inputs.kind == 'mirror'
63+
uses: sergeysova/jq-action@v2
64+
id: version
65+
with:
66+
cmd: 'jq .version package.json -r'
67+
- name: Reset the Beta Branch
68+
if: github.event.inputs.kind == 'mirror' || github.event.inputs.is-cycle-start == 'true'
69+
run: git reset --hard origin/main && git push origin beta -f
70+
- uses: ./.github/actions/setup
71+
with:
72+
install: true
73+
repo-token: ${{ secrets.GH_DEPLOY_TOKEN }}
74+
- name: Publish New Release
75+
# For beta-cycle we always increment from the branch state
76+
# For mirror we increment from the last beta version, unless it's start of a new cycle.
77+
if: github.event.inputs.kind == 'beta-cycle' || github.event.inputs.is-cycle-start == 'true'
78+
run: bun release exec publish beta
79+
env:
80+
FORCE_COLOR: 2
81+
CI: true
82+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
83+
- name: Publish New Mirror Release
84+
if: github.event.inputs.kind == 'mirror'
85+
run: bun release exec publish beta --from=${{ steps.version.outputs.stdout }}
86+
env:
87+
FORCE_COLOR: 2
88+
CI: true
89+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
90+
- uses: actions/upload-artifact@v4
91+
with:
92+
name: tarballs
93+
path: tmp/tarballs/**/*.tgz

.github/workflows/alpha-release.yml .github/workflows/release/publish-canary.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Alpha Releases
1+
name: Publish Canary Release
22

33
on:
44
workflow_dispatch:
@@ -27,12 +27,20 @@ jobs:
2727
runs-on: ubuntu-latest
2828
environment: deployment
2929
steps:
30+
- name: Enforce Branch
31+
# Note: we always checkout main in actions/checkout, but this enforces
32+
# good hygiene.
33+
if: github.ref != 'refs/heads/main'
34+
run: |
35+
echo "Releases may only be performed from the main branch."
36+
exit 1
3037
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
3138
with:
3239
fetch-depth: 1
3340
fetch-tags: true
3441
progress: false
3542
token: ${{ secrets.GH_DEPLOY_TOKEN }}
43+
ref: main
3644
- name: Check should run if HEAD is untagged
3745
run: |
3846
echo "HEAD is $(git name-rev --tags --name-only $(git rev-parse HEAD))"
@@ -48,7 +56,7 @@ jobs:
4856
git config --local user.email ${{ secrets.GH_DEPLOY_EMAIL }}
4957
git config --local user.name ${{ secrets.GH_DEPLOY_NAME }}
5058
- name: Publish with script
51-
run: bun run publish canary -i ${{ github.event.inputs.increment }}
59+
run: bun release canary -i ${{ github.event.inputs.increment }}
5260
env:
5361
FORCE_COLOR: 2
5462
CI: true
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish LTS Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'The branch to publish from, e.g. `lts-4-12`'
8+
required: true
9+
type: string
10+
channel:
11+
description: 'The NPM Distribution Tag. `lts` for current lts. `lts-prev` for e.g. `lts-4-8`'
12+
type: option
13+
default: 'lts'
14+
required: true
15+
options:
16+
- lts
17+
- lts-prev
18+
19+
env:
20+
TURBO_API: http://127.0.0.1:9080
21+
TURBO_TOKEN: this-is-not-a-secret
22+
TURBO_TEAM: myself
23+
24+
jobs:
25+
release:
26+
name: Run publish script
27+
runs-on: ubuntu-latest
28+
environment: deployment
29+
steps:
30+
- name: Enforce Branch
31+
# Note: we always checkout the correct lts branch in actions/checkout, but this enforces
32+
# good hygiene.
33+
if: github.ref != 'refs/heads/main'
34+
run: |
35+
echo "Releases may only be performed from the main branch."
36+
exit 1
37+
- name: Make sure git user is setup
38+
run: |
39+
git config --local user.email ${{ secrets.GH_DEPLOY_EMAIL }}
40+
git config --local user.name ${{ secrets.GH_DEPLOY_NAME }}
41+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
42+
with:
43+
fetch-tags: true
44+
progress: false
45+
token: ${{ secrets.GH_DEPLOY_TOKEN }}
46+
fetch-depth: 3
47+
ref: ${{ github.event.inputs.source-branch }}
48+
- uses: ./.github/actions/setup
49+
with:
50+
install: true
51+
repo-token: ${{ secrets.GH_DEPLOY_TOKEN }}
52+
- name: Publish New LTS Release
53+
# We always increment from the branch state
54+
run: bun release publish ${{ github.event.inputs.channel }}
55+
env:
56+
FORCE_COLOR: 2
57+
CI: true
58+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
59+
- uses: actions/upload-artifact@v4
60+
with:
61+
name: tarballs
62+
path: tmp/tarballs/**/*.tgz
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Publish Stable Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
source-branch:
7+
description: 'If starting a new cycle, or reversioning, the source branch to update the release branch from'
8+
required: false
9+
default: 'beta'
10+
type: choice
11+
options:
12+
- beta # promotes beta to stable
13+
- main # promotes canary to stable
14+
- release # re-releases a stable version
15+
# At cycle start we must always reset the release branch to beta.
16+
is-cycle-start:
17+
description: 'Whether this is the start of a new release cycle'
18+
required: true
19+
default: false
20+
type: boolean
21+
# downversion e.g. 5.4.0-alpha.1 => 5.3.1 happens when we use a canary, beta or later release to hotfix a stable
22+
# upversion e.g. 5.3.1 => 5.4.0 happens when we re-release an existing stable as a new minor/major
23+
# examples:
24+
# Upversion: 5.3.1 => 5.4.0
25+
# from-version: 5.3.1
26+
# increment: minor
27+
# Downversion: 5.4.0-alpha.1 => 5.3.1
28+
# from-version: 5.3.0
29+
# increment: patch
30+
from-version:
31+
description: 'When upversioning or downversioning, the version from which to increment to get the version number for the release'
32+
type: string
33+
increment:
34+
description: 'Type of Version Bump To Perform (only used when upversioning or downversioning)'
35+
required: true
36+
default: 'patch'
37+
type: choice
38+
options:
39+
- patch
40+
- minor
41+
- major
42+
43+
env:
44+
TURBO_API: http://127.0.0.1:9080
45+
TURBO_TOKEN: this-is-not-a-secret
46+
TURBO_TEAM: myself
47+
48+
jobs:
49+
release:
50+
name: Perform Release
51+
runs-on: ubuntu-latest
52+
environment: deployment
53+
steps:
54+
- name: Enforce Branch
55+
# Note: we always checkout release in actions/checkout, but this enforces
56+
# good hygiene.
57+
if: github.ref != 'refs/heads/main'
58+
run: |
59+
echo "Releases may only be performed from the main branch."
60+
exit 1
61+
- name: Make sure git user is setup
62+
run: |
63+
git config --local user.email ${{ secrets.GH_DEPLOY_EMAIL }}
64+
git config --local user.name ${{ secrets.GH_DEPLOY_NAME }}
65+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
66+
with:
67+
fetch-tags: true
68+
progress: false
69+
token: ${{ secrets.GH_DEPLOY_TOKEN }}
70+
fetch-depth: 3
71+
ref: release
72+
## Ensure we have a copy of the source branch
73+
- run: git fetch origin ${{ github.event.inputs.source-branch }} --depth=1
74+
- name: Reset the Release Branch
75+
if: github.event.inputs.source-branch != 'release' && (github.event.inputs.is-cycle-start == 'true' || github.event.inputs.from-version != null)
76+
run: git reset --hard origin/${{ github.event.inputs.source-branch }} && git push origin release -f
77+
- uses: ./.github/actions/setup
78+
with:
79+
install: true
80+
repo-token: ${{ secrets.GH_DEPLOY_TOKEN }}
81+
- name: Publish New Release
82+
# If we are not reversioning
83+
# Then we do the default patch increment from the current branch state.
84+
# This handles both start-of-cycle and bugfix releases.
85+
if: github.event.inputs.from-version == null
86+
run: bun release publish release
87+
env:
88+
FORCE_COLOR: 2
89+
CI: true
90+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
91+
- name: Publish New Release (Reversion)
92+
# If we are reversioning
93+
# Then we increment from the branch with the supplied increment
94+
# This handles both upversioning and downversioning
95+
if: github.event.inputs.from-version != null
96+
run: bun release publish release --from=${{ github.event.inputs.from-version }} --increment=${{ github.event.inputs.increment }}
97+
env:
98+
FORCE_COLOR: 2
99+
CI: true
100+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

0 commit comments

Comments
 (0)