Skip to content

Commit

Permalink
Config for Wercker release (oracle#131)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
garthy authored and owainlewis committed Feb 6, 2018
1 parent 6bb5236 commit 9419964
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ vendors.txt

# Wercker
.wercker/

.idea/
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ REGISTRY := wcr.io/oracle
PKG := github.com/oracle/oci-cloud-controller-manager
BIN := oci-cloud-controller-manager
IMAGE := $(REGISTRY)/$(BIN)
VERSION := $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)


BUILD := $(shell git describe --always --dirty)
# Allow overriding for release versions
# Else just equal the build (git hash)
VERSION ?= ${BUILD}
GOOS ?= linux
ARCH ?= amd64

Expand All @@ -22,7 +25,7 @@ else
endif

.PHONY: all
all: build
all: check test build

.PHONY: gofmt
gofmt:
Expand All @@ -36,17 +39,20 @@ golint:
govet:
@./hack/check-govet.sh ${SRC_DIRS}

.PHONY: check
check: gofmt govet golint

.PHONY: build-dirs
build-dirs:
@mkdir -p dist/

.PHONY: build
build: build-dirs
@GOOS=${GOOS} GOARCH=${ARCH} go build \
build: build-dirs manifests
@GOOS=${GOOS} GOARCH=${ARCH} go build -v \
-i \
-o dist/oci-cloud-controller-manager \
-installsuffix "static" \
-ldflags "-X main.version=${VERSION}" \
-ldflags "-X main.version=${VERSION} -X main.build=${BUILD}" \
./cmd/oci-cloud-controller-manager

.PHONY: manifests
Expand All @@ -62,15 +68,15 @@ test:

.PHONY: clean
clean:
@rm -rf dist/*
@rm -rf dist

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

.PHONY: run-dev
run-dev:
@go run cmd/$(BIN)/main.go \
run-dev: build
dist/oci-cloud-controller-manager \
--kubeconfig=${KUBECONFIG} \
--cloud-config=${CLOUD_PROVIDER_CFG} \
--cluster-cidr=10.244.0.0/16 \
Expand Down
3 changes: 2 additions & 1 deletion cmd/oci-cloud-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
)

var version string
var build string

func init() {
healthz.DefaultHealthz()
Expand All @@ -50,7 +51,7 @@ func main() {
logs.InitLogs()
defer logs.FlushLogs()

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

verflag.PrintAndExitIfRequested()

Expand Down
33 changes: 0 additions & 33 deletions manifests/oci-cloud-controller-manager-pod.yaml

This file was deleted.

54 changes: 44 additions & 10 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ dev:
build:
base-path: "/go/src/github.com/oracle/oci-cloud-controller-manager"
steps:
- script:
name: write VERSION.txt
code: |
make version > ${WERCKER_OUTPUT_DIR}/VERSION.txt
cat ${WERCKER_OUTPUT_DIR}/VERSION.txt
- script:
name: go fmt
code: make gofmt
Expand All @@ -25,18 +19,30 @@ build:
name: go vet
code: make govet

- script:
name: unit tests
code: make test

- script:
name: build
code: make build

- script:
name: unit tests
code: make test
name: manifests
code: make manifests

- script:
name: copy binary
name: write VERSION.txt
code: |
make version > dist/VERSION.txt
cat dist/VERSION.txt
copy:
steps:
- script:
name: copy output
code: |
cp dist/oci-cloud-controller-manager ${WERCKER_OUTPUT_DIR}
cp -a dist/* ${WERCKER_OUTPUT_DIR}
push:
box:
Expand All @@ -59,3 +65,31 @@ push:
tag: $VERSION
entrypoint: /oci-cloud-controller-manager
user: 65534 # nobody

release:
box:
id: oraclelinux:7-slim
steps:
- script:
name: set ENV vars
code: |
export VERSION=$(cat VERSION.txt)
echo "${VERSION}"
- github-create-release:
token: $GITHUB_TOKEN
tag: $VERSION
title: $VERSION
draft: false

- github-upload-asset:
token: $GITHUB_TOKEN
file: ./oci-cloud-controller-manager.yaml
filename: oci-cloud-controller-manager.yaml
content-type: text/yaml

- github-upload-asset:
token: $GITHUB_TOKEN
file: ./oci-cloud-controller-manager-rbac.yaml
filename: oci-cloud-controller-manager-rbac.yaml
content-type: text/yaml

0 comments on commit 9419964

Please sign in to comment.