-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (148 loc) · 5.62 KB
/
Copy pathrelease.yml
File metadata and controls
171 lines (148 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Release
# Builds and publishes the operator container image and the Helm chart to
# GitHub Container Registry (GHCR / GitHub Packages), and creates the matching
# GitHub Release.
#
# * push tag v* -> tagged release: image + chart + GitHub Release.
# * workflow_dispatch -> manual build/publish of image + chart (no GitHub Release).
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version to release (without the leading v)"
required: true
default: "0.1.2"
concurrency:
group: release-${{ github.ref }}
# Don't cancel an in-flight tag release; it produces an immutable artifact.
cancel-in-progress: false
permissions:
contents: write # needed by softprops/action-gh-release on tag pushes
packages: write # needed to push images and charts to GHCR
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/hyperbytedb-operator
CHART_OCI_REPO: oci://ghcr.io/${{ github.repository_owner }}/charts
jobs:
versions:
name: Compute versions
runs-on: hyperbytedb-operator-controller
outputs:
chart_version: ${{ steps.compute.outputs.chart_version }}
image_tag: ${{ steps.compute.outputs.image_tag }}
is_release: ${{ steps.compute.outputs.is_release }}
steps:
- name: Compute versions
id: compute
run: |
set -eu
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG="${{ github.ref_name }}" # e.g. v0.1.2
CHART_VERSION="${TAG#v}" # 0.1.2 (chart/app versions are semver, no leading v)
IMAGE_TAG="$CHART_VERSION" # 0.1.2
else
CHART_VERSION="${{ inputs.version }}"
IMAGE_TAG="${{ inputs.version }}"
fi
echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT"
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
echo "is_release=true" >> "$GITHUB_OUTPUT"
image:
name: Build & push operator image
needs: versions
runs-on: hyperbytedb-operator-controller
steps:
- uses: actions/checkout@v4
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push image
env:
IMAGE_TAG: ${{ needs.versions.outputs.image_tag }}
IS_RELEASE: ${{ needs.versions.outputs.is_release }}
run: |
set -eu
IMAGE="${REGISTRY}/${IMAGE_NAME}"
docker build -t "${IMAGE}:${IMAGE_TAG}" .
docker push "${IMAGE}:${IMAGE_TAG}"
if [ "$IS_RELEASE" = "true" ]; then
docker tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
docker push "${IMAGE}:latest"
fi
chart:
name: Package & push helm chart
needs: [versions, image]
runs-on: hyperbytedb-operator-controller
steps:
- uses: actions/checkout@v4
- name: Install CI dependencies
uses: ./.github/actions/install-ci-deps
with:
profile: k8s-runner
install_helm: "true"
install_yq: "true"
- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login "$REGISTRY" -u "${{ github.actor }}" --password-stdin
- name: Stamp default image tag in values.yaml
env:
IMAGE_TAG: ${{ needs.versions.outputs.image_tag }}
run: |
# Ensure the published chart's default image tag matches the image we
# just pushed. Users can still override with --set manager.image.tag.
yq -i '.manager.image.tag = strenv(IMAGE_TAG)' dist/chart/values.yaml
echo "--- Stamped values.yaml ---"
yq '.manager.image' dist/chart/values.yaml
- name: Lint chart
run: helm lint dist/chart
- name: Render chart (sanity check)
run: helm template hyperbytedb-operator dist/chart > /tmp/rendered.yaml
- name: Package chart
env:
CHART_VERSION: ${{ needs.versions.outputs.chart_version }}
run: |
helm package dist/chart \
--version "$CHART_VERSION" \
--app-version "$CHART_VERSION" \
--destination .
- name: Push chart to GHCR
run: helm push hyperbytedb-operator-*.tgz "$CHART_OCI_REPO"
- name: Upload chart artifact
uses: actions/upload-artifact@v4
with:
name: hyperbytedb-operator-chart
path: hyperbytedb-operator-*.tgz
if-no-files-found: error
retention-days: 30
release:
name: GitHub Release
needs: [versions, chart]
if: github.ref_type == 'tag'
runs-on: hyperbytedb-operator-controller
steps:
- uses: actions/download-artifact@v4
with:
name: hyperbytedb-operator-chart
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
generate_release_notes: true
files: hyperbytedb-operator-*.tgz
body: |
## Install
```sh
helm install hyperbytedb-operator \
oci://ghcr.io/${{ github.repository_owner }}/charts/hyperbytedb-operator \
--version ${{ needs.versions.outputs.chart_version }} \
--namespace hyperbytedb-operator-system \
--create-namespace
```
## Images
- `ghcr.io/${{ github.repository_owner }}/hyperbytedb-operator:${{ needs.versions.outputs.image_tag }}`
- `ghcr.io/${{ github.repository_owner }}/hyperbytedb-operator:latest`