Skip to content

Commit df3fe83

Browse files
mldangeloclaude
andauthored
chore: set up release-please for automated releases (#24)
## Summary - Adds `release-please` GitHub Action workflow that runs on pushes to `main` - Creates `release-please-config.json` with `simple` release type (appropriate for a bash script project) - Creates `.release-please-manifest.json` tracking the current version (`0.9.1`) - Adds `x-release-please-version` annotation to `src/crabcode` so the `VERSION` variable is auto-updated on release ## How it works 1. When conventional commits (`feat:`, `fix:`, `chore:`, etc.) are pushed to `main`, release-please automatically opens/updates a release PR with version bump and changelog entries 2. Merging the release PR creates a GitHub release with the new tag (`v0.x.x`) 3. The CHANGELOG.md is auto-formatted with Prettier after PR creation 4. The `VERSION` in `src/crabcode` is updated automatically via the generic file updater ## Configuration choices - **Release type**: `simple` — the right fit for a bash script project (not node/python) - **Tag format**: `v0.9.1` style (`include-v-in-tag: true`) - **Pre-major bumping**: enabled (`bump-minor-pre-major` + `bump-patch-for-minor-pre-major`) since we're pre-1.0 - **Bootstrap SHA**: set to current HEAD so release-please won't process historical commits ## Test plan - [ ] Merge this PR, then push a conventional commit (e.g. `feat: ...`) to `main` - [ ] Verify release-please opens a release PR with correct version bump and changelog - [ ] Merge the release PR and verify a GitHub release + tag is created - [ ] Verify `src/crabcode` VERSION is updated in the release commit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f9a354b commit df3fe83

4 files changed

Lines changed: 89 additions & 1 deletion

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: release-please
2+
run-name: crabcode release by @${{ github.actor }}
3+
4+
concurrency:
5+
group: release-please-${{ github.ref }}
6+
cancel-in-progress: false
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
jobs:
15+
release-please:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
outputs:
21+
release_created: ${{ steps.release.outputs.release_created }}
22+
tag_name: ${{ steps.release.outputs.tag_name }}
23+
version: ${{ steps.release.outputs.version }}
24+
steps:
25+
- uses: googleapis/release-please-action@v4
26+
id: release
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Check if PR exists
31+
id: check-pr
32+
run: |
33+
PR_OUTPUT='${{ steps.release.outputs.pr }}'
34+
if [ -n "$PR_OUTPUT" ] && [ "$PR_OUTPUT" != "null" ]; then
35+
echo "has_pr=true" >> $GITHUB_OUTPUT
36+
echo "pr_branch=$(echo '${{ steps.release.outputs.pr }}' | jq -r '.headBranchName')" >> $GITHUB_OUTPUT
37+
else
38+
echo "has_pr=false" >> $GITHUB_OUTPUT
39+
fi
40+
41+
- uses: actions/checkout@v6
42+
if: steps.check-pr.outputs.has_pr == 'true'
43+
with:
44+
ref: ${{ steps.check-pr.outputs.pr_branch }}
45+
fetch-depth: 1
46+
47+
- name: Format CHANGELOG.md with Prettier
48+
if: steps.check-pr.outputs.has_pr == 'true'
49+
run: |
50+
echo "Formatting CHANGELOG.md on branch: ${{ steps.check-pr.outputs.pr_branch }}"
51+
npx --yes prettier@latest --write CHANGELOG.md
52+
53+
if git diff --quiet CHANGELOG.md; then
54+
echo "No formatting changes needed"
55+
else
56+
echo "Formatting changes detected, committing..."
57+
git config user.name "github-actions[bot]"
58+
git config user.email "github-actions[bot]@users.noreply.github.com"
59+
git add CHANGELOG.md
60+
git commit -m "chore: format CHANGELOG.md with prettier"
61+
git push
62+
echo "Formatting committed and pushed"
63+
fi

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.9.1"
3+
}

release-please-config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"bootstrap-sha": "5496807d998f56cb2bed937c6707c72ef26932a0",
4+
"include-component-in-tag": false,
5+
"include-v-in-tag": true,
6+
"packages": {
7+
".": {
8+
"release-type": "simple",
9+
"package-name": "crabcode",
10+
"changelog-path": "CHANGELOG.md",
11+
"bump-minor-pre-major": true,
12+
"bump-patch-for-minor-pre-major": true,
13+
"extra-files": [
14+
{
15+
"type": "generic",
16+
"path": "src/crabcode",
17+
"glob": false
18+
}
19+
]
20+
}
21+
}
22+
}

src/crabcode

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
set -e
2929

30-
VERSION="0.9.1"
30+
VERSION="0.9.1" # x-release-please-version
3131
CONFIG_DIR="$HOME/.crabcode"
3232
CONFIG_FILE="$CONFIG_DIR/config.yaml"
3333
WIP_BASE="$CONFIG_DIR/wip"

0 commit comments

Comments
 (0)