Skip to content

Commit 9419964

Browse files
garthyowainlewis
authored andcommitted
Config for Wercker release (#131)
* Remove unused pod file * Clean makefile to add version/build * Add checks to all target, verbose build * Configure for release * Add release process and content type * Move copy to step
1 parent 6bb5236 commit 9419964

File tree

5 files changed

+63
-53
lines changed

5 files changed

+63
-53
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ vendors.txt
3939

4040
# Wercker
4141
.wercker/
42+
43+
.idea/

Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ REGISTRY := wcr.io/oracle
22
PKG := github.com/oracle/oci-cloud-controller-manager
33
BIN := oci-cloud-controller-manager
44
IMAGE := $(REGISTRY)/$(BIN)
5-
VERSION := $(shell git describe --exact-match 2> /dev/null || \
6-
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
75

6+
7+
BUILD := $(shell git describe --always --dirty)
8+
# Allow overriding for release versions
9+
# Else just equal the build (git hash)
10+
VERSION ?= ${BUILD}
811
GOOS ?= linux
912
ARCH ?= amd64
1013

@@ -22,7 +25,7 @@ else
2225
endif
2326

2427
.PHONY: all
25-
all: build
28+
all: check test build
2629

2730
.PHONY: gofmt
2831
gofmt:
@@ -36,17 +39,20 @@ golint:
3639
govet:
3740
@./hack/check-govet.sh ${SRC_DIRS}
3841

42+
.PHONY: check
43+
check: gofmt govet golint
44+
3945
.PHONY: build-dirs
4046
build-dirs:
4147
@mkdir -p dist/
4248

4349
.PHONY: build
44-
build: build-dirs
45-
@GOOS=${GOOS} GOARCH=${ARCH} go build \
50+
build: build-dirs manifests
51+
@GOOS=${GOOS} GOARCH=${ARCH} go build -v \
4652
-i \
4753
-o dist/oci-cloud-controller-manager \
4854
-installsuffix "static" \
49-
-ldflags "-X main.version=${VERSION}" \
55+
-ldflags "-X main.version=${VERSION} -X main.build=${BUILD}" \
5056
./cmd/oci-cloud-controller-manager
5157

5258
.PHONY: manifests
@@ -62,15 +68,15 @@ test:
6268

6369
.PHONY: clean
6470
clean:
65-
@rm -rf dist/*
71+
@rm -rf dist
6672

6773
.PHONY: deploy
6874
deploy:
6975
kubectl -n kube-system set image ds/${BIN} ${BIN}=${IMAGE}:${VERSION}
7076

7177
.PHONY: run-dev
72-
run-dev:
73-
@go run cmd/$(BIN)/main.go \
78+
run-dev: build
79+
dist/oci-cloud-controller-manager \
7480
--kubeconfig=${KUBECONFIG} \
7581
--cloud-config=${CLOUD_PROVIDER_CFG} \
7682
--cluster-cidr=10.244.0.0/16 \

cmd/oci-cloud-controller-manager/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
)
3737

3838
var version string
39+
var build string
3940

4041
func init() {
4142
healthz.DefaultHealthz()
@@ -50,7 +51,7 @@ func main() {
5051
logs.InitLogs()
5152
defer logs.FlushLogs()
5253

53-
glog.V(1).Infof("oci-cloud-controller-manager version: %s", version)
54+
glog.V(1).Infof("oci-cloud-controller-manager version: %s (%s)", version, build)
5455

5556
verflag.PrintAndExitIfRequested()
5657

manifests/oci-cloud-controller-manager-pod.yaml

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

wercker.yml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ dev:
55
build:
66
base-path: "/go/src/github.com/oracle/oci-cloud-controller-manager"
77
steps:
8-
- script:
9-
name: write VERSION.txt
10-
code: |
11-
make version > ${WERCKER_OUTPUT_DIR}/VERSION.txt
12-
cat ${WERCKER_OUTPUT_DIR}/VERSION.txt
13-
148
- script:
159
name: go fmt
1610
code: make gofmt
@@ -25,18 +19,30 @@ build:
2519
name: go vet
2620
code: make govet
2721

22+
- script:
23+
name: unit tests
24+
code: make test
25+
2826
- script:
2927
name: build
3028
code: make build
3129

3230
- script:
33-
name: unit tests
34-
code: make test
31+
name: manifests
32+
code: make manifests
3533

3634
- script:
37-
name: copy binary
35+
name: write VERSION.txt
36+
code: |
37+
make version > dist/VERSION.txt
38+
cat dist/VERSION.txt
39+
40+
copy:
41+
steps:
42+
- script:
43+
name: copy output
3844
code: |
39-
cp dist/oci-cloud-controller-manager ${WERCKER_OUTPUT_DIR}
45+
cp -a dist/* ${WERCKER_OUTPUT_DIR}
4046
4147
push:
4248
box:
@@ -59,3 +65,31 @@ push:
5965
tag: $VERSION
6066
entrypoint: /oci-cloud-controller-manager
6167
user: 65534 # nobody
68+
69+
release:
70+
box:
71+
id: oraclelinux:7-slim
72+
steps:
73+
- script:
74+
name: set ENV vars
75+
code: |
76+
export VERSION=$(cat VERSION.txt)
77+
echo "${VERSION}"
78+
79+
- github-create-release:
80+
token: $GITHUB_TOKEN
81+
tag: $VERSION
82+
title: $VERSION
83+
draft: false
84+
85+
- github-upload-asset:
86+
token: $GITHUB_TOKEN
87+
file: ./oci-cloud-controller-manager.yaml
88+
filename: oci-cloud-controller-manager.yaml
89+
content-type: text/yaml
90+
91+
- github-upload-asset:
92+
token: $GITHUB_TOKEN
93+
file: ./oci-cloud-controller-manager-rbac.yaml
94+
filename: oci-cloud-controller-manager-rbac.yaml
95+
content-type: text/yaml

0 commit comments

Comments
 (0)