Skip to content

Commit ad36f6e

Browse files
authored
feat(ci): automated release one way flow to main (#2855)
1 parent 28f71dd commit ad36f6e

File tree

7 files changed

+75
-31
lines changed

7 files changed

+75
-31
lines changed

.github/workflows/bump.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Bump
2+
on:
3+
push:
4+
branches:
5+
- canary
6+
concurrency: ${{ github.workflow }}-${{ github.ref }}
7+
jobs:
8+
bump:
9+
runs-on: blacksmith-2vcpu-ubuntu-2204
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
container:
14+
image: node:22
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
18+
with:
19+
fetch-depth: 2
20+
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
21+
- name: pnpm setup
22+
uses: pnpm/action-setup@1e1c8eafbd745f64b1ef30a7d7ed7965034c486c
23+
- name: Install packages
24+
run: pnpm install --frozen-lockfile --prefer-offline
25+
- name: Create "version packages" pull request
26+
uses: changesets/action@04d574e831923498156e0b2b93152878063203a3
27+
with:
28+
version: pnpm run version
29+
title: "chore(root): version packages"
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-canary.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ on:
55
- canary
66
concurrency: ${{ github.workflow }}-${{ github.ref }}
77
jobs:
8-
release:
9-
name: release canary
8+
release-canary:
109
runs-on: blacksmith-2vcpu-ubuntu-2204
11-
permissions:
10+
permissions:
1211
contents: write
1312
pull-requests: write
1413
container:
@@ -23,16 +22,7 @@ jobs:
2322
uses: pnpm/action-setup@1e1c8eafbd745f64b1ef30a7d7ed7965034c486c
2423
- name: Install packages
2524
run: pnpm install --frozen-lockfile --prefer-offline
26-
- name: Enter prerelease mode
27-
# This step errors if it is already in prerelease mode
28-
continue-on-error: true
29-
run: pnpm canary:enter
30-
- name: Create "version packages" pull request or publish release
31-
uses: changesets/action@v1.5.3
32-
with:
33-
version: pnpm run version
34-
publish: pnpm run release
35-
title: "chore(root): version packages"
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Publish canary release
26+
run: tsx ./scripts/release-only-canary.ts
27+
env:
3828
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@ jobs:
2222
uses: pnpm/action-setup@1e1c8eafbd745f64b1ef30a7d7ed7965034c486c
2323
- name: Install packages
2424
run: pnpm install --frozen-lockfile --prefer-offline
25-
- name: Exit prerelease mode
26-
# This step errors if it is not in prerelease mode
27-
continue-on-error: true
28-
run: pnpm canary:exit
29-
- name: Create "version packages" pull request or publish release
30-
uses: changesets/action@v1.5.3
31-
with:
32-
version: pnpm run version
33-
publish: pnpm run release
34-
title: "chore(root): version packages"
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Publish stable release
26+
run: pnpm run release
27+
env:
3728
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
"devDependencies": {
1717
"@biomejs/biome": "2.3.11",
1818
"@changesets/cli": "2.29.8",
19+
"@changesets/pre": "2.0.2",
1920
"@types/node": "22.19.7",
2021
"@types/react": "19.0.1",
2122
"@types/react-dom": "19.0.1",
2223
"happy-dom": "20.0.11",
24+
"nypm": "0.6.2",
2325
"pkg-pr-new": "0.0.62",
2426
"tsconfig": "workspace:*",
2527
"tsdown": "0.15.12",

pnpm-lock.yaml

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/release-only-canary.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { readPreState } from '@changesets/pre';
2+
import { runScript } from 'nypm';
3+
4+
const preState = await readPreState(process.cwd());
5+
if (preState?.mode === 'pre') {
6+
console.log('Is in prerelease mode, making automated release');
7+
await runScript('release');
8+
} else {
9+
console.log(
10+
'Was not in prerelease, skipping automated release. To release this you should rebase onto main',
11+
);
12+
}

scripts/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"lib": ["ESNext"],
5+
"types": ["node"],
6+
"target": "ESNext",
7+
"module": "esnext",
8+
"moduleResolution": "nodenext"
9+
},
10+
"include": ["./*.ts"]
11+
}

0 commit comments

Comments
 (0)