Skip to content

Commit

Permalink
Merge pull request #127 from kubevirt-bot/cherry-pick-126-to-release-0.7
Browse files Browse the repository at this point in the history
[release-0.7] Fix release
  • Loading branch information
kubevirt-bot authored Sep 3, 2020
2 parents da2280e + a2a33c1 commit 16df4e5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ deploy:
on:
branch: master
- provider: script
script: make manifests container-build container-push IMAGE_TAG=$TRAVIS_TAG
script: IMAGE_TAG=$TRAVIS_TAG OPERATOR_VERSION_NEXT=${TRAVIS_TAG#v} make release-manifests container-build container-push
skip_cleanup: true
on:
tags: true
Expand Down
19 changes: 4 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ KUBEVIRTCI_PATH=$$(pwd)/kubevirtci/cluster-up
KUBEVIRTCI_CONFIG_PATH=$$(pwd)/_ci-configs
export KUBEVIRT_NUM_NODES ?= 3

GIT_VERSION=$$(git describe --always --tags)
VERSION=$${CI_UPSTREAM_VERSION:-$(GIT_VERSION)}
GIT_COMMIT=$$(git rev-list -1 HEAD)
COMMIT=$${CI_UPSTREAM_COMMIT:-$(GIT_COMMIT)}
BUILD_DATE=$$(date --utc -Iseconds)

export GINKGO ?= build/_output/bin/ginkgo

# Make does not offer a recursive wildcard function, so here's one:
Expand Down Expand Up @@ -79,12 +73,7 @@ check: shfmt fmt vet generate-all verify-manifests verify-unchanged test

.PHONY: build
build:
mkdir -p _out; \
LDFLAGS="-s -w "; \
LDFLAGS+="-X kubevirt.io/node-maintenance-operator/version.Version=$(VERSION) "; \
LDFLAGS+="-X kubevirt.io/node-maintenance-operator/version.GitCommit=$(COMMIT) "; \
LDFLAGS+="-X kubevirt.io/node-maintenance-operator/version.BuildDate=$(BUILD_DATE) "; \
GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux go build -ldflags="$$LDFLAGS" -o _out/node-maintenance-operator kubevirt.io/node-maintenance-operator/cmd/manager
./hack/build.sh

.PHONY: container-build
container-build: container-build-operator container-build-bundle container-build-index container-build-must-gather
Expand Down Expand Up @@ -151,9 +140,9 @@ generate-template-bundle:
.PHONY: generate-all
generate-all: generate-k8s generate-crds generate-template-bundle generate-bundle

.PHONY: manifests
manifests: generate-bundle
./hack/release-manifests.sh ${IMAGE_TAG}
.PHONY: release-manifests
release-manifests: generate-bundle
./hack/release-manifests.sh

.PHONY: verify-manifests
verify-manifests:
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WORKDIR /go/src/kubevirt.io/node-maintenance-operator/
ENV GOPATH=/go
COPY . .

RUN mkdir -p _out && GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux go build -o _out/node-maintenance-operator kubevirt.io/node-maintenance-operator/cmd/manager
RUN make build

FROM registry.access.redhat.com/ubi8/ubi-minimal
ENV OPERATOR=/usr/local/bin/node-maintenance-operator \
Expand Down
16 changes: 16 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -ex

GIT_VERSION=$(git describe --always --tags)
VERSION=${CI_UPSTREAM_VERSION:-${GIT_VERSION}}
GIT_COMMIT=$(git rev-list -1 HEAD)
COMMIT=${CI_UPSTREAM_COMMIT:-${GIT_COMMIT}}
BUILD_DATE=$(date --utc -Iseconds)

mkdir -p _out

LDFLAGS="-s -w "
LDFLAGS+="-X kubevirt.io/node-maintenance-operator/version.Version=${VERSION} "
LDFLAGS+="-X kubevirt.io/node-maintenance-operator/version.GitCommit=${COMMIT} "
LDFLAGS+="-X kubevirt.io/node-maintenance-operator/version.BuildDate=${BUILD_DATE} "
GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux go build -ldflags="${LDFLAGS}" -o _out/node-maintenance-operator kubevirt.io/node-maintenance-operator/cmd/manager
20 changes: 7 additions & 13 deletions hack/release-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ set -e
PROJECT_ROOT="$(readlink -e $(dirname "$BASH_SOURCE[0]")/../)"
OUT_DIR=${PROJECT_ROOT}/_out

TAG="${1:-latest}"

if [ "${TAG}" == "latest" ]; then
echo "Manifests release will not apply on \"latest\" tag"
exit 0
fi

VERSION=${TAG#v}
OPERATOR="${IMAGE_REGISTRY}/${OPERATOR_IMAGE}:${VERSION}"

rm -rf ${OUT_DIR}
mkdir -p ${OUT_DIR}

cp deploy/operator.yaml ${OUT_DIR}/operator.yaml
sed -i "s/REPLACE_IMAGE/${OPERATOR}/g" ${OUT_DIR}/operator.yaml
if [ "${IMAGE_TAG}" == "latest" ]; then
echo "Manifests release will not apply on \"latest\" tag"
exit 1
fi

cp manifests/node-maintenance-operator/${TAG}/manifests/* ${OUT_DIR}/
# copy everything we want to release to $OUT_DIR
# it was build by the generate-bundle make target dependency already
cp manifests/node-maintenance-operator/${IMAGE_TAG}/manifests/* ${OUT_DIR}/

0 comments on commit 16df4e5

Please sign in to comment.