Skip to content

Commit 784a806

Browse files
chris-rockclaude
andauthored
⭐️ Automate release process via GitHub Release (#1380)
* Automate release process via GitHub Release creation This adds a new workflow that triggers when a GitHub Release is created: - Updates version files (Chart.yaml, kustomization.yaml) - Regenerates Helm chart and manifests - Commits changes to main - Moves the tag to include version updates - Triggers existing publish workflow Also adds pre-release support: - Pre-releases (v1.2.3-alpha.1) don't update the "latest" Docker tag - Pre-releases aren't marked as the latest GitHub release Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: spelling issues in RELEASE.md - Replace 'Click' with 'Select' to avoid spellcheck flag - Add 'kustomization' to spelling expect list Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7a106fb commit 784a806

5 files changed

Lines changed: 149 additions & 26 deletions

File tree

.github/actions/spelling/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ eksctl
88
fullname
99
iamidentitymapping
1010
irsa
11+
kustomization
1112
mcr
1213
oidc
1314
openssl

.github/workflows/publish.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ jobs:
100100
type=ref,event=pr
101101
flavor: |
102102
suffix=-${{ matrix.arch }},onlatest=true
103+
# Only apply 'latest' for non-prerelease version tags (no hyphen after version)
104+
latest=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
103105
104106
# Extract metadata (tags, labels) for Docker
105107
# https://github.com/docker/metadata-action
@@ -217,6 +219,9 @@ jobs:
217219
type=ref,event=branch
218220
type=ref,event=tag
219221
type=ref,event=pr
222+
flavor: |
223+
# Only apply 'latest' for non-prerelease version tags (no hyphen after version)
224+
latest=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
220225
221226
- name: Push multi-platform virtual tag and sign
222227
run: bash scripts/push-virtual-tag.sh

.github/workflows/release-manifests.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ jobs:
3232
with:
3333
files: mondoo-operator-manifests.yaml
3434
generate_release_notes: false
35-
make_latest: true
35+
# Only mark as latest if not a pre-release version (no hyphen after version)
36+
make_latest: ${{ !contains(github.ref_name, '-') }}

.github/workflows/release.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright (c) Mondoo, Inc.
2+
# SPDX-License-Identifier: BUSL-1.1
3+
4+
name: Release
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
prepare-release:
12+
runs-on: ubuntu-latest
13+
# Only run for version tags
14+
if: startsWith(github.event.release.tag_name, 'v')
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Checkout main branch
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
with:
22+
ref: main
23+
fetch-depth: 0
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Import environment variables from file
27+
run: cat ".github/env" >> $GITHUB_ENV
28+
29+
- name: Setup Go
30+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
31+
with:
32+
go-version: "${{ env.golang-version }}"
33+
34+
- name: Install yq
35+
run: |
36+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
37+
sudo chmod +x /usr/local/bin/yq
38+
39+
- name: Extract version from tag
40+
id: version
41+
run: |
42+
TAG="${{ github.event.release.tag_name }}"
43+
VERSION="${TAG#v}"
44+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
45+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
46+
47+
- name: Update version files
48+
run: |
49+
VERSION="${{ steps.version.outputs.version }}"
50+
51+
# Update Chart.yaml
52+
yq -i ".version = \"${VERSION}\"" charts/mondoo-operator/Chart.yaml
53+
yq -i ".appVersion = \"${VERSION}\"" charts/mondoo-operator/Chart.yaml
54+
55+
# Update kustomization.yaml
56+
yq -i ".images[0].newTag = \"v${VERSION}\"" config/manager/kustomization.yaml
57+
58+
- name: Generate manifests and Helm chart
59+
run: |
60+
make manifests
61+
CHART_NAME=charts/mondoo-operator make helm
62+
63+
- name: Configure Git
64+
run: |
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
68+
- name: Commit version updates
69+
id: commit
70+
run: |
71+
VERSION="${{ steps.version.outputs.version }}"
72+
73+
git add -A
74+
if git diff --staged --quiet; then
75+
echo "No changes to commit"
76+
echo "changed=false" >> $GITHUB_OUTPUT
77+
else
78+
git commit -m "🚀 Release v${VERSION}"
79+
git push origin main
80+
echo "changed=true" >> $GITHUB_OUTPUT
81+
fi
82+
83+
- name: Move tag to include version updates
84+
if: steps.commit.outputs.changed == 'true'
85+
run: |
86+
TAG="${{ steps.version.outputs.tag }}"
87+
88+
# Delete the old tag (local and remote)
89+
git tag -d "${TAG}" || true
90+
git push origin ":refs/tags/${TAG}" || true
91+
92+
# Create new tag at current HEAD (which includes version updates)
93+
git tag "${TAG}"
94+
git push origin "${TAG}"

RELEASE.md

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,65 @@
11
# Operator Release
22

3-
This document describes the release process for the operator
3+
## Automated Release Process
44

5-
## Versioning
5+
Releases are fully automated via GitHub Actions.
66

7-
Always consider what is the suitable version number to be released based on the [Operator upgrade manual](docs/operator-upgrades.md).
7+
### To Release a New Version:
88

9-
## Release script
9+
1. Go to the repository's **Releases** page
10+
2. Select **Draft a new release**
11+
3. Select **Choose a tag** and type the new version (e.g., `v12.1.0`)
12+
4. Select **Create new tag: v12.1.0 on publish**
13+
5. Set the release title (e.g., `v12.1.0`)
14+
6. Optionally add release notes describing the changes
15+
7. Select **Publish release**
1016

11-
The `release.sh` script will generate/update the Helm chart files.
17+
The release workflow will automatically:
18+
- Update version in Chart.yaml and kustomization.yaml
19+
- Regenerate Helm chart and manifests
20+
- Commit changes to main
21+
- Move the tag to include version updates
22+
- Trigger container image builds (multi-arch)
23+
- Publish Helm chart to GitHub Pages and OCI registry
24+
- Update the GitHub release with manifest files
1225

13-
Ensure the following software is installed before running the release script:
26+
### Versioning
1427

15-
- `yq`
16-
- `operator-sdk`
28+
Follow [semantic versioning](https://semver.org/):
29+
- **Patch** (12.0.X): Bug fixes, no breaking changes
30+
- **Minor** (12.X.0): New features, backwards compatible
31+
- **Major** (X.0.0): Breaking changes (see [upgrade docs](docs/operator-upgrades.md))
1732

18-
Run the release script:
33+
### Pre-Releases
1934

20-
1. Run the `release.sh` script from the root of the mondoo-operator repo with the previous version of the operator as the first parameter and the new version of the operator as the second parameter (without any leading 'v' in the version string). For example:
35+
For alpha, beta, or release candidate versions:
2136

22-
```bash
23-
$ ./release.sh 1.4.0 1.4.1
24-
```
37+
1. Follow the same release process above
38+
2. Use semver pre-release format: `v12.1.0-alpha.1`, `v12.1.0-rc.1`
39+
3. **Check the "Set as a pre-release" checkbox** in GitHub Release UI
2540

26-
### Helm Chart and Operator bundle
41+
Pre-releases will:
42+
- Build and publish container images (tagged with the pre-release version)
43+
- Publish Helm chart (with pre-release version)
44+
- **NOT** update the "latest" Docker tag
45+
- **NOT** be marked as the latest GitHub release
2746

28-
Mondoo Operator helm chart has been auto-generated using the [helmify](https://github.com/arttor/helmify) tool via the `release.sh` script. The CI uses [chart-releaser-action](https://github.com/helm/chart-releaser-action) to self host the charts using GitHub pages.
47+
Users can deploy a specific pre-release by specifying the version explicitly.
2948

30-
The following steps need to be followed to release Helm chart.
49+
### Manual Release (Emergency)
3150

32-
#### Helm Chart Release Workflow
51+
If the automated workflow fails, you can release manually:
3352

34-
Helm chart release action is executed against release tags. It checks each chart in the charts folder, and whenever there's a new chart version, creates a corresponding GitHub release named for the chart version, adds Helm chart artifacts to the release, and creates or updates an index.yaml file with metadata about those releases, which is then hosted on GitHub Pages.
53+
1. Run the release script:
54+
```bash
55+
./release.sh <previous_version> <new_version>
56+
```
3557

36-
### Committing the release
58+
2. Create a PR with the changes
3759

38-
After running the `release.sh` script, you can create a pull request containing the changes made to the repo (mainly the files under ./charts and ./config. Once the pull request has merged, you need to tag the release.
39-
40-
1. git checkout main
41-
2. git pull
42-
3. git tag v1.4.1
43-
4. git push origin v1.4.1
60+
3. After merge, tag and push:
61+
```bash
62+
git checkout main && git pull
63+
git tag v<new_version>
64+
git push origin v<new_version>
65+
```

0 commit comments

Comments
 (0)