Skip to content

Commit 7ec3b95

Browse files
chore: add create-release-pr workflow and changelog automation (#89)
* chore: add create-release-pr workflow and changelog automation - Add create-release-pr.yaml workflow with workflow_dispatch for patch/minor/major chart version bumps, changelog finalization, and automated PR creation - Update update-sourcebot-version.yaml to add changelog entry under [Unreleased] when bumping appVersion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: finalize changelog with version header in update-sourcebot-version The workflow bumps the chart version, so the changelog entry should be under a dated version header, not left under [Unreleased]. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6e710de commit 7ec3b95

File tree

2 files changed

+146
-0
lines changed

2 files changed

+146
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Create Release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump_type:
7+
description: "Type of version bump to apply"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
concurrency:
16+
group: create-release-pr
17+
cancel-in-progress: false
18+
19+
jobs:
20+
create-release-pr:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
26+
steps:
27+
- name: Generate GitHub App token
28+
id: generate_token
29+
uses: actions/create-github-app-token@v2
30+
with:
31+
app-id: ${{ secrets.RELEASE_APP_ID }}
32+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
33+
owner: sourcebot-dev
34+
repositories: sourcebot-helm-chart
35+
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
with:
39+
token: ${{ steps.generate_token.outputs.token }}
40+
41+
- name: Setup Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: '22'
45+
46+
- name: Install semver
47+
run: npm install -g semver
48+
49+
- name: Calculate new version
50+
id: calculate_version
51+
run: |
52+
CURRENT_VERSION=$(grep '^version:' charts/sourcebot/Chart.yaml | cut -d ' ' -f 2)
53+
echo "Current chart version: $CURRENT_VERSION"
54+
55+
NEW_VERSION=$(semver -i ${{ inputs.bump_type }} $CURRENT_VERSION)
56+
echo "New chart version: $NEW_VERSION"
57+
58+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
59+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
60+
61+
- name: Check if version already exists
62+
run: |
63+
VERSION=${{ steps.calculate_version.outputs.new_version }}
64+
if grep -q "## \[$VERSION\]" CHANGELOG.md; then
65+
echo "Error: Version $VERSION already exists in CHANGELOG.md"
66+
exit 1
67+
fi
68+
69+
- name: Update Chart.yaml version
70+
run: |
71+
sed -i "s/^version: .*/version: ${{ steps.calculate_version.outputs.new_version }}/" charts/sourcebot/Chart.yaml
72+
73+
- name: Update CHANGELOG.md
74+
run: |
75+
VERSION=${{ steps.calculate_version.outputs.new_version }}
76+
DATE=$(date +%Y-%m-%d)
77+
78+
# Insert the new version header after the [Unreleased] line
79+
sed -i "/## \[Unreleased\]/a\\
80+
\\
81+
## [$VERSION] - $DATE" CHANGELOG.md
82+
83+
echo "Updated CHANGELOG.md with version $VERSION"
84+
cat CHANGELOG.md | head -n 20
85+
86+
- name: Install helm-docs
87+
run: |
88+
cd /tmp
89+
curl -L https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz | tar xz
90+
sudo mv helm-docs /usr/local/bin/
91+
92+
- name: Update README.md
93+
run: |
94+
cd charts/sourcebot
95+
helm-docs
96+
97+
- name: Create Pull Request
98+
uses: peter-evans/create-pull-request@v8
99+
with:
100+
token: ${{ steps.generate_token.outputs.token }}
101+
commit-message: |
102+
chore: release chart v${{ steps.calculate_version.outputs.new_version }}
103+
104+
- Bump chart version from ${{ steps.calculate_version.outputs.current_version }} to ${{ steps.calculate_version.outputs.new_version }}
105+
- Update CHANGELOG.md
106+
- Update generated documentation
107+
title: "chore: release chart v${{ steps.calculate_version.outputs.new_version }}"
108+
body: |
109+
## Summary
110+
Release chart version ${{ steps.calculate_version.outputs.new_version }} (${{ inputs.bump_type }} bump).
111+
112+
## Changes
113+
- 📦 Bump chart version from ${{ steps.calculate_version.outputs.current_version }} to ${{ steps.calculate_version.outputs.new_version }}
114+
- 📝 Update CHANGELOG.md
115+
- 📝 Update generated documentation
116+
117+
---
118+
**Bump type**: `${{ inputs.bump_type }}`
119+
branch: release-chart-v${{ steps.calculate_version.outputs.new_version }}
120+
delete-branch: true
121+
reviewers: |
122+
brendan-kellam
123+
msukkari
124+
labels: |
125+
release

.github/workflows/update-sourcebot-version.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,27 @@ jobs:
8181
8282
echo "chart_version=$NEW_CHART_VERSION" >> $GITHUB_OUTPUT
8383
84+
- name: Update CHANGELOG.md
85+
if: steps.version-check.outputs.needs_update == 'true'
86+
run: |
87+
LATEST_VERSION=${{ steps.latest-version.outputs.latest }}
88+
CHART_VERSION=${{ steps.update-chart.outputs.chart_version }}
89+
DATE=$(date +%Y-%m-%d)
90+
91+
# Add the bump entry under [Unreleased]
92+
sed -i "/## \[Unreleased\]/a\\
93+
\\
94+
### Changed\\
95+
- Bumped Sourcebot to $LATEST_VERSION. [Release notes](https://github.com/sourcebot-dev/sourcebot/releases/tag/$LATEST_VERSION)" CHANGELOG.md
96+
97+
# Finalize [Unreleased] into a dated version header
98+
sed -i "/## \[Unreleased\]/a\\
99+
\\
100+
## [$CHART_VERSION] - $DATE" CHANGELOG.md
101+
102+
echo "Updated CHANGELOG.md"
103+
cat CHANGELOG.md | head -n 20
104+
84105
- name: Install helm-docs
85106
if: steps.version-check.outputs.needs_update == 'true'
86107
run: |

0 commit comments

Comments
 (0)