Skip to content

Commit ab75169

Browse files
committed
ci(release): release without git commits
1 parent 7db1b8b commit ab75169

3 files changed

Lines changed: 116 additions & 27 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch: # Allow manual trigger
88
inputs:
99
dry_run:
10-
description: 'Run in dry-run mode (no actual release)'
10+
description: "Run in dry-run mode (no actual release)"
1111
required: false
1212
type: boolean
1313
default: false
@@ -23,7 +23,9 @@ jobs:
2323
name: Run CI
2424
uses: ./.github/workflows/ci.yml
2525

26-
# Automated release with semantic-release
26+
# Automated release with semantic-release (no-commit mode)
27+
# This configuration creates releases without pushing version commits back to main
28+
# Perfect for repositories with strict branch protection/rulesets
2729
release:
2830
name: Semantic Release
2931
runs-on: ubuntu-latest
@@ -34,8 +36,8 @@ jobs:
3436
uses: actions/checkout@v4
3537
with:
3638
fetch-depth: 0 # Fetch all history for semantic-release
37-
token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
38-
persist-credentials: true # Need credentials for semantic-release to push
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
persist-credentials: false # No need to push commits in no-commit mode
3941

4042
- name: Setup Node.js
4143
uses: actions/setup-node@v4
@@ -59,19 +61,18 @@ jobs:
5961
echo "filename=$VSIX_FILE" >> $GITHUB_OUTPUT
6062
echo "Built VSIX file: $VSIX_FILE"
6163
62-
- name: Run semantic-release
64+
- name: Run semantic-release (no-commit mode)
6365
env:
64-
GITHUB_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6567
VSCE_PAT: ${{ secrets.VSCE_PAT }}
66-
GIT_AUTHOR_NAME: github-actions[bot]
67-
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
68-
GIT_COMMITTER_NAME: github-actions[bot]
69-
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
7068
run: |
7169
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
72-
echo "Running in dry-run mode..."
70+
echo "Running in dry-run mode (no commits will be pushed)..."
7371
npx semantic-release --dry-run
7472
else
73+
echo "Running semantic-release in no-commit mode..."
74+
echo "This will create a GitHub release with VSIX but won't update package.json/CHANGELOG in the repo"
75+
echo "TODO: (and good first issue) actually introduce semantic release updating (after stable release) "
7576
npx semantic-release
7677
fi
7778

.releaserc.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"plugins": [
44
"@semantic-release/commit-analyzer",
55
"@semantic-release/release-notes-generator",
6-
"@semantic-release/changelog",
76
[
87
"@semantic-release/npm",
98
{
@@ -23,20 +22,9 @@
2322
{
2423
"path": "*.vsix",
2524
"label": "VS Code Extension (VSIX)"
26-
},
27-
{
28-
"path": "CHANGELOG.md",
29-
"label": "Changelog"
3025
}
3126
]
3227
}
33-
],
34-
[
35-
"@semantic-release/git",
36-
{
37-
"assets": ["package.json", "CHANGELOG.md"],
38-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
39-
}
4028
]
4129
]
4230
}

docs/RELEASE_SETUP.md

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,39 @@ We use a Personal Access Token (PAT) with bypass permissions to allow semantic-r
3838
- **Name**: `GH_PAT`
3939
- **Secret**: Paste the token you created
4040

