Skip to content

Commit

Permalink
Spectro cicd3 (#83)
Browse files Browse the repository at this point in the history
* spectro-cicd

* spectro-cicd

* spectro-cicd3
  • Loading branch information
seemadurrani authored Jun 22, 2023
1 parent df23fb0 commit 9e0f905
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 6 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/spectro-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Spectro Release
run-name: Release for Cluster API Maas ${{ github.event.inputs.release_version }}
on:
workflow_dispatch:
inputs:
release_version:
description: 'Cluster API Version to Build'
required: true
default: '0.0.0'
jobs:
builder:
# edge-runner machine group is a bunch of machines in US Datacenter
runs-on: ubuntu-latest
# Initialize all secrets required for the job
# Ensure that the credentials are provided as encrypted secrets
env:
SPECTRO_VERSION: ${{ github.event.inputs.release_version }}
steps:
-
uses: mukunku/[email protected]
id: checkTag
with:
tag: v${{ github.event.inputs.release_version }}-spectro
-
if: ${{ steps.checkTag.outputs.exists == 'true' }}
run: |
echo "Tag already exists for v${{ github.event.inputs.release_version }}-spectro..."
exit 1
-
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to private registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
-
name: Build Image
env:
REGISTRY: gcr.io/spectro-images-public/release/cluster-api-maas
run: |
make docker-build
make docker-push
-
name: Build Image - FIPS Mode
env:
FIPS_ENABLE: yes
REGISTRY: gcr.io/spectro-images-public/release-fips/cluster-api-maas
run: |
make docker-build
make docker-push
-
name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.release_version }}-spectro
release_name: Release v${{ github.event.inputs.release_version }}-spectro
body: |
Release version ${{ github.event.inputs.release_version }}
draft: false
prerelease: false
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

ARG CRYPTO_LIB
ENV GOEXPERIMENT=${CRYPTO_LIB:+boringcrypto}
# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY pkg/ pkg/
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go

RUN if [ ${CRYPTO_LIB} ]; \
then \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-linkmode=external -extldflags=-static" -a -o manager main.go ;\
else \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go ;\
fi

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ BUILD_DIR :=_build
RELEASE_DIR := _build/release
DEV_DIR := _build/dev
REPO_ROOT := $(shell git rev-parse --show-toplevel)
FIPS_ENABLE ?= ""

RELEASE_LOC := release
ifeq ($(FIPS_ENABLE),yes)
RELEASE_LOC := release-fips
endif

# Image URL to use all building/pushing image targets
IMAGE_NAME := cluster-api-provider-maas-controller
IMG_URL ?= gcr.io/spectro-dev-public/release/cluster-api
IMG_TAG ?= spectro-v0.2.0-v1beta1-20230517.0809
IMG ?= ${IMG_URL}/${IMAGE_NAME}:${IMG_TAG}
REGISTRY ?= gcr.io/spectro-dev-public/${RELEASE_LOC}/cluster-api
SPECTRO_VERSION ?= 4.0.0-dev
IMG_TAG ?= v0.2.0-spectro-${SPECTRO_VERSION}
IMG ?= ${REGISTRY}/${IMAGE_NAME}:${IMG_TAG}

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

# Build the docker image
docker-build: #test
docker build . -t ${IMG}
docker build --build-arg CRYPTO_LIB=${FIPS_ENABLE} . -t ${IMG}

# Push the docker image
docker-push: ## Push the docker image to gcr
Expand Down

0 comments on commit 9e0f905

Please sign in to comment.