Skip to content

Commit 032de6b

Browse files
setup some release stuff (#100)
This sets up some stuff for release automation, built around github actions, changesets, and pkg.pr.new. - pkg-pr-new.yml: For every pull request, we publish a version to their registry, and a comment will popup in the PR comments showing how to use it (eg: cloudflare/workers-oauth-provider#99 (comment)) This lets people test out PRs before they even land. - prerelease.yml: whenever something lands in main, after Test(test.yml) passes, we publish to npm with `@beta`, with the version being the git hash. This lets people test whatever's in master quickly. - release.yml: When a PR lands after Test(test.yml) passes, the changeset action opens a Version Packages PR (if not already created), that deletes all changesets under the .changeset folder, and populates the CHANGELOG with their contents. You can edit the CHANGELOG further as you wish here. - release.yml: When the Version Packages PR itself lands, then the changesets action will do an npm release (with the highest common changeset level: path, minor, or major). It will also tag git and make a github release. You can make a changeset in 2 ways: - running `npx changeset` in your PR branch, which will ask you a couple of questions (what level of change, and title). You can add more details directly in the generated changeset. You can add as many (or as few, even 0) changesets as you'd like. - Every PR will have a comment generated that shows what changesets are included (or if they're not). This will also have a link to generate and add a changeset to the PR directly (example cloudflare/workers-oauth-provider#99 (comment))
1 parent 6404359 commit 032de6b

File tree

8 files changed

+2063
-86
lines changed

8 files changed

+2063
-86
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "cloudflare/capnweb" }
6+
],
7+
"commit": false,
8+
"fixed": [],
9+
"linked": [],
10+
"access": "public",
11+
"baseBranch": "main",
12+
"updateInternalDependencies": "patch",
13+
"ignore": []
14+
}

.changeset/good-glasses-see.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"capnweb": patch
3+
---
4+
5+
Trigger a first release

.github/workflows/pkg-pr-new.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish to pkg.pr.new for pre-release
2+
permissions:
3+
contents: read
4+
5+
on:
6+
pull_request: {}
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 1
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 22
18+
cache: "npm"
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Build packages
24+
run: npm run build
25+
26+
- name: Publish to pkg.pr.new
27+
run: npx pkg-pr-new publish

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release
2+
permissions:
3+
contents: write # to create release (changesets/action)
4+
issues: write # to post issue comments (changesets/action)
5+
pull-requests: write # to create pull request (changesets/action)
6+
id-token: write # to use OpenID Connect token for provenance (changesets/action)
7+
8+
on:
9+
workflow_run:
10+
workflows: ["Test"]
11+
branches: [main]
12+
types: [completed]
13+
14+
jobs:
15+
release:
16+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'cloudflare' }}
17+
timeout-minutes: 5
18+
runs-on: ubuntu-latest
19+
environment: release
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1
25+
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 24 # includes npm 11.5.1 or later, needed for trusted publishing
29+
cache: "npm"
30+
31+
- run: npm ci
32+
- run: npm run build
33+
34+
- id: changesets
35+
uses: changesets/action@v1
36+
with:
37+
# The standard step is only to run `changeset version` but this does not update the
38+
# package-lock.json file. So we also run `npm install`, which does this update.
39+
# This is a workaround until this is handled automatically by `changeset version`.
40+
# See https://github.com/changesets/changesets/issues/421.
41+
version: npx changeset version && npm install
42+
publish: npx changeset publish
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
prerelease:
47+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'cloudflare' }}
48+
timeout-minutes: 5
49+
runs-on: ubuntu-latest
50+
environment: release
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 1
56+
57+
- uses: actions/setup-node@v4
58+
with:
59+
node-version: 24 # includes npm 11.5.1 or later, needed for trusted publishing
60+
cache: "npm"
61+
62+
- run: npm ci
63+
64+
- name: Modify package.json version
65+
run: npx tsx .github/version-script.ts
66+
67+
- run: npm run build
68+
69+
- run: npm publish --tag beta

.github/workflows/test.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Test
2+
permissions:
3+
contents: read
24

35
on:
46
push:
5-
branches: [ main ]
7+
branches: [main]
68
pull_request:
7-
branches: [ main ]
9+
branches: [main]
810

911
jobs:
1012
test:
@@ -14,19 +16,19 @@ jobs:
1416
options: --user 1001
1517

1618
steps:
17-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v4
1820

19-
- name: Setup Node.js
20-
uses: actions/setup-node@v4
21-
with:
22-
node-version: '22'
23-
cache: 'npm'
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: "22"
25+
cache: "npm"
2426

25-
- name: Install dependencies
26-
run: npm ci
27+
- name: Install dependencies
28+
run: npm ci
2729

28-
- name: Build project
29-
run: npm run build
30+
- name: Build project
31+
run: npm run build
3032

31-
- name: Run tests
32-
run: npm test
33+
- name: Run tests
34+
run: npm test

0 commit comments

Comments
 (0)