Skip to content

Commit 78cc995

Browse files
authored
feat: add automated changesets release workflow (#1389)
1 parent daad54d commit 78cc995

10 files changed

Lines changed: 174 additions & 15 deletions

File tree

‎.changeset/config.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@
2525
],
2626
"snapshot": {
2727
"useCalculatedVersion": true
28+
},
29+
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
30+
"onlyUpdatePeerDependentsWhenOutOfRange": true
2831
}
2932
}

‎.github/workflows/release.yml‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
stable-release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
if: github.event_name == 'push'
15+
permissions:
16+
contents: write
17+
id-token: write
18+
pull-requests: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # tag=v4.1.0
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # tag=v4.4.0
31+
with:
32+
node-version: '24'
33+
registry-url: https://registry.npmjs.org/
34+
35+
- name: Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Build packages
39+
run: pnpm build
40+
41+
- name: Check release files
42+
run: pnpm lint:ci
43+
44+
- name: Test packages
45+
run: pnpm test
46+
47+
- name: Create release PR or publish packages
48+
id: changesets
49+
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # tag=v1.9.0
50+
with:
51+
version: pnpm version-packages
52+
publish: pnpm release
53+
commit: 'chore: changeset version'
54+
title: 'chore: changeset version'
55+
createGithubReleases: true
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
canary-release:
60+
name: Canary Release
61+
runs-on: ubuntu-latest
62+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
63+
permissions:
64+
contents: read
65+
id-token: write
66+
pull-requests: read
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Setup pnpm
75+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # tag=v4.1.0
76+
77+
- name: Setup Node.js
78+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # tag=v4.4.0
79+
with:
80+
node-version: '24'
81+
registry-url: https://registry.npmjs.org/
82+
83+
- name: Install dependencies
84+
run: pnpm install --frozen-lockfile
85+
86+
- name: Version packages for canary
87+
run: pnpm version-packages:canary
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Build canary packages
92+
run: pnpm build
93+
94+
- name: Check generated canary release files
95+
run: pnpm lint:ci
96+
97+
- name: Test canary packages
98+
run: pnpm test
99+
100+
- name: Publish canary packages
101+
run: pnpm release:canary
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎CONTRIBUTING.md‎

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,45 @@ The documentation is a part of the website, which is stored in `website` directo
7070

7171
### Publishing a release
7272

