Skip to content

Commit 7972769

Browse files
committed
docs: add prerelease setup guide
1 parent 132a24a commit 7972769

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
yarn commitlint --edit $1
4+
devbox run -- yarn commitlint --edit $1

PRERELEASE_SETUP.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ Note: `chore/*` branches do not publish - they're for internal changes not meant
2424
Since semantic-release now controls which branches can publish based on `release.config.js`, you can either:
2525

2626
**Option A: Allow any branch** (Recommended)
27+
2728
- Leave "Deployment branches and tags" set to "All branches"
2829
- semantic-release will handle branch filtering
2930

3031
**Option B: Restrict to specific patterns**
32+
3133
- Select "Protected branches and tags only"
3234
- Add patterns: `fix/*`, `feat/*`, `beta`
3335

3436
### 3. Add Required Reviewers (Optional)
3537

3638
If you want manual approval before publishing:
39+
3740
- Enable "Required reviewers"
3841
- Add reviewers from your team
3942
- Set wait timer if desired
@@ -45,12 +48,14 @@ The environment needs access to npm for publishing. You have two options:
4548
#### Option A: npm Token (Traditional)
4649

4750
1. Generate an npm automation token:
51+
4852
```bash
4953
npm login
5054
npm token create --type=automation
5155
```
5256

5357
2. Add the token as a secret:
58+
5459
- Click "Add secret"
5560
- Name: `NPM_TOKEN`
5661
- Value: `npm_xxx...` (your automation token)
@@ -69,21 +74,25 @@ The environment needs access to npm for publishing. You have two options:
6974
#### Option B: npm Provenance with OIDC (Recommended)
7075
7176
The current setup uses npm provenance with OIDC, which doesn't require storing an NPM_TOKEN. This is more secure because:
77+
7278
- No long-lived tokens to manage
7379
- Automatic provenance attestation
7480
- Built-in supply chain security
7581
7682
**No additional npm setup needed!** The workflow already has:
83+
7784
- `id-token: write` permission
7885
- `@semantic-release/npm` with `provenance: true`
7986

8087
npm will automatically authenticate using GitHub's OIDC provider.
8188

8289
**Requirements:**
90+
8391
- The `@segment` npm organization must have publishing from GitHub Actions enabled
8492
- The package must be public or the org must be on a paid npm plan
8593

8694
To verify OIDC is configured:
95+
8796
1. Go to: https://www.npmjs.com/settings/segment/packages
8897
2. Check that "Publish" permissions include GitHub Actions
8998
3. If not, contact npm org admin to enable it
@@ -98,6 +107,7 @@ gh workflow run release.yml -f type=dry-run --ref fix/your-branch
98107
```
99108

100109
This will:
110+
101111
- Run CI checks
102112
- Simulate the release process
103113
- Show what would be published (without actually publishing)
@@ -110,6 +120,7 @@ gh workflow run release.yml -f type=prerelease --ref fix/your-branch
110120
```
111121

112122
This will:
123+
113124
- Run CI checks
114125
- Run E2E tests
115126
- Publish to npm with the appropriate dist-tag
@@ -144,8 +155,9 @@ npm install @segment/analytics-react-native@2.22.1-fix.1
144155
### "semantic-release says no version will be published"
145156

146157
Check that your branch name matches one of the configured patterns in `release.config.js`:
158+
147159
- `fix/*` - bug fixes for client distribution
148-
- `feat/*` - new features for client distribution
160+
- `feat/*` - new features for client distribution
149161
- `beta` - explicit beta channel
150162
- `master` - production releases
151163
- Version branches like `1.x` or `1.2.x` - maintenance releases
@@ -155,18 +167,21 @@ Note: `chore/*` branches intentionally don't publish as they're for internal cha
155167
### "npm publish failed with 403"
156168

157169
If using Option A (npm token):
170+
158171
- Verify `NPM_TOKEN` is set in the environment secrets
159172
- Check the token has publish permissions: `npm token list`
160173
- Ensure the token hasn't expired
161174

162175
If using Option B (OIDC):
176+
163177
- Verify the GitHub Actions OIDC provider is configured in npm org settings
164178
- Check that `id-token: write` permission is set in the workflow
165179
- Ensure `provenance: true` is set in semantic-release npm plugin config
166180

167181
### "Environment branch policy blocking publish"
168182

169183
If you set "Protected branches only" in the environment:
184+
170185
- Make sure your branch pattern is added to the protection rules
171186
- Or switch to "All branches" and rely on semantic-release filtering
172187

@@ -181,11 +196,13 @@ If you set "Protected branches only" in the environment:
181196
## Migrating from Old "Beta" Setup
182197

183198
The old setup used `{ name: '*', prerelease: 'beta' }` which made ALL non-master branches publish as "beta". This was confusing because:
199+
184200
- Fix branches weren't actually beta releases
185201
- You couldn't have multiple prerelease channels
186202
- The GitHub environment was called "Publish-Beta" but handled all prereleases
187203

188204
The new setup is more explicit and semantically correct:
205+
189206
- Each branch category gets its own channel
190207
- The environment is now "Publish-Prerelease" to reflect its broader scope
191208
- "beta" is now an explicit channel for the `beta` branch only

devbox.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
"ci:install": ["yarn install --immutable"],
2525
"ci:commitlint": ["bash -c 'echo \"$PR_TITLE\" | yarn commitlint'"],
2626
"check": [
27-
"devbox run lint",
28-
"devbox run format-check",
29-
"devbox run build",
30-
"devbox run typecheck",
31-
"devbox run test"
27+
"yarn lint",
28+
"yarn format:check",
29+
"yarn build",
30+
"yarn typecheck",
31+
"yarn test"
3232
],
3333
"build": ["yarn build"],
3434
"test": ["yarn test"],

0 commit comments

Comments
 (0)