Skip to content

Commit bb69420

Browse files
committed
Fix release tag workflow
1 parent 9c46415 commit bb69420

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ jobs:
3535
- uses: actions/setup-python@v5
3636
with:
3737
python-version: '3.11'
38-
- run: pnpm install --frozen-lockfile --ignore-scripts
39-
- run: pnpm exec electron-rebuild -f -w better-sqlite3
38+
- run: pnpm install --frozen-lockfile
4039
- run: pnpm release
4140
env:
4241
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/tag.mjs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if (!['patch', 'minor', 'major'].includes(bump)) {
1414
}
1515

1616
const exec = (cmd, opts = {}) => execSync(cmd, { stdio: 'inherit', ...opts })
17+
const read = (cmd) => execSync(cmd, { encoding: 'utf8' }).trim()
1718

1819
// Ensure working tree is clean
1920
try {
@@ -23,6 +24,20 @@ try {
2324
process.exit(1)
2425
}
2526

27+
const branch = read('git branch --show-current')
28+
if (branch !== 'main') {
29+
console.error('Releases must be tagged from main after the version bump is ready to publish.')
30+
process.exit(1)
31+
}
32+
33+
exec('git fetch origin main')
34+
const localHead = read('git rev-parse HEAD')
35+
const remoteHead = read('git rev-parse origin/main')
36+
if (localHead !== remoteHead) {
37+
console.error('Local main must match origin/main before tagging. Pull or push your changes first.')
38+
process.exit(1)
39+
}
40+
2641
// Bump version in package.json only, no git tag
2742
exec(`npm version ${bump} --no-git-tag-version`)
2843

@@ -32,15 +47,12 @@ const tag = `v${version}`
3247
// Commit the bump locally, then tag that commit
3348
exec(`git add package.json`)
3449
exec(`git commit -m "chore: bump version to ${tag}"`)
50+
exec('git push origin main')
3551
exec(`git tag ${tag}`)
3652

3753
// Push the tag (triggers CI) — tags are not subject to branch rules
3854
exec(`git push origin ${tag}`)
3955

4056
console.log(`
4157
Tag ${tag} pushed. CI will build and publish the release.
42-
43-
The version bump commit is local. Push it to main:
44-
- If you can push directly: git push
45-
- Otherwise open a PR from your current branch
4658
`)

0 commit comments

Comments
 (0)