41-
### 3. Configure Branch Protection Rules
41+
### 3. Configure Branch Protection (Rulesets or Legacy)
42+
43+
#### Option A: GitHub Rulesets (Recommended - Newer Repositories)
44+
45+
**Important**: Deploy keys do NOT work with rulesets for semantic-release. You need to bypass for specific actors.
46+
47+
1. Go to Settings → Rules → Rulesets
48+
2. Find or create a ruleset that applies to the `main` branch
49+
3. Configure bypass permissions:
50+
51+
**Method 1: Bypass for Repository Admin (Simplest)**
52+
- Under "Bypass list", click "Add bypass"
53+
- Select "Repository admin"
54+
- This allows repository admins to bypass (semantic-release will use admin PAT)
55+
56+
**Method 2: Bypass for GitHub App**
57+
- Under "Bypass list", click "Add bypass"
58+
- Select "GitHub Apps"
59+
- Add the GitHub Actions app if available
60+
61+
**Method 3: Bypass for Specific User**
62+
- Create a PAT (see step 1)
63+
- Under "Bypass list", click "Add bypass"
64+
- Select "Organization members" or "Repository collaborators"
65+
- Add the user who owns the PAT
66+
67+
4. Ensure these ruleset settings allow semantic-release to work:
68+
- **Require pull request before merging**: Add bypass for your chosen actor
69+
- **Require status checks to pass**: Add bypass for your chosen actor
70+
- **Require linear history**: Can be enabled (semantic-release creates merge commits)
71+
- **Block force pushes**: Keep enabled (semantic-release doesn't force push)
72+
73+
#### Option B: Legacy Branch Protection Rules
4274

4375
1. Go to Settings → Branches → Branch protection rules
4476
2. Edit the rule for `main`
@@ -145,8 +177,15 @@ This creates releases without pushing version bumps back to main.
145177

146178
Solution: The PAT needs "Workflows" permission. Recreate the token with this permission added.
147179

148-
### "protected branch hook declined"
180+
### "protected branch hook declined" or "Resource protected by organization SAML enforcement"
149181

182+
**For GitHub Rulesets:**
183+
1. Verify the PAT owner is in the bypass list (not deploy keys)
184+
2. Check Settings → Rules → Rulesets → View ruleset runs to see why it was blocked
185+
3. Ensure the ruleset bypass includes the correct actor type (Repository admin, Org member, or App)
186+
4. If using org-level rulesets, you may need org admin permissions
187+
188+
**For Legacy Protection:**
150189
Solution: Ensure the PAT user or github-actions[bot] is in the bypass list for branch protection.
151190

152191
### "Author identity unknown"
@@ -158,8 +197,69 @@ Solution: The workflow sets `GIT_AUTHOR_NAME` and `GIT_AUTHOR_EMAIL` environment
158197
Check:
159198
1. `GH_PAT` secret is properly set
160199
2. PAT has not expired
161-
3. PAT has correct permissions
162-
4. Branch protection allows bypass
200+
3. PAT has correct permissions (Contents: R/W minimum)
201+
4. Branch protection/rulesets allow bypass for the PAT owner
202+
5. PAT is authorized for SSO (if applicable)
203+
204+
### Deploy keys don't work with Rulesets
205+
206+
This is expected. Deploy keys cannot be added to ruleset bypass lists. Solutions:
207+
1. Use a Personal Access Token (PAT) instead
208+
2. Add the PAT owner to the ruleset bypass list
209+
3. Use "Repository admin" bypass if the PAT is from an admin
210+
211+
### Verifying Ruleset Configuration
212+
213+
Test if your PAT can push to protected branch:
214+
215+
```bash
216+
# Clone with PAT
217+
git clone https://<PAT>@github.com/JuliaPluto/advanced-vscode-extension.git
218+
cd advanced-vscode-extension
219+
git checkout main
220+
221+
# Make a test commit
222+
echo "test" >> test.txt
223+
git add test.txt
224+
git commit -m "test: ruleset bypass"
225+
git push
226+
227+
# If this fails, your ruleset bypass is not configured correctly
228+
# Clean up
229+
git reset --hard HEAD~1
230+
git push --force
231+
```
232+
233+
### Alternative: Skip Version Commits
234+
235+
If you can't get rulesets to allow pushes, configure semantic-release to skip version commits and only create tags/releases:
236+
237+
Update `.releaserc.json`:
238+
```json
239+
{
240+
"branches": ["main"],
241+
"plugins": [
242+
"@semantic-release/commit-analyzer",
243+
"@semantic-release/release-notes-generator",
244+
["@semantic-release/npm", { "npmPublish": false }],
245+
["semantic-release-vsce", { "packageVsix": true }],
246+
[
247+
"@semantic-release/github",
248+
{
249+
"assets": [
250+
{ "path": "*.vsix", "label": "VS Code Extension (VSIX)" }
251+
]
252+
}
253+
]
254+
]
255+
}
256+
```
257+
258+
This removes:
259+
- `@semantic-release/changelog` - no changelog updates
260+
- `@semantic-release/git` - no version commits to main
261+
262+
Releases are created without pushing back to the repository.
163263

164264
## Security Notes
165265

0 commit comments

Comments
 (0)