Skip to content

Commit 9e0f905

Browse files
authored
Spectro cicd3 (#83)
* spectro-cicd * spectro-cicd * spectro-cicd3
1 parent df23fb0 commit 9e0f905

File tree

3 files changed

+88
-6
lines changed

3 files changed

+88
-6
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Spectro Release
2+
run-name: Release for Cluster API Maas ${{ github.event.inputs.release_version }}
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: 'Cluster API Version to Build'
8+
required: true
9+
default: '0.0.0'
10+
jobs:
11+
builder:
12+
# edge-runner machine group is a bunch of machines in US Datacenter
13+
runs-on: ubuntu-latest
14+
# Initialize all secrets required for the job
15+
# Ensure that the credentials are provided as encrypted secrets
16+
env:
17+
SPECTRO_VERSION: ${{ github.event.inputs.release_version }}
18+
steps:
19+
-
20+
uses: mukunku/[email protected]
21+
id: checkTag
22+
with:
23+
tag: v${{ github.event.inputs.release_version }}-spectro
24+
-
25+
if: ${{ steps.checkTag.outputs.exists == 'true' }}
26+
run: |
27+
echo "Tag already exists for v${{ github.event.inputs.release_version }}-spectro..."
28+
exit 1
29+
-
30+
uses: actions/checkout@v3
31+
-
32+
name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v1
34+
-
35+
name: Login to private registry
36+
uses: docker/login-action@v1
37+
with:
38+
registry: ${{ secrets.REGISTRY_URL }}
39+
username: ${{ secrets.REGISTRY_USERNAME }}
40+
password: ${{ secrets.REGISTRY_PASSWORD }}
41+
-
42+
name: Build Image
43+
env:
44+
REGISTRY: gcr.io/spectro-images-public/release/cluster-api-maas
45+
run: |
46+
make docker-build
47+
make docker-push
48+
-
49+
name: Build Image - FIPS Mode
50+
env:
51+
FIPS_ENABLE: yes
52+
REGISTRY: gcr.io/spectro-images-public/release-fips/cluster-api-maas
53+
run: |
54+
make docker-build
55+
make docker-push
56+
-
57+
name: Create Release
58+
id: create_release
59+
uses: actions/create-release@v1
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
with:
63+
tag_name: v${{ github.event.inputs.release_version }}-spectro
64+
release_name: Release v${{ github.event.inputs.release_version }}-spectro
65+
body: |
66+
Release version ${{ github.event.inputs.release_version }}
67+
draft: false
68+
prerelease: false

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@ COPY go.sum go.sum
88
# cache deps before building and copying source so that we don't need to re-download as much
99
# and so that source changes don't invalidate our downloaded layer
1010
RUN go mod download
11-
11+
ARG CRYPTO_LIB
12+
ENV GOEXPERIMENT=${CRYPTO_LIB:+boringcrypto}
1213
# Copy the go source
1314
COPY main.go main.go
1415
COPY api/ api/
1516
COPY pkg/ pkg/
1617
COPY controllers/ controllers/
1718

1819
# Build
19-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
20+
21+
RUN if [ ${CRYPTO_LIB} ]; \
22+
then \
23+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-linkmode=external -extldflags=-static" -a -o manager main.go ;\
24+
else \
25+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go ;\
26+
fi
2027

2128
# Use distroless as minimal base image to package the manager binary
2229
# Refer to https://github.com/GoogleContainerTools/distroless for more details

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ BUILD_DIR :=_build
1212
RELEASE_DIR := _build/release
1313
DEV_DIR := _build/dev
1414
REPO_ROOT := $(shell git rev-parse --show-toplevel)
15+
FIPS_ENABLE ?= ""
16+
17+
RELEASE_LOC := release
18+
ifeq ($(FIPS_ENABLE),yes)
19+
RELEASE_LOC := release-fips
20+
endif
1521

1622
# Image URL to use all building/pushing image targets
1723
IMAGE_NAME := cluster-api-provider-maas-controller
18-
IMG_URL ?= gcr.io/spectro-dev-public/release/cluster-api
19-
IMG_TAG ?= spectro-v0.2.0-v1beta1-20230517.0809
20-
IMG ?= ${IMG_URL}/${IMAGE_NAME}:${IMG_TAG}
24+
REGISTRY ?= gcr.io/spectro-dev-public/${RELEASE_LOC}/cluster-api
25+
SPECTRO_VERSION ?= 4.0.0-dev
26+
IMG_TAG ?= v0.2.0-spectro-${SPECTRO_VERSION}
27+
IMG ?= ${REGISTRY}/${IMAGE_NAME}:${IMG_TAG}
2128

2229
# Set --output-base for conversion-gen if we are not within GOPATH
2330
ifneq ($(abspath $(REPO_ROOT)),$(shell go env GOPATH)/src/github.com/spectrocloud/cluster-api-provider-maas)
@@ -149,7 +156,7 @@ generate-manifests: ## Generate manifests
149156

150157
# Build the docker image
151158
docker-build: #test
152-
docker build . -t ${IMG}
159+
docker build --build-arg CRYPTO_LIB=${FIPS_ENABLE} . -t ${IMG}
153160

154161
# Push the docker image
155162
docker-push: ## Push the docker image to gcr

0 commit comments

Comments
 (0)