Skip to content

Commit

Permalink
ci: update release job and drop semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
a-cordier committed Jun 11, 2024
1 parent f244b6e commit 4ecbea6
Show file tree
Hide file tree
Showing 15 changed files with 486 additions and 301 deletions.
186 changes: 150 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@ orbs:
keeper: gravitee-io/[email protected]
gravitee: gravitee-io/[email protected]
slack: circleci/[email protected]
gh: circleci/[email protected]

parameters:
go-version:
type: string
default: "1.22.1"
trigger:
type: enum
default: test
enum:
- release
- test
release-version:
type: string
default: ""
latest:
type: boolean
default: false
description: Is this version the latest version available ?
dry-run:
type: boolean
default: false

executors:
azure-cli:
parameters:
resource_class:
description: The resource class
type: enum
enum: ["small", "medium", "large", "xlarge"]
default: "medium"
docker:
# Version can be found here https://docs.microsoft.com/en-us/cli/azure/release-notes-azure-cli
# be careful when updating the version as it looks it is not following semver
- image: mcr.microsoft.com/azure-cli:2.61.0
resource_class: <<parameters.resource_class>>
resource_class: small

commands:
notify-on-failure:
Expand Down Expand Up @@ -242,7 +251,6 @@ jobs:
login-to-azure:
executor:
name: azure-cli
resource_class: small
parameters:
clusterName:
type: enum
Expand Down Expand Up @@ -341,38 +349,140 @@ jobs:
- go/save-cache
- notify-on-failure

