Commit bfaf0cf
committed
fix: prevent tag conflict by using @semantic-release/exec for webview sync
## Problem
Semantic Release was creating tags on commit A, then GitHub Actions was amending
the commit to add webview package changes, creating commit B. This caused the tag
to point to the wrong commit, leading to "tag already exists" errors on subsequent
releases.
## Root Cause
The workflow had a separate step that ran AFTER Semantic Release to sync
webview/package.json. This step used `git commit --amend --force` which changed
the commit SHA, making the already-created tag point to a non-existent commit.
Flow was:
1. Semantic Release creates commit A and tag v2.1.0 → A
2. Webview sync amends A to create commit B
3. Tag v2.1.0 still points to A (which no longer exists in history)
4. Next release: tag v2.1.0 exists but not in production branch → conflict
## Solution
Use `@semantic-release/exec` plugin's `prepareCmd` hook to update webview files
BEFORE Semantic Release creates the commit and tag. This ensures:
1. All version updates (root + webview) happen in prepare phase
2. Semantic Release commits everything in one atomic commit
3. Tag is created on the correct, final commit
4. No commit amendment needed
## Changes
1. **package.json**: Add `@semantic-release/exec` dependency
2. **.releaserc.json**: Add `@semantic-release/exec` plugin before `@semantic-release/git`
- prepareCmd: `cd src/webview && npm version ${nextRelease.version} --no-git-tag-version --allow-same-version && npm install`
3. **release.yml**: Remove "Sync webview package.json version" step (no longer needed)
## Plugin Execution Order
1. @semantic-release/commit-analyzer - Determine version bump
2. @semantic-release/release-notes-generator - Generate changelog
3. @semantic-release/changelog - Write CHANGELOG.md
4. @semantic-release/npm - Update root package.json
5. **@semantic-release/exec** - Update webview package.json + package-lock.json ← NEW
6. @semantic-release/git - Commit all changes + create tag
7. @semantic-release/github - Create GitHub release
## Testing
This fix will be validated on the next release. Expected behavior:
- Single commit with all version changes
- Tag points to the correct commit
- No "tag already exists" errors1 parent fb8f793 commit bfaf0cfCopy full SHA for bfaf0cf
4 files changed
+193-21Lines changed: 193 additions & 21 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- .github/workflows
Expand file treeCollapse file tree
Open diff view settings
Collapse file
.github/workflows/release.yml
Copy file name to clipboardExpand all lines: .github/workflows/release.yml-21Lines changed: 0 additions & 21 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | 49 | |
71 | 50 | |
72 | 51 | |
|
Collapse file
+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
54 | 54 | |
55 | 55 | |
56 | 56 | |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
57 | 63 | |
58 | 64 | |
59 | 65 | |
|
Collapse file
+186Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
80 | 80 | |
81 | 81 | |
82 | 82 | |
| 83 | + |
83 | 84 | |
84 | 85 | |
85 | 86 | |
|
0 commit comments