Skip to content

Commit 41261fc

Browse files
authored
Integrate goreleaser to produce draft releases when new tags are pushed (#2365)
* Makefile: Avoid hardcoding the quay repository in the release target Update the release target and avoid hardcoding the quay.io/operator-framework/olm quay repository and instead use the existing IMAGE_REPO variable defined further up in the Makefile. Update how the $(ver) variable is handled and avoid hardcoding the 'v' prefix when overriding that 'ver' variable in the environment. Signed-off-by: timflannagan <[email protected]> * Integrate goreleaser to automate the building and publishing of multi-arch container images Signed-off-by: timflannagan <[email protected]> * .github/workflows: Add a release workflow for creating draft releases Add a GHA release workflow that's triggered on tags that's responsible for building and pushing multi-arch (i.e. manifestlist) OLM container images using goreleaser. Goreleaser will also create a draft release, and generate a changelog since the previous tag. Rendering the release quickstart manifests is done after goreleaser has created this draft release as there's no easy way to hook this functionality into goreleaser after the docker images/manifestlists have been pushed but before release artifacts are generated. Use the 'softprops/action-gh-release' to update the newly created draft release with these quickstart manifests as assets. Signed-off-by: timflannagan <[email protected]> * .goreleaser: Add support for ppc64le and s390x architectures * .github/workflows: Avoid using the latest goreleaser action version
1 parent 33606c9 commit 41261fc

File tree

5 files changed

+226
-3
lines changed

5 files changed

+226
-3
lines changed

.github/workflows/goreleaser.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: release
2+
on:
3+
pull_request:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.16
20+
21+
- name: Get the image tag
22+
if: startsWith(github.ref, 'refs/tags')
23+
run: |
24+
# Source: https://github.community/t/how-to-get-just-the-tag-name/16241/32
25+
if [[ $GITHUB_REF == refs/tags/* ]]; then
26+
echo IMAGE_TAG="${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
27+
fi
28+
29+
- name: Create a draft release
30+
uses: actions/create-release@v1
31+
id: release
32+
if: startsWith(github.ref, 'refs/tags')
33+
env:
34+
GITHUB_TOKEN: ${{ github.token }}
35+
with:
36+
draft: true
37+
tag_name: ${{ github.ref }}
38+
release_name: ${{ github.ref }}
39+
40+
- name: Docker Login
41+
uses: docker/login-action@v1
42+
if: startsWith(github.ref, 'refs/tags')
43+
with:
44+
registry: quay.io
45+
username: ${{ secrets.QUAY_USERNAME }}
46+
password: ${{ secrets.QUAY_PASSWORD }}
47+
48+
- name: Run GoReleaser
49+
uses: goreleaser/goreleaser-action@v2
50+
if: startsWith(github.ref, 'refs/tags')
51+
with:
52+
version: 0.177.0
53+
args: release --rm-dist
54+
env:
55+
GITHUB_TOKEN: ${{ github.token }}
56+
IMAGE_REPO: ${{ secrets.QUAY_USERNAME }}/olm
57+
PKG: github.com/operator-framework/operator-lifecycle-manager
58+
59+
- name: Generate quickstart release manifests
60+
if: startsWith(github.ref, 'refs/tags')
61+
run: make release ver=${{ env.IMAGE_TAG }} IMAGE_REPO=quay.io/${{ secrets.QUAY_USERNAME }}/olm
62+
63+
- name: Update release artifacts with rendered Kubernetes manifests
64+
uses: softprops/action-gh-release@v1
65+
if: startsWith(github.ref, 'refs/tags')
66+
with:
67+
name: ${{ env.IMAGE_TAG }}
68+
files: |
69+
deploy/upstream/quickstart/crds.yaml
70+
deploy/upstream/quickstart/olm.yaml
71+
deploy/upstream/quickstart/install.sh
72+
draft: true
73+
token: ${{ github.token }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,5 @@ apiserver.key
455455

456456
!vendor/**
457457
test/e2e-local.image.tar
458+
459+
dist/

.goreleaser.yml

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
env:
2+
- GO111MODULE=on
3+
- CGO_ENABLED=0
4+
before:
5+
hooks:
6+
- go mod tidy
7+
- go mod vendor
8+
builds:
9+
- id: olm
10+
main: ./cmd/olm
11+
binary: olm
12+
goos:
13+
- linux
14+
goarch:
15+
- amd64
16+
- arm64
17+
- ppc64le
18+
- s390x
19+
tags:
20+
- json1
21+
flags:
22+
- -mod=vendor
23+
ldflags:
24+
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
25+
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
26+
- id: catalog
27+
main: ./cmd/catalog
28+
binary: catalog
29+
goos:
30+
- linux
31+
goarch:
32+
- amd64
33+
- arm64
34+
- ppc64le
35+
- s390x
36+
tags:
37+
- json1
38+
flags:
39+
- -mod=vendor
40+
ldflags:
41+
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
42+
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
43+
- id: cpb
44+
main: ./util/cpb
45+
binary: cpb
46+
goos:
47+
- linux
48+
goarch:
49+
- amd64
50+
- arm64
51+
- ppc64le
52+
- s390x
53+
tags:
54+
- json1
55+
flags:
56+
- -mod=vendor
57+
ldflags:
58+
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
59+
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
60+
- id: package-server
61+
main: ./cmd/package-server
62+
binary: package-server
63+
goos:
64+
- linux
65+
goarch:
66+
- amd64
67+
- arm64
68+
- ppc64le
69+
- s390x
70+
tags:
71+
- json1
72+
flags:
73+
- -mod=vendor
74+
ldflags:
75+
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
76+
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
77+
dockers:
78+
- image_templates:
79+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-amd64
80+
dockerfile: Dockerfile.goreleaser
81+
use: buildx
82+
goos: linux
83+
goarch: amd64
84+
build_flag_templates:
85+
- --platform=linux/amd64
86+
- image_templates:
87+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-arm64
88+
dockerfile: Dockerfile.goreleaser
89+
use: buildx
90+
goos: linux
91+
goarch: arm64
92+
build_flag_templates:
93+
- --platform=linux/arm64
94+
- image_templates:
95+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-ppc64le
96+
dockerfile: Dockerfile.goreleaser
97+
use: buildx
98+
goos: linux
99+
goarch: ppc64le
100+
build_flag_templates:
101+
- --platform=linux/ppc64le
102+
- image_templates:
103+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-s390x
104+
dockerfile: Dockerfile.goreleaser
105+
use: buildx
106+
goos: linux
107+
goarch: s390x
108+
build_flag_templates:
109+
- --platform=linux/s390x
110+
docker_manifests:
111+
- name_template: quay.io/{{ .Env.IMAGE_REPO }}:v{{ .Major }}.{{ .Minor }}
112+
image_templates:
113+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-amd64
114+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-arm64
115+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-ppc64le
116+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-s390x
117+
- name_template: quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}
118+
image_templates:
119+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-amd64
120+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-arm64
121+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-ppc64le
122+
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-s390x
123+
checksum:
124+
name_template: 'checksums.txt'
125+
snapshot:
126+
name_template: "{{ .Tag }}"
127+
changelog:
128+
sort: asc
129+
filters:
130+
exclude:
131+
- '^doc:'
132+
- '^test:'
133+
release:
134+
draft: true

Dockerfile.goreleaser

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM --platform=$BUILDPLATFORM gcr.io/distroless/static:debug
2+
LABEL stage=olm
3+
WORKDIR /
4+
# bundle unpack Jobs require cp at /bin/cp
5+
RUN ["/busybox/ln", "-s", "/busybox/cp", "/bin/cp"]
6+
# copy goreleaser built binaries
7+
COPY olm /bin/olm
8+
COPY catalog /bin/catalog
9+
COPY package-server /bin/package-server
10+
COPY cpb /bin/cpb
11+
EXPOSE 8080
12+
EXPOSE 5443
13+
ENTRYPOINT ["/bin/olm"]

Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,16 @@ verify: verify-codegen verify-mockgen verify-manifests
217217

218218
# before running release, bump the version in OLM_VERSION and push to master,
219219
# then tag those builds in quay with the version in OLM_VERSION
220-
release: ver=$(shell cat OLM_VERSION)
220+
release: ver=v$(shell cat OLM_VERSION)
221221
release: manifests
222-
docker pull quay.io/operator-framework/olm:v$(ver)
222+
@echo "Generating the $(ver) release"
223+
docker pull $(IMAGE_REPO):$(ver)
223224
$(MAKE) target=upstream ver=$(ver) quickstart=true package
224225

225226
verify-release: release
226227
$(MAKE) diff
227228

228-
package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' quay.io/operator-framework/olm:v$(ver))
229+
package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' $(IMAGE_REPO):$(ver))
229230
package:
230231
ifndef target
231232
$(error target is undefined)

0 commit comments

Comments
 (0)