Skip to content

Commit 67bfcf5

Browse files
abueideclaude
andauthored
fix(ci): remove @semantic-release/git to avoid branch protection push (#1141)
Remove the @semantic-release/git plugin which pushes version bump commits and CHANGELOG.md back to the branch. The default github.token cannot push to protected branches, and this avoids the need for a PAT. Version source of truth is git tags + npm registry. Add a sync-versions devbox command to pull latest npm versions into package.json on demand. Update release docs accordingly. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61e2dae commit 67bfcf5

4 files changed

Lines changed: 53 additions & 10 deletions

File tree

release.config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const changelogFile = 'CHANGELOG.md';
2-
31
module.exports = {
42
branches: ['master', { name: 'beta', prerelease: true }],
53
tagFormat: '${name}-v${version}',
@@ -9,10 +7,8 @@ module.exports = {
97
'@semantic-release/release-notes-generator',
108
{ preset: 'conventionalcommits' },
119
],
12-
['@semantic-release/changelog', { changelogFile }],
1310
['@semantic-release/npm', { npmPublish: true, provenance: true }],
1411
['@semantic-release/github', { successComment: false }],
15-
['@semantic-release/git', { assets: [changelogFile, 'package.json'] }],
1612
],
1713
debug: true,
1814
};

scripts/sync-versions.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Syncs package.json version fields with the latest published npm versions.
5+
# Run via: devbox run sync-versions
6+
7+
PROJECT_ROOT="${PROJECT_ROOT:-$(git rev-parse --show-toplevel)}"
8+
9+
updated=0
10+
skipped=0
11+
12+
for pkg_json in "$PROJECT_ROOT"/packages/*/package.json "$PROJECT_ROOT"/packages/plugins/*/package.json; do
13+
[ -f "$pkg_json" ] || continue
14+
15+
name=$(jq -r '.name' "$pkg_json")
16+
private=$(jq -r '.private // false' "$pkg_json")
17+
current=$(jq -r '.version' "$pkg_json")
18+
19+
if [ "$private" = "true" ]; then
20+
echo " skip $name (private)"
21+
skipped=$((skipped + 1))
22+
continue
23+
fi
24+
25+
latest=$(npm view "$name" version 2>/dev/null || echo "")
26+
if [ -z "$latest" ]; then
27+
echo " skip $name (not on npm)"
28+
skipped=$((skipped + 1))
29+
continue
30+
fi
31+
32+
if [ "$current" = "$latest" ]; then
33+
echo " ok $name@$current"
34+
skipped=$((skipped + 1))
35+
else
36+
jq --arg v "$latest" '.version = $v' "$pkg_json" > "$pkg_json.tmp" && mv "$pkg_json.tmp" "$pkg_json"
37+
echo " bump $name $current -> $latest"
38+
updated=$((updated + 1))
39+
fi
40+
done
41+
42+
echo ""
43+
echo "Done: $updated updated, $skipped unchanged/skipped"

shells/devbox-fast.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
],
2626
"format": ["treefmt"],
2727
"lint": ["treefmt --fail-on-change"],
28+
"sync-versions": ["bash $SCRIPTS_DIR/sync-versions.sh"],
2829
"update-apps": [
2930
"yarn install --no-immutable",
3031
"yarn e2e install --no-immutable",

wiki/release.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,33 @@ This repo uses semantic-release with multi-semantic-release to version and publi
44

55
### Prerequisites
66

7-
- Secrets: `GH_TOKEN` (repo `contents` write) and `NPM_TOKEN` (publish). CI also passes `YARN_NPM_AUTH_TOKEN` (same as `NPM_TOKEN`).
7+
- Secrets: npm trusted publishing (OIDC) is configured per-package on npmjs.com. The workflow uses `github.token` for GitHub operations.
88
- Git history: full clone (`fetch-depth: 0`) so semantic-release can find prior tags.
99
- Commit format: conventional commits; commitlint is already configured.
1010

1111
### What runs
1212

1313
- Config files: `release.config.js` (single-package defaults) and `multi-release.config.js` (multi-package orchestration, sequential init/prepare, ignore private packages, tag format/branches).
14-
- Plugins: commit analyzer + release notes, changelog (`CHANGELOG.md`), npm publish, GitHub release (no success comment), and git commit of changelog + package.json.
14+
- Plugins: commit analyzer + release notes, npm publish (with provenance), and GitHub release (no success comment).
1515
- Script: root `yarn release` runs `multi-semantic-release` with the above config per public package.
1616

1717
### CI/CD path (recommended)
1818

1919
1. Ensure `master`/`beta` are green. Merges must use conventional commits.
20-
2. Trigger `Publish` workflow in Actions. Inputs are tokens only; workflow fetches full history, installs Devbox, then runs `devbox run release`.
21-
3. Outputs: package tags (`${name}-vX.Y.Z`), npm publishes, GitHub releases, and updated changelog commits pushed back via the workflow token.
20+
2. Trigger `Release` workflow in Actions. Choose type: `dry-run`, `beta`, or `production`.
21+
3. Outputs: package tags (`${name}-vX.Y.Z`), npm publishes, and GitHub releases.
22+
23+
Note: version bumps and changelogs are **not** committed back to the repo. The source of truth for versions is the git tags and npm registry. To sync the repo's `package.json` versions with npm, run `devbox run --config=shells/devbox-fast.json sync-versions` and include the changes in a PR.
2224

2325
### Local dry run
2426

25-
1. `GH_TOKEN=<token> NPM_TOKEN=<token> YARN_NPM_AUTH_TOKEN=<token>` (GH token needs `contents` write; npm token can be automation/classic publish).
26-
2. `devbox run release -- --dry-run` to see what would publish. Omit `--dry-run` to actually publish (only do this if you intend to release from your machine).
27+
1. `GH_TOKEN=<token> devbox run --config=shells/devbox-fast.json release-dry-run` (GH token needs `contents` read).
28+
2. Omit `--dry-run` to actually publish (only do this if you intend to release from your machine; npm auth is handled via OIDC in CI).
2729

2830
### Tips and gotchas
2931

3032
- Only public packages release; private workspaces (e.g., `packages/shared`) are ignored.
3133
- Tag pattern is important: keep `${name}-v${version}` if you create manual tags for debugging.
3234
- If adding a new branch for releases, update both `release.config.js` and `multi-release.config.js`.
3335
- Keep yarn.lock in sync before releasing to avoid install differences between CI and local.
36+
- `.npmrc` contains `workspaces-update=false` to prevent `npm version` from failing on Yarn's `workspace:` protocol.

0 commit comments

Comments
 (0)