Skip to content

Commit b11186c

Browse files
committed
[WIP] goreleaser tooling
1 parent 09c3aa1 commit b11186c

File tree

7 files changed

+163
-168
lines changed

7 files changed

+163
-168
lines changed

.goreleaser.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
before:
2+
hooks:
3+
- go version | grep --quiet "go1\.15\.2" || echo "Go binary version must be 1.15.2"
4+
- go mod download
5+
builds:
6+
- id: operator-sdk
7+
main: ./cmd/operator-sdk
8+
binary: operator-sdk
9+
env:
10+
- CGO_ENABLED=0
11+
- GO111MODULE=on
12+
- REPO=github.com/operator-framework/operator-sdk
13+
mod_timestamp: "{{ .CommitTimestamp }}"
14+
asmflags:
15+
- all=-trimpath={{ dir .ArtifactPath | dir | dir | dir }}
16+
gcflags:
17+
- all=-trimpath={{ dir .ArtifactPath | dir | dir | dir }}
18+
ldflags:
19+
- -X {{ .Env.REPO }}/internal/version.Version={{ if not .IsSnapshot }}v{{ end }}{{ .Version }}
20+
- -X {{ .Env.REPO }}/internal/version.GitVersion={{ .Tag }}
21+
- -X {{ .Env.REPO }}/internal/version.GitCommit={{ .FullCommit }}
22+
- -X {{ .Env.REPO }}/internal/version.KubernetesVersion={{ .Env.K8S_VERSION }}
23+
goarch:
24+
- amd64
25+
- arm64
26+
- ppc64le
27+
- s390x
28+
goos:
29+
- linux
30+
- darwin
31+
ignore:
32+
- goos: darwin
33+
goarch: arm64
34+
- goos: darwin
35+
goarch: ppc64le
36+
- goos: darwin
37+
goarch: s390x
38+
39+
# ansible-operator build steps
40+
- id: ansible-operator
41+
main: ./cmd/ansible-operator
42+
binary: ansible-operator
43+
env:
44+
- CGO_ENABLED=0
45+
- GO111MODULE=on
46+
- REPO=github.com/operator-framework/operator-sdk
47+
mod_timestamp: "{{ .CommitTimestamp }}"
48+
asmflags:
49+
- all=-trimpath={{ dir .ArtifactPath | dir | dir | dir }}
50+
gcflags:
51+
- all=-trimpath={{ dir .ArtifactPath | dir | dir | dir }}
52+
ldflags:
53+
- -X {{ .Env.REPO }}/internal/version.Version={{ if not .IsSnapshot }}v{{ end }}{{ .Version }}
54+
- -X {{ .Env.REPO }}/internal/version.GitVersion={{ .Tag }}
55+
- -X {{ .Env.REPO }}/internal/version.GitCommit={{ .FullCommit }}
56+
- -X {{ .Env.REPO }}/internal/version.KubernetesVersion={{ .Env.K8S_VERSION }}
57+
goarch:
58+
- amd64
59+
- arm64
60+
- ppc64le
61+
- s390x
62+
goos:
63+
- linux
64+
- darwin
65+
ignore:
66+
- goos: darwin
67+
goarch: arm64
68+
- goos: darwin
69+
goarch: ppc64le
70+
- goos: darwin
71+
goarch: s390x
72+
73+
# helm-operator build steps
74+
- id: helm-operator
75+
main: ./cmd/helm-operator
76+
binary: helm-operator
77+
env:
78+
- CGO_ENABLED=0
79+
- GO111MODULE=on
80+
- REPO=github.com/operator-framework/operator-sdk
81+
mod_timestamp: "{{ .CommitTimestamp }}"
82+
asmflags:
83+
- all=-trimpath={{ dir .ArtifactPath | dir | dir | dir }}
84+
gcflags:
85+
- all=-trimpath={{ dir .ArtifactPath | dir | dir | dir }}
86+
ldflags:
87+
- -X {{ .Env.REPO }}/internal/version.Version={{ if not .IsSnapshot }}v{{ end }}{{ .Version }}
88+
- -X {{ .Env.REPO }}/internal/version.GitVersion={{ .Tag }}
89+
- -X {{ .Env.REPO }}/internal/version.GitCommit={{ .FullCommit }}
90+
- -X {{ .Env.REPO }}/internal/version.KubernetesVersion={{ .Env.K8S_VERSION }}
91+
goarch:
92+
- amd64
93+
- arm64
94+
- ppc64le
95+
- s390x
96+
goos:
97+
- linux
98+
- darwin
99+
ignore:
100+
- goos: darwin
101+
goarch: arm64
102+
- goos: darwin
103+
goarch: ppc64le
104+
- goos: darwin
105+
goarch: s390x
106+
107+
# Use most recent tag and short commit for snapshot version.
108+
snapshot:
109+
name_template: "{{ .Tag }}"
110+
111+
# We don't use archives, so skip creating them.
112+
archives:
113+
- format: binary
114+
115+
checksum:
116+
name_template: 'checksums.txt'
117+
118+
# Sign checksum files with the local default PGP key.
119+
# TODO(estroz): configure CI PGP key
120+
# signs:
121+
# - signature: "${artifact}.asc"
122+
# cmd: gpg2
123+
# artifacts: checksum
124+
125+
# We use a custom changelog generator.
126+
changelog:
127+
128+
# TODO(estroz): configure homebrew publishing
129+
# brews:
130+
# - name: operator-sdk
131+
# ids:
132+
# - operator-sdk

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dist: xenial
33

