Skip to content

Commit 19cb805

Browse files
authored
Automate release process (#269)
* Automatically publish Docker image on all pushes to main and tags, and create GitHub release on tags * Update docs * Make Zizmor happy: don't use the cache for release builds * Fix more Zizmor warnings
1 parent 0123692 commit 19cb805

File tree

2 files changed

+62
-14
lines changed

2 files changed

+62
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: ci
22
on:
33
push:
4-
branches: [main]
4+
branches: [ main ]
5+
tags: [ '*' ]
56
pull_request:
67

78
permissions:
@@ -18,6 +19,7 @@ jobs:
1819
with:
1920
go-version: '1.25'
2021
check-latest: true
22+
cache: ${{ github.event_name != 'push' }} # zizmor: ignore[cache-poisoning] Zizmor doesn't understand that this disables caching for release builds
2123
- run: make rollout-operator
2224

2325
test:
@@ -30,6 +32,7 @@ jobs:
3032
with:
3133
go-version: '1.25'
3234
check-latest: true
35+
cache: ${{ github.event_name != 'push' }} # zizmor: ignore[cache-poisoning] Zizmor doesn't understand that this disables caching for release builds
3336
- run: make test
3437
- run: make test-boringcrypto
3538

@@ -43,6 +46,7 @@ jobs:
4346
with:
4447
go-version: '1.25'
4548
check-latest: true
49+
cache: ${{ github.event_name != 'push' }} # zizmor: ignore[cache-poisoning] Zizmor doesn't understand that this disables caching for release builds
4650
- run: make build-image
4751
- run: make integration
4852

@@ -56,6 +60,7 @@ jobs:
5660
with:
5761
go-version: '1.25'
5862
check-latest: true
63+
cache: ${{ github.event_name != 'push' }} # zizmor: ignore[cache-poisoning] Zizmor doesn't understand that this disables caching for release builds
5964
- run: make build-image-boringcrypto
6065
- run: make integration
6166

@@ -69,7 +74,53 @@ jobs:
6974
with:
7075
go-version: '1.25'
7176
check-latest: true
77+
cache: ${{ github.event_name != 'push' }} # zizmor: ignore[cache-poisoning] Zizmor doesn't understand that this disables caching for release builds
7278
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
7379
with:
7480
version: v2.4.0
7581
args: --timeout=5m
82+
83+
push-image:
84+
runs-on: ubuntu-latest
85+
needs:
86+
- build
87+
- test
88+
- integration
89+
- integration-boringcrypto
90+
- lint
91+
if: github.event_name == 'push' # We want this job to run for both pushes to main, as well as new tags.
92+
permissions:
93+
contents: write # Needed to be able to create releases.
94+
id-token: write
95+
steps:
96+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
97+
with:
98+
persist-credentials: false
99+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
100+
with:
101+
go-version: '1.25'
102+
check-latest: true
103+
cache: false
104+
- name: Log in to Docker Hub
105+
uses: grafana/shared-workflows/actions/dockerhub-login@c6d954f7cd9c0022018982e01268de6cb75b913c # dockerhub-login/v1.0.2
106+
- name: Generate image tag
107+
id: image_tag
108+
run: |
109+
if [[ "$REF_TYPE" == "tag" ]]; then
110+
echo "tag=$REF_NAME" >> "$GITHUB_OUTPUT"
111+
else
112+
echo "tag=main-$SHA" >> "$GITHUB_OUTPUT"
113+
fi
114+
env:
115+
REF_TYPE: ${{ github.ref_type }}
116+
REF_NAME: ${{ github.ref_name }}
117+
SHA: ${{ github.sha }}
118+
- name: Build and push image
119+
run: make publish-images
120+
env:
121+
IMAGE_TAG: ${{ steps.image_tag.outputs.tag }}
122+
- name: Publish release
123+
if: github.ref_type == 'tag'
124+
run: make release-notes | gh release create "$IMAGE_TAG" --notes-file -
125+
env:
126+
IMAGE_TAG: ${{ steps.image_tag.outputs.tag }}

RELEASE.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# How to release a new version
22

3-
1. Update `CHANGELOG.md`
4-
- Open PR and get it merged
3+
1. Update `CHANGELOG.md` as required:
4+
- Open a PR and get it merged
5+
56
2. Create a new tag that follows semantic versioning:
67
```bash
78
$ tag=v0.1.0
89
$ git tag -s "${tag}" -m "${tag}"
910
$ git push origin "${tag}"
1011
```
11-
3. Publish the updated Docker image
12-
```bash
13-
$ IMAGE_TAG="${tag}" make publish-images
14-
```
15-
4. Create a new GitHub release [here](https://github.com/grafana/rollout-operator/releases/new) based on the tag. The release notes can be generated with:
16-
```bash
17-
$ IMAGE_TAG="${tag}" make release-notes
18-
```
19-
5. Update the Helm Chart
20-
- Repository https://github.com/grafana/helm-charts/tree/main/charts/rollout-operator
21-
- [Example PR](https://github.com/grafana/helm-charts/pull/3177/files)
12+
13+
3. The [CI workflow](.github/workflows/ci.yaml) will run automatically.
14+
It will build and push the image to [Docker Hub](https://hub.docker.com/r/grafana/rollout-operator), and create a [GitHub release](https://github.com/grafana/rollout-operator/releases) with release notes.
15+
16+
4. Update the Helm Chart:
17+
- Repository https://github.com/grafana/helm-charts/tree/main/charts/rollout-operator
18+
- [Example PR](https://github.com/grafana/helm-charts/pull/3177/files)

0 commit comments

Comments
 (0)