Skip to content

Commit daede34

Browse files
authored
Add release tooling. (#8)
This fixes #5. Signed-off-by: James Peach <jpeach@vmware.com>
1 parent 1126a62 commit daede34

File tree

6 files changed

+144
-2
lines changed

6 files changed

+144
-2
lines changed

.goreleaser.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
project_name: contour-authserver
2+
before:
3+
hooks:
4+
- go mod download
5+
- go generate ./...
6+
builds:
7+
- env:
8+
- CGO_ENABLED=0
9+
goarch:
10+
- amd64
11+
goos:
12+
- linux
13+
- darwin
14+
ldflags:
15+
- -s
16+
- -w
17+
- -X github.com/projectcontour/contour-authserver/pkg/version.Progname={{ .ProjectName }}
18+
- -X github.com/projectcontour/contour-authserver/pkg/version.Version={{ .Env.VERSION }}
19+
- -X github.com/projectcontour/contour-authserver/pkg/version.Sha={{ .Env.SHA }}
20+
- -X github.com/projectcontour/contour-authserver/pkg/version.BuildDate={{ .Date }}
21+
archives:
22+
- replacements:
23+
darwin: Darwin
24+
linux: Linux
25+
windows: Windows
26+
386: i386
27+
amd64: x86_64
28+
checksum:
29+
name_template: 'checksums.txt'
30+
snapshot:
31+
name_template: "{{ .Tag }}-next"
32+
changelog:
33+
sort: asc
34+
filters:
35+
exclude:
36+
- '^docs:'
37+
- '^test:'
38+
dockers:
39+
- goarch: amd64
40+
goos: linux
41+
dockerfile: hack/Dockerfile.release
42+
skip_push: true
43+
image_templates:
44+
- "projectcontour/{{ .ProjectName }}:{{ .Env.VERSION }}"
45+
- "projectcontour/{{ .ProjectName }}:latest"
46+
build_flag_templates:
47+
- "--pull"
48+
- "--label=org.opencontainers.image.created={{.Date}}"
49+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
50+
- "--label=org.opencontainers.image.version={{.Env.VERSION}}"
51+
- "--label=org.opencontainers.image.url=https://projectcontour.io/"
52+
- "--label=org.opencontainers.image.documentation=https://projectcontour.io/"
53+
- "--label=org.opencontainers.image.vendor=Project Contour"
54+
- "--label=org.opencontainers.image.licenses=Apache-2.0"
55+
- "--label=org.opencontainers.image.title=Contour Authserver"
56+
- "--label=org.opencontainers.image.description=Contour Authorization Server"

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Build the manager binary
1+
# Build the contour-authserver binary.
2+
#
3+
# Note that this is not used for releasing, since goreleaser handles that.
4+
25
FROM golang:1.14 as base
36

47
ENV GO111MODULE=on

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,21 @@ docker-build: ## Build the docker image
7979
docker-push: ## Push the docker image
8080
docker push ${IMG}
8181

82+
.PHONY: release
83+
release: ## Build and publish a release to Github
84+
# Check there is a token.
85+
[[ -n "$$GITHUB_TOKEN" ]] || [[ -r ~/.config/goreleaser/github_token ]]
86+
# Check we are on a tag.
87+
git describe --exact-match >/dev/null
88+
# Do a full dry-run.
89+
goreleaser check
90+
SHA=$(SHA) VERSION=$(VERSION) goreleaser release --rm-dist
91+
8292
.PHONY: clean
8393
clean:
8494
@rm -rf cover.out
85-
@rm bin/$(BIN)
95+
@rm -rf bin
96+
@rm -rf dist
8697

8798
.PHONY: help
8899
help:

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,33 @@ the `testserver` and `htpasswd` backends. For developer deployments,
9898

9999
There are no versioned releases or container images yet.
100100

101+
# Releasing `contour-authserver`
102+
103+
Maintainers who need to release a new version of `contour-authserver`
104+
can follow the following steps:
105+
106+
```bash
107+
# Ensure that you have a Github token either in $GITHUB_TOKEN or in ~/.config/goreleaser/github_token.
108+
# Ensure that goreleaser is installed.
109+
110+
# Tag the release.
111+
$ ./hack/make-release-tag.sh $OLDVERS $NEWVERS
112+
113+
# Push the release tag to Github.
114+
$ git push origin $NEWVERS
115+
116+
# Build and release binaries and Docker images.
117+
$ make release
118+
119+
# Log in with the Contour build account to push the images.
120+
$ docker login -u projectcontourbuilder
121+
$ docker push projectcontour/contour-authserver:$NEWVERS
122+
$ docker push projectcontour/contour-authserver:latest
123+
124+
# Log out of the Contour build account.
125+
$ docker logout
126+
```
127+
101128
[1]: https://httpd.apache.org/docs/current/programs/htpasswd.html
102129
[2]: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#authentication
103130
[3]: https://tools.ietf.org/html/rfc7617

hack/Dockerfile.release

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
COPY contour-authserver /
3+
ENTRYPOINT ["/contour-authserver"]

hack/make-release-tag.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#! /usr/bin/env bash
2+
3+
# Copyright Project Contour Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
readonly PROGNAME=$(basename "$0")
18+
readonly OLDVERS="$1"
19+
readonly NEWVERS="$2"
20+
21+
if [ -z "$OLDVERS" ] || [ -z "$NEWVERS" ]; then
22+
printf "Usage: %s OLDVERS NEWVERS\n" PROGNAME
23+
exit 1
24+
fi
25+
26+
set -o errexit
27+
set -o nounset
28+
set -o pipefail
29+
30+
if [ -n "$(git tag --list "$NEWVERS")" ]; then
31+
printf "%s: tag '%s' already exists\n" "$PROGNAME" "$NEWVERS"
32+
exit 1
33+
fi
34+
35+
git tag -F - "$NEWVERS" <<EOF
36+
Tag $NEWVERS release.
37+
38+
$(git shortlog "$OLDVERS..HEAD")
39+
EOF
40+
41+
printf "Created tag '%s'\n" "$NEWVERS"
42+
printf "Run 'git push %s %s' to push the tag if you are happy\n" '$REMOTE' "$NEWVERS"

0 commit comments

Comments
 (0)