44
language: go
55
go:
6-
- 1.15.x
6+
- 1.15.2
77
go_import_path: github.com/operator-framework/operator-sdk
88

99
cache:
@@ -50,9 +50,11 @@ stages:
5050
- check
5151
- test
5252
- name: deploy
53-
if: type != pull_request AND ( tag IS present OR branch = master OR commit_message =~ /\[travis deploy\]/ )
53+
if: type != pull_request AND ( tag IS present OR branch = master OR branch =~ /^v[0-9]+\.[0-9]+\.x$/ OR commit_message =~ /\[travis deploy\]/ )
5454
- name: deploy-manifest-multiarch
55-
if: type != pull_request AND ( tag IS present OR branch = master OR commit_message =~ /\[travis deploy\]/ )
55+
if: type != pull_request AND ( tag IS present OR branch = master OR branch =~ /^v[0-9]+\.[0-9]+\.x$/ OR commit_message =~ /\[travis deploy\]/ )
56+
- name: release
57+
if: type != pull_request AND tag IS present
5658

5759
jobs:
5860
include:
@@ -151,3 +153,10 @@ jobs:
151153
name: push manifest lists
152154
<<: *manifest-deploy
153155
script: make -f release/Makefile image-push-multiarch
156+
157+
## Release jobs ##
158+
159+
- stage: release
160+
name: publish release
161+
before_install: git fetch origin --unshallow --tags
162+
script: make -f release/Makefile release TAG="$TRAVIS_TAG"

Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,6 @@ test-e2e-integration:: ## Run integration tests
145145
./hack/tests/integration.sh
146146
./hack/tests/subcommand-olm-install.sh
147147

148-
# TODO(estroz): remove changelog/release when goreleaser is added as release tool (they shouldn't be exposed as dev targets).
149-
150-
.PHONY: changelog
151-
changelog: ## Generate CHANGELOG.md and migration guide updates
152-
$(MAKE) -f release/Makefile changelog
153-
154-
.PHONY: release
155-
release: clean ## Release the Operator SDK
156-
$(MAKE) -f release/Makefile GO_BUILD_ARGS='$(GO_BUILD_ARGS)'
157-
158148
.DEFAULT_GOAL := help
159149
.PHONY: help
160150
help: ## Show this help screen.

hack/image/push-image-tags.sh

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function push_image_tags() {
1616
push_image=$1; shift || push_image=$source_image
1717

1818
print_image_info $source_image
19-
print_git_tags
2019

2120
docker_login $push_image
2221

@@ -53,31 +52,4 @@ function print_image_info() {
5352
fi
5453
}
5554

56-
#
57-
# print_git_tags
58-
#
59-
# print_git_tags prints all tags present in the git repository.
60-
#
61-
function print_git_tags() {
62-
git_tags=$(git tag -l | sed 's|^| |')
63-
if [[ -n "$git_tags" ]]; then
64-
echo "Found git tags:"
65-
echo "$git_tags"
66-
echo ""
67-
fi
68-
}
69-
70-
71-
#
72-
# latest_git_version
73-
#
74-
# latest_git_version returns the highest semantic version
75-
# number found in the repository, with the form "vX.Y.Z".
76-
# Version numbers not matching the semver release format
77-
# are ignored.
78-
#
79-
function latest_git_version() {
80-
git tag -l | egrep "${semver_regex}" | sort -V | tail -1
81-
}
82-
8355
push_image_tags "$@"

hack/image/push-manifest-list.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ function push_manifest_list() {
2828
}
2929

3030
function get_arch_images(){
31-
image=$1; shift || fatal "${FUNCNAME} usage error"
32-
tag=$1; shift || fatal "${FUNCNAME} usage error"
33-
arches="$@"
34-
for arch in $arches; do
35-
echo "$image-$arch:$tag"
36-
done
31+
image=$1; shift || fatal "${FUNCNAME} usage error"
32+
tag=$1; shift || fatal "${FUNCNAME} usage error"
33+
arches="$@"
34+
for arch in $arches; do
35+
echo "$image-$arch:$tag"
36+
done
3737
}
3838

3939
push_manifest_list "$@"

release.sh

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

0 commit comments

Comments
 (0)