Skip to content

Commit 17e7412

Browse files
committed
[WIP] goreleaser tooling
1 parent e311086 commit 17e7412

File tree

43 files changed

+374
-400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+374
-400
lines changed

.gitignore

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ website/resources/
1212
website/node_modules/
1313
website/tech-doc-hugo
1414

15-
# samples bin
16-
testdata/go/memcached-operator/bin/*
17-
18-
19-
*\.DS_Store
20-
2115
# Created by https://www.toptal.com/developers/gitignore/api/go,vim,emacs,visualstudiocode
2216
# Edit at https://www.toptal.com/developers/gitignore?templates=go,vim,emacs,visualstudiocode
2317

@@ -120,3 +114,5 @@ tags
120114
.ionide
121115

122116
# End of https://www.toptal.com/developers/gitignore/api/go,vim,emacs,visualstudiocode
117+
118+
*\.DS_Store

.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: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
os: linux
2+
dist: xenial
3+
4+
# Install python3 and utilities dependencies
5+
addons:
6+
apt:
7+
packages:
8+
- "python3"
9+
- "python3-pip"
10+
211
language: go
12+
go:
13+
- 1.15.2
314
go_import_path: github.com/operator-framework/operator-sdk
4-
dist: xenial
515

616
# Python 3.6 is the default Python when language: python.
717
# But when not language: python, Python 3 can not be used by default.
@@ -20,28 +30,21 @@ addons:
2030

2131
cache:
2232
directories:
23-
- $HOME/.cache/go-build
24-
25-
go:
26-
- 1.15.x
33+
- ${HOME}/.cache/go-build
34+
- $(go env GOPATH)/pkg/mod
2735

2836
# The `x_base_steps` top-level key is unknown to travis,
2937
# so we can use it to create a bunch of common build step
3038
# YAML anchors which we use in our build jobs.
3139
x_base_steps:
3240
# Base go, ansbile, and helm job
3341
- &test
34-
env:
35-
# before_install for jobs that require go builds and do not run for doc-only changes
3642
before_install:
3743
# hack/ci/check-doc-only-update.sh needs to be sourced so
3844
# that it can properly exit the test early with success
3945
- source hack/ci/check-doc-only-update.sh
4046
- git fetch origin --unshallow --tags
41-
after_success:
42-
- echo "Tests passed"
4347
after_failure:
44-
- echo "Tests failed"
4548
- kubectl get all --all-namespaces
4649
- kubectl get events --all-namespaces --field-selector=type=Warning
4750
services:
@@ -51,10 +54,6 @@ x_base_steps:
5154
- &deploy
5255
before_install:
5356
- git fetch origin --unshallow --tags
54-
after_success:
55-
- echo "Image build succeeded, and docker image tagged and pushed to repository"
56-
after_failure:
57-
- echo "Image build, docker image tagging, or docker image pushing to repository failed"
5857
services:
5958
- docker
6059

@@ -66,20 +65,18 @@ x_base_steps:
6665
# We need /etc/docker to be accessible to non-root users.
6766
# See https://github.com/moby/moby/pull/37847.
6867
- sudo chmod 0755 /etc/docker
69-
after_success:
70-
- echo "Manifest list push to registry succeeded"
71-
after_failure:
72-
- echo "Manifest list creation or push to registry failed"
7368
services:
7469
- docker
7570

7671
stages:
7772
- check
7873
- test
7974
- name: deploy
80-
if: type != pull_request AND ( tag IS present OR branch = master OR commit_message =~ /\[travis deploy\]/ )
75+
if: type != pull_request AND ( tag IS present OR branch = master OR branch =~ /^v[0-9]+\.[0-9]+\.x$/ OR commit_message =~ /\[travis deploy\]/ )
8176
- name: deploy-manifest-multiarch
82-
if: type != pull_request AND ( tag IS present OR branch = master OR commit_message =~ /\[travis deploy\]/ )
77+
if: type != pull_request AND ( tag IS present OR branch = master OR branch =~ /^v[0-9]+\.[0-9]+\.x$/ OR commit_message =~ /\[travis deploy\]/ )
78+
- name: release
79+
if: type != pull_request AND tag IS present
8380

8481
jobs:
8582
include:
@@ -88,38 +85,38 @@ jobs:
8885

8986
# Run the sanity tests
9087
- stage: check
91-
name: Sanity Tests
88+
name: sanity
9289
before_install:
9390
- git fetch origin --unshallow --tags
9491
script:
9592
- make test-sanity
9693

9794
# Run website checks
98-
- name: Doc Checks
95+
- name: doc links
9996
script:
10097
- make test-links
10198

10299
## Operator test stage jobs ##
103100

104101
# Build and test ansible and test ansible using molecule
105102
- stage: test
103+
name: ansible e2e
106104
<<: *test
107-
name: Ansible on Kubernetes
108105
before_script:
109106
- pip3 install --upgrade setuptools pip
110107
- pip install --user ansible~=2.9.13
111108
script:
112109
- make test-e2e-ansible test-e2e-ansible-molecule
113110

114111
# Test subcommands
115-
- <<: *test
116-
name: Subcommands and Integration on Kubernetes
112+
- name: subcommand and integration
113+
<<: *test
117114
script:
118115
- make test-e2e-integration
119116

120117
# Build and test go
121-
- <<: *test
122-
name: Go on Kubernetes
118+
- name: go unit and e2e
119+
<<: *test
123120
before_script:
124121
- (cd / && go get github.com/mattn/goveralls)
125122
script:
@@ -129,48 +126,55 @@ jobs:
129126
- $GOPATH/bin/goveralls -service=travis-ci -coverprofile=coverage.out -repotoken=$COVERALLS_TOKEN
130127

131128
# Build and test helm
132-
- <<: *test
133-
name: Helm on Kubernetes
129+
- name: helm e2e
130+
<<: *test
134131
script: make test-e2e-helm
135132

136133
## Image deploy/push stage jobs ##
137134

138135
# Build and deploy arm64 docker images
139136
- stage: deploy
140-
<<: *deploy
141-
name: Docker images for arm64
137+
name: build and push images (arm64)
142138
arch: arm64
139+
<<: *deploy
143140
script:
144-
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-sdk
145-
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk
141+
- make image-build
142+
- make -f release/Makefile image-push
146143

147144
# Build and deploy amd64 docker images
148-
- <<: *deploy
149-
name: Docker images for amd64
145+
- name: build and push images (amd64)
150146
arch: amd64
147+
<<: *deploy
151148
script:
152-
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-sdk
153-
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk
149+
- make image-build
150+
- make -f release/Makefile image-push
154151

155152
# Build and deploy ppc64le docker images
156-
- <<: *deploy
157-
name: Docker images for ppc64le
153+
- name: build and push images (ppc64le)
158154
arch: ppc64le
155+
<<: *deploy
159156
script:
160-
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-sdk
161-
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk
157+
- make image-build
158+
- make -f release/Makefile image-push
162159

163160
# Build and deploy s390x docker images
164-
- <<: *deploy
165-
name: Docker images for s390x
161+
- name: build and push images (s390x)
166162
arch: s390x
163+
<<: *deploy
167164
script:
168-
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-sdk
169-
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-sdk
165+
# Use targets directly since kuttl doesn't support s390x.
166+
- make image/ansible-operator image/helm-operator image/operator-sdk image/scorecard-test
167+
- make -f release/Makefile image-push/ansible-operator image-push/helm-operator image-push/operator-sdk image-push/scorecard-test
170168

171169
# Build and deploy ansible multi-arch manifest list
172170
- stage: deploy-manifest-multiarch
171+
name: push manifest lists
173172
<<: *manifest-deploy
174-
name: Manifest lists
175-
script:
176-
- make image-push-ansible-multiarch image-push-helm-multiarch image-push-scorecard-test-multiarch image-push-scorecard-test-kuttl-multiarch image-push-sdk-multiarch
173+
script: make -f release/Makefile image-push-multiarch
174+
175+
## Release jobs ##
176+
177+
- stage: release
178+
name: publish release
179+
before_install: git fetch origin --unshallow --tags
180+
script: make -f release/Makefile release TAG="$TRAVIS_TAG"

0 commit comments

Comments
 (0)