73-
We use [changesets](https://github.com/changesets/changesets) to automate to bump the version, update `CHANGELOG.md` files in published packages and publish to NPM registry. If you have publish access to the NPM `@callstack` scope, run the following from the default branch (usually `main` branch) to publish a new release:
73+
We use [changesets](https://github.com/changesets/changesets) and the
74+
[Changesets GitHub Action](https://github.com/changesets/action) to bump package
75+
versions, update package `CHANGELOG.md` files, publish to npm, and create GitHub
76+
releases.
7477

75-
```sh
76-
pnpm release
77-
```
78+
#### Stable releases
7879

79-
NOTE: You must have a `GITHUB_TOKEN` environment variable available. You can create a GitHub access token with the "repo" access [here](https://github.com/settings/tokens).
80+
When releasable changesets are merged to `main`, the `Release` workflow creates
81+
or updates a `chore: changeset version` pull request. This PR contains the exact
82+
package version changes and generated changelog entries for the next release.
83+
84+
Review the version numbers and changelog entries in that PR before merging it.
85+
When the version PR is merged to `main`, the same workflow runs `pnpm release`,
86+
publishes the packages to npm, pushes the release tags, and creates GitHub
87+
releases from the generated changelog entries.
88+
89+
#### Canary releases
90+
91+
Canary releases are published manually from the `Release` workflow in GitHub
92+
Actions. Run it only from the `main` branch. The workflow creates snapshot
93+
versions with the `canary` snapshot label, runs the full release checks, and
94+
publishes with the `canary` npm dist-tag without committing version changes or
95+
creating GitHub releases.
96+
97+
#### npm trusted publishing
98+
99+
Releases use npm trusted publishing instead of long-lived npm automation tokens.
100+
Do not add `NPM_TOKEN` or `NODE_AUTH_TOKEN` secrets for publishing.
101+
102+
Each published package in the `@callstack` scope must have trusted publishing
103+
configured on npmjs.com with GitHub Actions as the publisher:
104+
105+
- Owner: `callstack`
106+
- Repository: `repack`
107+
- Workflow file: `release.yml`
108+
- Allowed action: `npm publish`
109+
110+
The release workflows intentionally disable package-manager caching to avoid
111+
using a pnpm cache during publishing.
80112

81113
## Reporting issues
82114

‎package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"lint:ci": "biome check",
1414
"typecheck": "turbo run typecheck",
1515
"test": "turbo run test",
16-
"release": "pnpm build && pnpm lint && pnpm test && pnpm changeset publish",
16+
"version-packages": "pnpm changeset version && pnpm lint",
17+
"version-packages:canary": "pnpm changeset version --snapshot canary && pnpm lint",
18+
"release": "pnpm changeset publish",
19+
"release:canary": "pnpm changeset publish --tag canary --no-git-tag",
1720
"pods": "turbo run pods",
1821
"pods:update": "turbo run pods:update",
1922
"website:start": "pnpm --filter website run start",

‎packages/dev-server/package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
},
1313
"files": ["dist", "static"],
1414
"homepage": "https://github.com/callstack/repack",
15-
"repository": "github:callstack/repack",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/callstack/repack.git"
18+
},
1619
"keywords": ["react-native", "repack", "re.pack", "server", "dev-server"],
1720
"author": "zamotany <zamotany.oss@gmail.com>",
1821
"engines": {

‎packages/init/package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"license": "MIT",
66
"version": "5.2.5",
77
"homepage": "https://github.com/callstack/repack",
8-
"repository": "github:callstack/repack",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/callstack/repack.git"
11+
},
912
"keywords": ["repack", "re.pack", "init", "repack-init"],
1013
"publishConfig": {
1114
"registry": "https://registry.npmjs.org/",

‎packages/plugin-expo-modules/package.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"author": "Jakub Romańczyk <jakub.romanczyk@callstack.com>",
66
"license": "MIT",
77
"homepage": "https://github.com/callstack/repack",
8-
"repository": "github:callstack/repack",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/callstack/repack.git"
11+
},
912
"type": "commonjs",
1013
"main": "dist/index.js",
1114
"types": "dist/index.d.ts",
@@ -33,7 +36,7 @@
3336
"node": ">=18"
3437
},
3538
"peerDependencies": {
36-
"@callstack/repack": "workspace:*"
39+
"@callstack/repack": "workspace:^"
3740
},
3841
"devDependencies": {
3942
"@callstack/repack": "workspace:*",

‎packages/plugin-nativewind/package.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"contributors": ["Jakub Romańczyk <jakub.romanczyk@callstack.com>"],
77
"license": "MIT",
88
"homepage": "https://github.com/callstack/repack",
9-
"repository": "github:callstack/repack",
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/callstack/repack.git"
12+
},
1013
"type": "commonjs",
1114
"main": "dist/index.js",
1215
"types": "dist/index.d.ts",
@@ -42,7 +45,7 @@
4245
"dedent": "^0.7.0"
4346
},
4447
"peerDependencies": {
45-
"@callstack/repack": "workspace:*",
48+
"@callstack/repack": "workspace:^",
4649
"nativewind": ">=4.1.23",
4750
"react-native-css-interop": ">=0.1.22",
4851
"postcss": ">=8.4.31",

‎packages/plugin-reanimated/package.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"author": "Jakub Romańczyk <jakub.romanczyk@callstack.com>",
66
"license": "MIT",
77
"homepage": "https://github.com/callstack/repack",
8-
"repository": "github:callstack/repack",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/callstack/repack.git"
11+
},
912
"type": "commonjs",
1013
"main": "dist/index.js",
1114
"types": "dist/index.d.ts",
@@ -41,7 +44,7 @@
4144
},
4245
"peerDependencies": {
4346
"@babel/core": "^7.20",
44-
"@callstack/repack": "workspace:*"
47+
"@callstack/repack": "workspace:^"
4548
},
4649
"devDependencies": {
4750
"@callstack/repack": "workspace:*",

‎packages/repack/package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
"src/modules/ScriptManager/NativeScriptManager.ts"
3131
],
3232
"homepage": "https://github.com/callstack/repack",
33-
"repository": "github:callstack/repack",
33+
"repository": {
34+
"type": "git",
35+
"url": "https://github.com/callstack/repack.git"
36+
},
3437
"keywords": [
3538
"react-native",
3639
"react native",

0 commit comments

Comments
 (0)