semantic-release:
release:
docker:
- image: cimg/go:<< pipeline.parameters.go-version >>-node
environment:
GITHUB_TOKEN: "keeper://TIlcGPFq4rN5GvgnZb9hng/field/password"
GIT_AUTHOR_NAME: "keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login"
GIT_AUTHOR_EMAIL: "keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email"
GIT_COMMITTER_NAME: "keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login"
GIT_COMMITTER_EMAIL: "keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email"
DOCKER_USERNAME: "keeper://cooU9UoXIk8Kj0hsP2rkBw/field/login"
DOCKER_TOKEN: "keeper://cooU9UoXIk8Kj0hsP2rkBw/field/password"
steps:
- checkout
- gravitee/install-semantic-release
- setup_remote_docker
- keeper/exec:
step-name: Docker login
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login
var-name: GIT_AUTHOR_NAME
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email
var-name: GIT_AUTHOR_EMAIL
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login
var-name: GIT_COMMITTER_NAME
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email
var-name: GIT_COMMITTER_EMAIL
- keeper/env-export:
secret-url: keeper://cooU9UoXIk8Kj0hsP2rkBw/field/login
var-name: DOCKER_USERNAME
- keeper/env-export:
secret-url: keeper://cooU9UoXIk8Kj0hsP2rkBw/field/password
var-name: DOCKER_TOKEN
- keeper/env-export:
secret-url: keeper://hfnQD5TEfxzwRXUKhJhM-A/field/password
var-name: JIRA_TOKEN
- run:
name: Switch to release branch
command: |
export RELEASE_BRANCH=$(npx zx scripts/get-release-branch.mjs --version << pipeline.parameters.release-version >>)
echo "Switching to branch $RELEASE_BRANCH"
git fetch
git switch $RELEASE_BRANCH 2>/dev/null || git switch -c $RELEASE_BRANCH
- run:
name: Docker login
command: docker login --username="${DOCKER_USERNAME}" -p="${DOCKER_TOKEN}"
- run:
name: Install operator SDK
name: Build Docker image for version << pipeline.parameters.release-version >>
command: |
export OPERATOR_SDK_RELEASE_VERSION=v1.23.0
export ARCH=$(case $(uname -m) in amd64|x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export DOWNLOAD_URL=https://github.com/operator-framework/operator-sdk/releases/latest/download
export BINARY=operator-sdk_${OS}_${ARCH}
curl -OJL ${DOWNLOAD_URL}/${BINARY}
chmod +x ${BINARY} && sudo cp ${BINARY} /usr/local/bin/operator-sdk && rm ${BINARY}
docker build -t graviteeio/kubernetes-operator:<< pipeline.parameters.release-version >> .
- when:
condition: << pipeline.parameters.latest >>
steps:
- run:
name: Tag << pipeline.parameters.release-version >> image as latest
command: |
docker tag \
graviteeio/kubernetes-operator:<< pipeline.parameters.release-version >> \
graviteeio/kubernetes-operator:latest
- when:
condition:
and:
- not: << pipeline.parameters.dry-run >>
- << pipeline.parameters.latest >>
steps:
- run:
name: Push << pipeline.parameters.release-version >> Docker image as latest tag
command: |
docker push graviteeio/kubernetes-operator:<< pipeline.parameters.release-version >>
docker push graviteeio/kubernetes-operator:latest
- when:
condition:
and:
- not: << pipeline.parameters.dry-run >>
- not: << pipeline.parameters.latest >>
steps:
- run:
name: Push << pipeline.parameters.release-version >> Docker image tag
command: |
docker push graviteeio/kubernetes-operator:<< pipeline.parameters.release-version >>
- helm/install_helm_client
- keeper/exec:
step-name: "Run Semantic Release"
command: npx semantic-release
- when:
condition: << pipeline.parameters.dry-run >>
steps:
- run:
name: Dry run release Helm chart
command: |
npx zx scripts/release-helm-chart.mjs --dry-run --version << pipeline.parameters.release-version >>
- when:
condition:
not: << pipeline.parameters.dry-run >>
steps:
- run:
name: Release Helm chart
command: |
npx zx scripts/release-helm-chart.mjs --version << pipeline.parameters.release-version >>
- run:
name: Commit and tag release
command: |
make add-license > /dev/null
git add helm/gko/Chart.yaml
git commit -m "ci: release version << pipeline.parameters.release-version >> [skip ci]"
git tag << pipeline.parameters.release-version >>
echo
git diff HEAD~1 HEAD
- when:
condition:
not: << pipeline.parameters.dry-run >>
steps:
- run:
name: Push release tag and commit
command: |
export RELEASE_BRANCH=$(npx zx scripts/get-release-branch.mjs --version << pipeline.parameters.release-version >>)
git push -u origin $RELEASE_BRANCH
git push --tags origin $RELEASE_BRANCH
- run:
name: Generate Changelog
command: npx zx scripts/generate-changelog.mjs --version << pipeline.parameters.release-version >> > /tmp/CHANGELOG.md
- when:
condition: << pipeline.parameters.dry-run >>
steps:
- run:
name: Print Changelog
command: cat /tmp/CHANGELOG.md
- run:
name: Generate Release Artifacts
command: |
cp -r helm/gko/crds /tmp/crds
pushd /tmp/crds
zip -r /tmp/custom-resource-definitions.zip ./*
popd
- when:
condition:
not: << pipeline.parameters.dry-run >>
steps:
- gh/setup
- run:
name: Publish Github Release << pipeline.parameters.release-version >>
command: |
gh release create --latest << pipeline.parameters.release-version >> /tmp/custom-resource-definitions.zip -F /tmp/CHANGELOG.md
notify-release-slack:
docker:
Expand Down Expand Up @@ -462,6 +572,10 @@ workflows:
and:
- not:
equal: [master, << pipeline.git.branch >>]
- not:
equal: ['release', << pipeline.parameters.trigger >>]
- not:
equal: ['test', << pipeline.parameters.trigger >>]
jobs:
- lint-sources:
name: Lint sources
Expand Down Expand Up @@ -550,10 +664,10 @@ workflows:

release:
when:
equal: [trigger-release, << pipeline.git.branch >>]
equal: ['release', << pipeline.parameters.trigger >>]
jobs:
- semantic-release:
name: Semantic Release
- release:
name: Release
context: cicd-orchestrator

notify-release:
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/clean-release.yml

This file was deleted.

39 changes: 26 additions & 13 deletions .github/workflows/trigger-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,34 @@

name: Trigger Release

on: workflow_dispatch

on:
workflow_dispatch:
inputs:
version:
description: 'Which version should we release ?'
required: true
type: string
latest:
description: 'Is this version the latest version ?'
required: false
default: false
type: boolean
dry-run:
description: 'Should this run as a dry run ?'
required: true
default: true
type: boolean
jobs:
trigger-release:
runs-on: ubuntu-latest
env:
VERSION: ${{ inputs.version }}
LATEST: ${{ inputs.latest }}
DRY_RUN: ${{ inputs.dry-run }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Set up git"
run: |
git config user.name "Gravitee.io Bot"
git config user.email [email protected]
- name: "Create release branch"
- name: "Trigger release pipeline"
run: |
echo "🚀 Creating release branch"
git checkout -b trigger-release
git push --set-upstream origin trigger-release
echo "🚀 Releasing version ${VERSION}"
echo " Latest: ${LATEST}"
echo " Dry run: ${DRY_RUN}"
npx zx scripts/trigger-release.mjs --version ${VERSION} --dry-run ${DRY_RUN} --latest ${LATEST}
10 changes: 0 additions & 10 deletions make/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@ docker-build: ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${IMG}:${TAG}

# RELEASE

.PHONY: docker-build-release
docker-build-release: ## Build docker image with the manager.
docker build -t ${IMG}:${TAG} -t ${IMG}:latest .

.PHONY: docker-push-release
docker-push-release: ## Push docker image with the manager.
docker push ${IMG}:${TAG}
docker push ${IMG}:latest

6 changes: 3 additions & 3 deletions make/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lint-licenses: addlicense ## Run addlicense linter and fail on error
.PHONY: add-license
add-license: addlicense ## Add license headers to files
@echo "Adding license headers ..."
$(ADDLICENSE) -f LICENSE_TEMPLATE.txt \
@$(ADDLICENSE) -f LICENSE_TEMPLATE.txt \
-ignore ".circleci/**" \
-ignore ".mergify.yml" \
-ignore "config/**" \
Expand All @@ -39,5 +39,5 @@ lint: $(ALL_LINT)

.PHONY: lint-fix
lint-fix: golangci-lint addlicense ## Fix whatever golangci-lint can fix and add licenses headers
$(GOLANGCILINT) run ./... --fix
$(MAKE) add-license
@$(GOLANGCILINT) run ./... --fix
@$(MAKE) add-license
2 changes: 1 addition & 1 deletion make/tool.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
@mkdir -p $(LOCALBIN)

## Tool Binaries
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
Expand Down
Loading

0 comments on commit 4ecbea6

Please sign in to comment.