Skip to content

Commit a0e90ca

Browse files
committed
Automate release process
The new release process uses goreleaser to automatically create and publish releases. Among other things this allows us to make sure that all version numbers are updated automatically based on the git tag we set. For every release after this commit the deployment example files are published as a GitHub release. The links to the corresponding files in the repository do not work anymore.
1 parent 9601334 commit a0e90ca

15 files changed

Lines changed: 478 additions & 144 deletions

.github/workflows/goreleaser.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: goreleaser
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
branches:
8+
- master
9+
jobs:
10+
goreleaser:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- name: Set up Go
18+
uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.16
21+
- name: Setup Docker Buildx
22+
uses: docker/setup-buildx-action@v1
23+
- name: Login to Docker Hub
24+
uses: docker/login-action@v1
25+
with:
26+
username: ${{ secrets.DOCKER_USER }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
- name: Run GoReleaser for snapshot
29+
if: "!startsWith(github.ref, 'refs/tags/')"
30+
uses: goreleaser/goreleaser-action@v2
31+
with:
32+
version: latest
33+
args: release --snapshot --rm-dist
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Publish latest snapshot image
37+
if: "!startsWith(github.ref, 'refs/tags/')"
38+
env:
39+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
40+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
41+
run: |
42+
docker push hetznercloud/hcloud-cloud-controller-manager:latest
43+
- name: Run GoReleaser for tag
44+
if: "startsWith(github.ref, 'refs/tags/')"
45+
uses: goreleaser/goreleaser-action@v2
46+
with:
47+
version: latest
48+
args: release --rm-dist
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
- name: Clear
52+
if: always()
53+
run: rm -f ${HOME}/.docker/config.json

.github/workflows/publish_on_master.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/publish_on_tag.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/bin
22
/vendor
3+
dist/
4+
deploy/gen/
35
.coverage.out
46
.envrc

.gitlab-ci.yml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
---
22
include:
3-
- project: "hc/backend/deploy-tools"
4-
file: "ci/release/image.yml"
53
- project: "hc/backend/deploy-tools"
64
file: "ci/build/image.yml"
7-
5+
- project: "hc/backend/deploy-tools"
6+
file: "ci/release/image.yml"
87

98
stages:
109
- test
11-
- E2E
1210
- build
11+
- build:image
12+
- e2e
1313
- release
14+
- release:image
1415

1516
variables:
1617
GOPROXY: goproxy.prodext.hcinfra.de
@@ -38,11 +39,45 @@ test:unit:
3839
tags:
3940
- hc-bladerunner
4041

42+
.build:goreleaser: &build-goreleaser
43+
stage: build
44+
image:
45+
name: goreleaser/goreleaser
46+
entrypoint: [""]
47+
variables:
48+
GIT_DEPTH: 0
49+
after_script:
50+
- cp dist/hcloud-cloud-controller-manager_linux_amd64/hcloud-cloud-controller-manager hcloud-cloud-controller-manager
51+
artifacts:
52+
paths:
53+
- hcloud-cloud-controller-manager
54+
expire_in: 1 day
55+
tags:
56+
- hc-bladerunner
57+
58+
build:goreleaser:snapshot:
59+
<<: *build-goreleaser
60+
script: |
61+
goreleaser build --rm-dist --snapshot
62+
except:
63+
- tags
64+
65+
build:goreleaser:tags:
66+
<<: *build-goreleaser
67+
script: |
68+
goreleaser build --rm-dist
69+
only:
70+
- tags
71+
72+
build:image:
73+
stage: build:image
74+
4175
.e2e:k8s: &testk8se2e
42-
stage: E2E
76+
stage: e2e
4377
image: docker:git
4478
variables:
4579
K8S_VERSION: k8s-1.19.10
80+
CCM_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
4681
before_script:
4782
- apk add --no-cache git make musl-dev go openssh-client
4883
script:
@@ -82,3 +117,6 @@ k8s-1.21 networks:
82117
variables:
83118
K8S_VERSION: k8s-1.21.0
84119
USE_NETWORKS: "yes"
120+
121+
release:image:
122+
stage: release:image

.goreleaser.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
---
4+
before:
5+
hooks:
6+
- go mod tidy
7+
builds:
8+
- id: hcloud-cloud-controller-manager
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
goarch:
14+
- amd64
15+
binary: hcloud-cloud-controller-manager
16+
ldflags:
17+
- "-s -w -X hcloud.providerVersion={{ if not .IsSnapshot }}v{{ end }}{{ .Version }}"
18+
hooks:
19+
post: ./scripts/generate-deployment-yamls.sh {{ .Version }}
20+
archives:
21+
- id: deployment-yamls
22+
# builds: [""]
23+
name_template: "{{ .ProjectName }}_{{ .Version }}_deployment_yamls"
24+
wrap_in_directory: true
25+
26+
dockers:
27+
- ids:
28+
- hcloud-cloud-controller-manager
29+
goos: linux
30+
goarch: amd64
31+
image_templates:
32+
- "hetznercloud/hcloud-cloud-controller-manager:latest"
33+
- "hetznercloud/hcloud-cloud-controller-manager:{{ if not .IsSnapshot }}v{{ end }}{{ .Version }}"
34+
dockerfile: Dockerfile
35+
use_buildx: true
36+
build_flag_templates:
37+
- "--platform=linux/amd64"
38+
release:
39+
ids: [""]
40+
draft: true
41+
extra_files:
42+
- glob: "./deploy/ccm-*.yaml"

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
v1.10.0
5+
-------
6+
7+
*Note* starting from this release this file is no longer maintained. We
8+
changed to an automated release process. Changelog entries can now be
9+
found on the respective [GitHub
10+
releases](https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases).
11+
412
v1.9.1
513
------
614

Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
FROM golang:1.16 as builder
2-
WORKDIR /maschine-controller/src
3-
ADD . .
4-
RUN CGO_ENABLED=0 go build -o hcloud-maschine-controller.bin .
5-
61
FROM alpine:3.12
72
RUN apk add --no-cache ca-certificates bash
8-
COPY --from=builder /maschine-controller/src/hcloud-maschine-controller.bin /bin/hcloud-cloud-controller-manager
3+
COPY hcloud-cloud-controller-manager /bin/hcloud-cloud-controller-manager
94
ENTRYPOINT ["/bin/hcloud-cloud-controller-manager"]

0 commit comments

Comments
 (0)