Skip to content

Commit 9ead01a

Browse files
committed
feat: add automatic tag creation on chart PR merge
- Add auto-tag-on-merge.yaml workflow to automatically create release tags - Updates documentation to reflect full automation of chart releases - Fixes helm-release.yaml to force-add packages despite .gitignore This ensures the charts repository is fully automated with no manual intervention required.
1 parent 7358e0e commit 9ead01a

2 files changed

Lines changed: 117 additions & 3 deletions

File tree

.github/workflows/README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@ This is a multi-chart repository that can host multiple Helm charts. The structu
2727

2828
## Workflows
2929

30-
### 1. Release Helm Chart (`helm-release.yaml`)
30+
### 1. Auto Tag on Merge (`auto-tag-on-merge.yaml`)
31+
32+
**Trigger**: When a PR with `chart-update` label is merged
33+
34+
**Purpose**: Automatically creates release tags for chart updates
35+
36+
**Features**:
37+
- Detects chart name and version from PR branch name (format: `update-<chart>-<version>`)
38+
- Creates appropriate git tag (format: `<chart>-v<version>`)
39+
- Posts confirmation comment on the merged PR
40+
- Triggers the helm-release workflow automatically
41+
42+
**Note**: This workflow ensures the charts repository is fully automated - no manual tagging required!
43+
44+
### 2. Release Helm Chart (`helm-release.yaml`)
3145

3246
**Trigger**:
3347
- Git tags matching `chartname-v*.*.*` pattern (e.g., `vault-transit-unseal-operator-v0.1.0`)
@@ -146,7 +160,18 @@ Enable the following:
146160

147161
## Releasing a Chart
148162

149-
### Automatic Release (Recommended)
163+
### Fully Automated Release (via External PR)
164+
165+
When a PR is created by external automation (e.g., from operator releases) with the `chart-update` label:
166+
167+
1. The PR is automatically tested via `helm-test.yaml`
168+
2. Once merged, `auto-tag-on-merge.yaml` automatically:
169+
- Creates the appropriate release tag
170+
- Triggers `helm-release.yaml` to publish the chart
171+
172+
No manual intervention required!
173+
174+
### Manual Release
150175

151176
1. Update the chart version in `Chart.yaml`:
152177
```yaml
@@ -173,7 +198,7 @@ Enable the following:
173198
- Update the repository index
174199
- Create a GitHub release
175200

176-
### Manual Release
201+
### Manual Release via Workflow Dispatch
177202

178203
Use the workflow dispatch feature:
179204

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Auto Tag Chart Release on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
auto-tag:
10+
name: Create Chart Release Tag
11+
if: |
12+
github.event.pull_request.merged == true &&
13+
contains(github.event.pull_request.labels.*.name, 'chart-update')
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Extract chart info from PR
23+
id: extract
24+
run: |
25+
PR_TITLE="${{ github.event.pull_request.title }}"
26+
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
27+
28+
# Extract chart name and version from branch name
29+
# Format: update-vault-transit-unseal-operator-1.0.5
30+
if [[ "$PR_BRANCH" =~ ^update-([a-zA-Z0-9-]+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
31+
CHART_NAME="${BASH_REMATCH[1]}"
32+
APP_VERSION="${BASH_REMATCH[2]}"
33+
echo "chart_name=$CHART_NAME" >> $GITHUB_OUTPUT
34+
echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
35+
36+
# Get the chart version from Chart.yaml
37+
CHART_VERSION=$(yq '.version' "./charts/$CHART_NAME/Chart.yaml")
38+
echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT
39+
40+
echo "Chart: $CHART_NAME"
41+
echo "Chart Version: $CHART_VERSION"
42+
echo "App Version: $APP_VERSION"
43+
else
44+
echo "ERROR: Could not parse chart info from PR branch: $PR_BRANCH"
45+
exit 1
46+
fi
47+
48+
- name: Create and push tag
49+
run: |
50+
git config --global user.name "github-actions[bot]"
51+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
52+
53+
TAG_NAME="${{ steps.extract.outputs.chart_name }}-v${{ steps.extract.outputs.chart_version }}"
54+
55+
# Check if tag already exists
56+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
57+
echo "Tag $TAG_NAME already exists, skipping..."
58+
exit 0
59+
fi
60+
61+
# Create and push tag
62+
git tag -a "$TAG_NAME" -m "Release ${{ steps.extract.outputs.chart_name }} v${{ steps.extract.outputs.chart_version }}
63+
64+
Chart version: ${{ steps.extract.outputs.chart_version }}
65+
App version: ${{ steps.extract.outputs.app_version }}
66+
67+
Automated release from PR #${{ github.event.pull_request.number }}"
68+
69+
git push origin "$TAG_NAME"
70+
71+
echo "✅ Created tag: $TAG_NAME"
72+
73+
- name: Comment on PR
74+
if: success()
75+
uses: peter-evans/create-or-update-comment@v4
76+
with:
77+
issue-number: ${{ github.event.pull_request.number }}
78+
body: |
79+
🎉 **Chart Release Tag Created!**
80+
81+
Tag: `${{ steps.extract.outputs.chart_name }}-v${{ steps.extract.outputs.chart_version }}`
82+
83+
The Helm chart release workflow will now automatically:
84+
- Package the chart
85+
- Update the repository index
86+
- Create a GitHub release
87+
- Publish to https://fredericrous.github.io/charts/
88+
89+
Monitor progress: [Release Workflow](https://github.com/fredericrous/charts/actions/workflows/helm-release.yaml)

0 commit comments

Comments
 (0)