Skip to content

Commit 3900716

Browse files
azuclaude
andcommitted
feat: add fully automated release workflow
- Add auto-release workflow with version selection (patch/minor/major) - Automatically updates Cargo.toml and CHANGELOG.md - Creates git tag and triggers GitHub release - Integrates with existing Homebrew formula update workflow - Update documentation with new automated process 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e5d56de commit 3900716

File tree

2 files changed

+151
-20
lines changed

2 files changed

+151
-20
lines changed

.github/workflows/auto-release.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Auto Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
jobs:
21+
auto-release:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
with:
28+
fetch-depth: 0
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
33+
with:
34+
node-version: '20'
35+
36+
- name: Install semver CLI
37+
run: npm install -g semver
38+
39+
- name: Get current version
40+
id: current_version
41+
run: |
42+
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
43+
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
44+
echo "Current version: $CURRENT_VERSION"
45+
46+
- name: Set release type
47+
id: release_type
48+
run: |
49+
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
50+
echo "type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
51+
echo "Release type: $RELEASE_TYPE"
52+
53+
- name: Calculate new version
54+
id: new_version
55+
run: |
56+
CURRENT_VERSION="${{ steps.current_version.outputs.current }}"
57+
RELEASE_TYPE="${{ steps.release_type.outputs.type }}"
58+
NEW_VERSION=$(semver -i $RELEASE_TYPE $CURRENT_VERSION)
59+
60+
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
61+
echo "New version: $NEW_VERSION"
62+
63+
- name: Update Cargo.toml
64+
run: |
65+
NEW_VERSION="${{ steps.new_version.outputs.new }}"
66+
sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" Cargo.toml
67+
echo "Updated Cargo.toml to version $NEW_VERSION"
68+
69+
- name: Update CHANGELOG.md
70+
run: |
71+
NEW_VERSION="${{ steps.new_version.outputs.new }}"
72+
TODAY=$(date +%Y-%m-%d)
73+
74+
# Get commits since last tag for changelog
75+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
76+
if [ -n "$LAST_TAG" ]; then
77+
COMMITS=$(git log ${LAST_TAG}..HEAD --oneline --pretty=format:"- %s")
78+
else
79+
COMMITS=$(git log --oneline --pretty=format:"- %s" -10)
80+
fi
81+
82+
# Insert new version section after "## [Unreleased]"
83+
sed -i "/## \[Unreleased\]/a\\
84+
\\
85+
## [$NEW_VERSION] - $TODAY\\
86+
\\
87+
### Changes\\
88+
$COMMITS" CHANGELOG.md
89+
90+
echo "Updated CHANGELOG.md"
91+
92+
- name: Commit version bump
93+
run: |
94+
NEW_VERSION="${{ steps.new_version.outputs.new }}"
95+
git config --local user.email "action@github.com"
96+
git config --local user.name "GitHub Action"
97+
git add Cargo.toml CHANGELOG.md
98+
git commit -m "chore: release v$NEW_VERSION
99+
100+
🤖 Generated with [Claude Code](https://claude.ai/code)
101+
102+
Co-Authored-By: Claude <noreply@anthropic.com>"
103+
104+
- name: Create and push tag
105+
run: |
106+
NEW_VERSION="${{ steps.new_version.outputs.new }}"
107+
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
108+
git push origin main
109+
git push origin "v$NEW_VERSION"
110+
111+
- name: Trigger Homebrew update
112+
run: |
113+
NEW_VERSION="${{ steps.new_version.outputs.new }}"
114+
# Wait a moment for the release workflow to complete
115+
sleep 60
116+
gh workflow run "Update Homebrew Formula" --field tag="v$NEW_VERSION"
117+
env:
118+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,37 +137,50 @@ cargo clippy
137137

138138
## Release Process
139139

140-
This project uses automated CI/CD for releases:
140+
This project uses **fully automated releases** via GitHub Actions:
141141

142-
### Automated Steps
142+
### Automated Release (Recommended)
143143

144-
1. **Create Release**: Tag and push creates GitHub release with binaries
144+
1. **Trigger Auto Release**:
145+
- Go to [Actions → Auto Release](https://github.com/azu/confirm-pam/actions/workflows/auto-release.yml)
146+
- Click "Run workflow"
147+
- Select release type: `patch`, `minor`, or `major`
148+
- Click "Run workflow"
149+
150+
2. **What happens automatically**:
151+
- ✅ Version bumped in `Cargo.toml`
152+
-`CHANGELOG.md` updated with recent commits
153+
- ✅ Git tag created and pushed
154+
- ✅ GitHub release with binaries created
155+
- ✅ Homebrew formula update triggered
156+
157+
3. **Final manual step**:
158+
- Review and merge the auto-generated Homebrew formula PR
159+
160+
### Manual Release (Legacy)
161+
162+
<details>
163+
<summary>For manual control over release process</summary>
164+
165+
1. **Manual Steps**:
145166
```bash
167+
# Update version and changelog manually
146168
git tag v0.x.x
147169
git push origin v0.x.x
148170
```
149171

150-
2. **GitHub Actions**: Automatically builds and publishes release assets
151-
152-
### Manual Steps
153-
154-
3. **Update Homebrew Formula** (Semi-automated):
172+
2. **Homebrew Update**:
155173
- Go to [Actions → Update Homebrew Formula](https://github.com/azu/confirm-pam/actions/workflows/update-homebrew.yml)
156-
- Click "Run workflow"
157-
- Enter the release tag (e.g., `v0.2.0`)
158-
- This creates a branch with updated formula
159-
- Manually create PR from the generated branch: `gh pr create --base main --head update-homebrew-X.X.X`
174+
- Enter release tag and run workflow
175+
- Create PR from generated branch: `gh pr create --base main --head update-homebrew-X.X.X`
160176

161-
4. **Merge Formula PR**: Review and merge the PR to complete Homebrew update
177+
</details>
162178

163-
### Release Checklist
179+
### Release Types
164180

165-
- [ ] Update `CHANGELOG.md`
166-
- [ ] Bump version in `Cargo.toml`
167-
- [ ] Create and push git tag
168-
- [ ] Wait for GitHub Actions to complete
169-
- [ ] Manually trigger Homebrew formula update
170-
- [ ] Merge the generated Homebrew formula PR
181+
- **patch** (0.1.0 → 0.1.1): Bug fixes, small improvements
182+
- **minor** (0.1.0 → 0.2.0): New features, enhancements
183+
- **major** (0.1.0 → 1.0.0): Breaking changes, major releases
171184

172185
## Contributing
173186

0 commit comments

Comments
 (0)