Skip to content

Commit fea9cd4

Browse files
committed
Add branch guard to CI publish job
- Verify tagged commit is on main before publishing - Requires fetch-depth: 0 for full history
1 parent f711d65 commit fea9cd4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ jobs:
2828
contents: write
2929
steps:
3030
- uses: actions/checkout@v6
31+
with:
32+
fetch-depth: 0
33+
- name: Verify tag is on main
34+
run: |
35+
if ! git branch -r --contains "$GITHUB_SHA" | grep -q 'origin/main'; then
36+
echo "Error: tag $GITHUB_REF_NAME is not on the main branch"
37+
exit 1
38+
fi
3139
- uses: actions/setup-node@v6
3240
with:
3341
node-version: 22

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ This force-moves the tag to the current commit and pushes it, re-triggering CI.
9191
### Branches
9292

9393
- **main** -- releases happen here; `npm version` enforces this via a branch guard
94-
- **dev** -- CI runs tests only (no publish); merge to main when ready
94+
- **dev** -- CI runs tests only; publish job verifies the tag is on main before proceeding
9595

9696
## CI
9797

9898
GitHub Actions (`.github/workflows/ci.yml`):
9999

100100
- **test** job runs on every push to `main`/`dev` and on PRs to `main`
101-
- **publish** job runs only on `v*` tags, after tests pass
101+
- **publish** job runs only on `v*` tags on `main`, after tests pass

0 commit comments

Comments
 (0)