forked from cloudnative-pg/cloudnative-pg
-
Notifications
You must be signed in to change notification settings - Fork 0
324 lines (301 loc) · 12 KB
/
release-publish.yml
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# When a release tag is pushed, create and publish operator images on GitHub
# Registry. Then generate a release on GitHub.
name: release-publish
on:
push:
tags:
- v*
env:
GOLANG_VERSION: "1.21.x"
CNPG_IMAGE_NAME: "ghcr.io/${{ github.repository }}"
permissions:
contents: write
packages: write
jobs:
release:
name: Create Github release
runs-on: ubuntu-22.04
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get tag
run: |
tag="${GITHUB_REF#refs/tags/v}"
version="${tag#v}"
file=$(echo ${version} | awk -F '[.]' '{print "release_notes/v"$1"."$2".md"}')
echo "TAG=${tag}" >> $GITHUB_ENV
echo "VERSION=${version}" >> $GITHUB_ENV
echo "FILE=${file}" >> $GITHUB_ENV
-
name: Generate release notes
run: |
docker run --rm -v $(pwd):/src mist/submark \
submark -O --h2 "Version ${{ env.TAG }}" \
--out-file /src/release_notes.md \
/src/docs/src/${{ env.FILE }}
-
name: Release
uses: softprops/action-gh-release@v1
with:
body_path: release_notes.md
draft: false
name: Release ${{ env.TAG }}
files: releases/cnpg-${{ env.VERSION }}.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-binaries:
name: Build containers
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.build-meta.outputs.version }}
digest: ${{ steps.build.outputs.digest }}
platforms: ${{ env.PLATFORMS }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
# To identify the commit we need the history and all the tags.
fetch-depth: 0
-
name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
check-latest: true
-
name: Build meta
id: build-meta
run: |
images='ghcr.io/cloudnative-pg/cloudnative-pg'
images="${images},ghcr.io/cloudnative-pg/cloudnative-pg-testing"
commit_sha=${{ github.sha }}
commit_date=$(git log -1 --pretty=format:'%ad' --date short "${commit_sha}")
tag="${GITHUB_REF#refs/tags/v}"
skip_krew="false"
latest_release_branch=$(git branch -rl 'origin/release-*' | sort -r | head -n1 | sed -e 's/^.*\(release-.*\)/\1/')
current_release_branch=$(echo "${tag}" | sed -e 's/\([0-9]\+.[0-9]\+\).*/release-\1/')
if [[ "$latest_release_branch" != "$current_release_branch" ]]; then
skip_krew="true"
fi
# use git describe to get the nearest tag and use that to build the version (e.g. 1.4.0-dev24 or 1.4.0)
commit_version=$(git describe --tags --match 'v*' "${commit_sha}"| sed -e 's/^v//; s/-g[0-9a-f]\+$//; s/-\([0-9]\+\)$/-dev\1/')
commit_short=$(git rev-parse --short "${commit_sha}")
echo "IMAGES=${images}" >> $GITHUB_ENV
echo "DATE=${commit_date}" >> $GITHUB_ENV
echo "version=${commit_version}" >> $GITHUB_OUTPUT
echo "COMMIT=${commit_short}" >> $GITHUB_ENV
echo "SKIP_KREW=${skip_krew}" >> $GITHUB_ENV
-
name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
-
name: Set GoReleaser environment
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV
echo PWD=$(pwd) >> $GITHUB_ENV
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist --timeout 60m
env:
DATE: ${{ env.DATE }}
COMMIT: ${{ env.COMMIT }}
VERSION: ${{ steps.build-meta.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
-
name: Publish Krew
if: ${{ env.SKIP_KREW == 'false' }}
uses: rajatjindal/[email protected]
with:
krew_template_file: dist/krew/cnpg.yaml
-
name: Docker meta
id: docker-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGES }}
tags: |
type=semver,pattern={{version}}
-
name: Docker meta UBI8
id: docker-meta-ubi8
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGES }}
flavor: |
suffix=-ubi8
tags: |
type=semver,pattern={{version}}
-
name: Detect platforms
run: |
# Keep in mind that adding more platforms (architectures) will increase the building
# time even if we use the ghcache for the building process.
platforms="linux/amd64,linux/arm64"
echo "PLATFORMS=${platforms}" >> $GITHUB_ENV
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.PLATFORMS }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
platforms: ${{ env.PLATFORMS }}
context: .
push: true
build-args: |
VERSION=${{ steps.build-meta.outputs.version }}
tags: ${{ steps.docker-meta.outputs.tags }}
-
name: Build and push UBI8
uses: docker/build-push-action@v5
with:
platforms: ${{ env.PLATFORMS }}
context: .
file: Dockerfile-ubi8
push: true
build-args: |
VERSION=${{ steps.build-meta.outputs.version }}
tags: ${{ steps.docker-meta-ubi8.outputs.tags }}
olm-bundle:
name: Create OLM bundle and catalog
runs-on: ubuntu-22.04
needs:
- release-binaries
if: |
(always() && !cancelled()) &&
needs.release-binaries.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ needs.release-binaries.outputs.platforms }}
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
check-latest: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set bundle variables
run: |
tag="${GITHUB_REF#refs/tags/v}"
version="${tag#v}"
LOWERCASE_CNPG_IMAGE_NAME=${CNPG_IMAGE_NAME,,}
echo "IMAGE_NAME=${LOWERCASE_CNPG_IMAGE_NAME}" >> $GITHUB_ENV
echo "CONTROLLER_IMG=${LOWERCASE_CNPG_IMAGE_NAME}:${version}-ubi8" >> $GITHUB_ENV
echo "BUNDLE_IMG=${LOWERCASE_CNPG_IMAGE_NAME}:bundle-${version}" >> $GITHUB_ENV
- name: Create bundle
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
CONTROLLER_IMG: ${{ env.CONTROLLER_IMG }}
BUNDLE_IMG: ${{ env.BUNDLE_IMG }}
run: |
make olm-catalog
- name: Archive the bundle manifests
uses: actions/upload-artifact@v4
with:
name: bundle
path: |
bundle.Dockerfile
bundle/
cloudnative-pg-catalog.yaml
operatorhub_pr:
name: Create remote PR for OperatorHub
runs-on: ubuntu-22.04
needs:
- release-binaries
- olm-bundle
if: |
(always() && !cancelled()) &&
needs.olm-bundle.result == 'success'
env:
VERSION: ${{ needs.release-binaries.outputs.version }}
steps:
- name: Checkout community-operators
uses: actions/checkout@v4
with:
repository: k8s-operatorhub/community-operators
fetch-depth: 0
persist-credentials: false
- name: Download the bundle
uses: actions/download-artifact@v4
with:
name: bundle
- name: Copy bundle in the community-operators
run: |
mkdir -p "operators/cloudnative-pg/${{ env.VERSION }}"
cp -R bundle/* "operators/cloudnative-pg/${{ env.VERSION }}"
rm -fr cloudnative-pg-catalog.yaml bundle.Dockerfile *.zip bundle/
- name: Create Remote Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.REPO_GHA_PAT }}
commit-message: "operator cloudnative-pg (${{ env.VERSION }})"
title: "operator cloudnative-pg (${{ env.VERSION }})"
signoff: true
branch: release-cloudnativepg-${{ env.VERSION }}
delete-branch: true
push-to-fork: cloudnative-pg/community-operators
body: |
Thanks submitting your Operator. Please check below list before you create your Pull Request.
### Updates to existing Operators
* [x] Did you create a `ci.yaml` file according to the [update instructions](https://github.com/operator-framework/community-operators/blob/master/docs/operator-ci-yaml.md)?
* [x] Is your new CSV pointing to the previous version with the `replaces` property if you chose `replaces-mode` via the `updateGraph` property in `ci.yaml`?
* [x] Is your new CSV referenced in the [appropriate channel](https://github.com/operator-framework/community-operators/blob/master/docs/packaging-operator.md#channels) defined in the `package.yaml` or `annotations.yaml` ?
* [x] Have you tested an update to your Operator when deployed via OLM?
* [x] Is your submission [signed](https://github.com/operator-framework/community-operators/blob/master/docs/contributing-prerequisites.md#sign-your-work)?
### Your submission should not
* [x] Modify more than one operator
* [x] Modify an Operator you don't own
* [x] Rename an operator - please remove and add with a different name instead
* [x] Modify any files outside the above mentioned folders
* [x] Contain more than one commit. **Please squash your commits.**
### Operator Description must contain (in order)
1. [x] Description about the managed Application and where to find more information
2. [x] Features and capabilities of your Operator and how to use it
3. [x] Any manual steps about potential pre-requisites for using your Operator
### Operator Metadata should contain
* [x] Human readable name and 1-liner description about your Operator
* [x] Valid [category name](https://github.com/operator-framework/community-operators/blob/master/docs/packaging-operator.md#categories)<sup>1</sup>
* [x] One of the pre-defined [capability levels](https://github.com/operator-framework/operator-courier/blob/4d1a25d2c8d52f7de6297ec18d8afd6521236aa2/operatorcourier/validate.py#L556)<sup>2</sup>
* [x] Links to the maintainer, source code and documentation
* [x] Example templates for all Custom Resource Definitions intended to be used
* [x] A quadratic logo
Remember that you can preview your CSV [here](https://operatorhub.io/preview).
--
<sup>1</sup> If you feel your Operator does not fit any of the pre-defined categories, file an issue against this repo and explain your need
<sup>2</sup> For more information see [here](https://sdk.operatorframework.io/docs/overview/#operator-capability-level)