Skip to content

Integrate goreleaser to produce draft releases when new tags are pushed #2365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: release
on:
pull_request:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Get the image tag
if: startsWith(github.ref, 'refs/tags')
run: |
# Source: https://i.8713187.xyzmunity/t/how-to-get-just-the-tag-name/16241/32
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo IMAGE_TAG="${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi

- name: Create a draft release
uses: actions/create-release@v1
id: release
if: startsWith(github.ref, 'refs/tags')
env:
GITHUB_TOKEN: ${{ github.token }}
with:
draft: true
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}

- name: Docker Login
uses: docker/login-action@v1
if: startsWith(github.ref, 'refs/tags')
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags')
with:
version: 0.177.0
args: release --rm-dist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to add the --snapshot flag anytime we're not pushing images.

FYI - opm also pushes a master image on every push to master for folks that want to live on the edge :) It can be nice to have that, but definitely non-blocking.

env:
GITHUB_TOKEN: ${{ github.token }}
IMAGE_REPO: ${{ secrets.QUAY_USERNAME }}/olm
PKG: github.com/operator-framework/operator-lifecycle-manager

- name: Generate quickstart release manifests
if: startsWith(github.ref, 'refs/tags')
run: make release ver=${{ env.IMAGE_TAG }} IMAGE_REPO=quay.io/${{ secrets.QUAY_USERNAME }}/olm

- name: Update release artifacts with rendered Kubernetes manifests
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags')
with:
name: ${{ env.IMAGE_TAG }}
files: |
deploy/upstream/quickstart/crds.yaml
deploy/upstream/quickstart/olm.yaml
deploy/upstream/quickstart/install.sh
draft: true
token: ${{ github.token }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,5 @@ apiserver.key

!vendor/**
test/e2e-local.image.tar

dist/
134 changes: 134 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
env:
- GO111MODULE=on
- CGO_ENABLED=0
before:
hooks:
- go mod tidy
- go mod vendor
builds:
- id: olm
main: ./cmd/olm
binary: olm
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
tags:
- json1
flags:
- -mod=vendor
ldflags:
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
- id: catalog
main: ./cmd/catalog
binary: catalog
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
tags:
- json1
flags:
- -mod=vendor
ldflags:
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
- id: cpb
main: ./util/cpb
binary: cpb
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
tags:
- json1
flags:
- -mod=vendor
ldflags:
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
- id: package-server
main: ./cmd/package-server
binary: package-server
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
tags:
- json1
flags:
- -mod=vendor
ldflags:
- -X {{ .Env.PKG }}/pkg/version.GitCommit={{ .FullCommit }}
- -X {{ .Env.PKG }}/pkg/version.OLMVersion={{ .Tag }}
dockers:
- image_templates:
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-amd64
dockerfile: Dockerfile.goreleaser
use: buildx
goos: linux
goarch: amd64
build_flag_templates:
- --platform=linux/amd64
- image_templates:
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-arm64
dockerfile: Dockerfile.goreleaser
use: buildx
goos: linux
goarch: arm64
build_flag_templates:
- --platform=linux/arm64
- image_templates:
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-ppc64le
dockerfile: Dockerfile.goreleaser
use: buildx
goos: linux
goarch: ppc64le
build_flag_templates:
- --platform=linux/ppc64le
- image_templates:
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-s390x
dockerfile: Dockerfile.goreleaser
use: buildx
goos: linux
goarch: s390x
build_flag_templates:
- --platform=linux/s390x
docker_manifests:
- name_template: quay.io/{{ .Env.IMAGE_REPO }}:v{{ .Major }}.{{ .Minor }}
image_templates:
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-amd64
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-arm64
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-ppc64le
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-s390x
- name_template: quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}
image_templates:
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-amd64
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-arm64
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-ppc64le
- quay.io/{{ .Env.IMAGE_REPO }}:{{ .Tag }}-s390x
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^doc:'
- '^test:'
release:
draft: true
13 changes: 13 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=$BUILDPLATFORM gcr.io/distroless/static:debug
LABEL stage=olm
WORKDIR /
# bundle unpack Jobs require cp at /bin/cp
RUN ["/busybox/ln", "-s", "/busybox/cp", "/bin/cp"]
# copy goreleaser built binaries
COPY olm /bin/olm
COPY catalog /bin/catalog
COPY package-server /bin/package-server
COPY cpb /bin/cpb
EXPOSE 8080
EXPOSE 5443
ENTRYPOINT ["/bin/olm"]
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,16 @@ verify: verify-codegen verify-mockgen verify-manifests

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

verify-release: release
$(MAKE) diff

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