Skip to content

Commit

Permalink
switch to run pipeline for tagged releases
Browse files Browse the repository at this point in the history
  • Loading branch information
radTuti committed Dec 19, 2024
1 parent e768b15 commit ca8efd8
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 49 deletions.
11 changes: 0 additions & 11 deletions .semaphore/push_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,3 @@ blocks:
- name: Build
commands:
- make cd CONFIRM=true;
- make maybe-build-release;

promotions:
- name: Clean Up
pipeline_file: clean_up.yml
# Auto promote to clean up since this likely wasn't promoted from the CI pipeline (since we only promote to the
# clean up pipeline if we're not running on master or a release branch).
# We only auto promote if the cd has passed, because if it's failed we'll likely just want to run CD again, but if
# we've cleared the cache it will take a long time.
auto_promote:
when: "result = 'passed'"
71 changes: 71 additions & 0 deletions .semaphore/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: v1.0
name: Operator CD
agent:
machine:
type: f1-standard-2
os_image: ubuntu2004
global_job_config:
secrets:
- name: docker-hub
- name: oss-release-secrets
# Mount the github SSH secret for pulling private repositories.
- name: private-repo
prologue:
commands:
- echo $DOCKERHUB_PASSWORD | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
# Correct permissions since they are too open by default:
- chmod 0600 ~/.keys/*
# Add the key to the ssh agent:
- ssh-add ~/.keys/*
# Free up some space
- sudo rm -rf ~/.kiex ~/.phpbrew ~/.rbenv ~/.nvm ~/.kerl
# Semaphore mounts a copy-on-write FS as /var/lib/docker in order to provide a pre-loaded cache of
# some images. However, the cache is not useful to us and the copy-on-write FS is a big problem given
# how much we churn docker containers during testing. Disable it.
- sudo systemctl stop docker
- sudo umount /var/lib/docker && sudo killall qemu-nbd || true
- sudo systemctl start docker
- checkout
# Restore all the build specific caches
- "cache restore bin-amd64-${SEMAPHORE_GIT_SHA}"
- "cache restore go-pkg-cache-amd64-${SEMAPHORE_GIT_SHA}"
- "cache restore go-mod-cache-amd64-${SEMAPHORE_GIT_SHA}"
- "cache restore bin-arm64-${SEMAPHORE_GIT_SHA}"
- "cache restore go-pkg-cache-arm64-${SEMAPHORE_GIT_SHA}"
- "cache restore go-mod-cache-arm64-${SEMAPHORE_GIT_SHA}"
- "cache restore bin-ppc64le-${SEMAPHORE_GIT_SHA}"
- "cache restore go-pkg-cache-ppc64le-${SEMAPHORE_GIT_SHA}"
- "cache restore go-mod-cache-ppc64le-${SEMAPHORE_GIT_SHA}"
- "cache restore bin-s390x-${SEMAPHORE_GIT_SHA}"
- "cache restore go-pkg-cache-s390x-${SEMAPHORE_GIT_SHA}"
- "cache restore go-mod-cache-s390x-${SEMAPHORE_GIT_SHA}"

blocks:
- name: Release
run:
when: "tag =~ '^v'"
task:
secrets:
- name: quay-robot-semaphore_v2
- name: operator-redhat-connect
prologue:
commands:
- docker login -u="$QUAY_USERNAME" -p="$QUAY_TOKEN" quay.io;
- export BRANCH_NAME=$SEMAPHORE_GIT_BRANCH
jobs:
- name: Publish Release
commands:
- make release-tag RELEASE_TAG=${SEMAPHORE_GIT_RELEASE_TAG}
env_vars:
- name: CONFIRM
value: "true"

promotions:
- name: Clean Up
pipeline_file: clean_up.yml
# Auto promote to clean up since this likely wasn't promoted from the CI pipeline (since we only promote to the
# clean up pipeline if we're not running on master or a release branch).
# We only auto promote if the cd has passed, because if it's failed we'll likely just want to run CD again, but if
# we've cleared the cache it will take a long time.
auto_promote:
when: "result = 'passed'"
13 changes: 11 additions & 2 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,17 @@ blocks:
# reset so it looks like we haven't committed yet
- git reset --soft $(git merge-base $SEMAPHORE_GIT_BRANCH HEAD)
- make pre-commit
- name: 'Build amd64'
dependencies: ["Pre-commit verification"]
# Clear the cache before starting the build
# This is to ensure we clean up cache from previous runs.
- name: Clear Entire Cache
dependencies: []
task:
jobs:
- name: Clear Entire Cache
commands:
- "cache clear"
- name: "Build amd64"
dependencies: ["Pre-commit verification", "Clear Entire Cache"]
task:
jobs:
- name: Build amd64
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,15 @@ endif
###############################################################################
# Release
###############################################################################
## Determines if we are on a tag and if so builds a release.
maybe-build-release:
./hack/maybe-build-release.sh
VERSION_REGEX := ^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?(\+[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$$
release-tag: var-require-all-RELEASE_TAG-GITHUB_TOKEN
$(eval VALID_TAG := $(shell echo $(RELEASE_TAG) | grep -Eq "$(VERSION_REGEX)" && echo true))
$(if $(VALID_TAG),,$(error $(RELEASE_TAG) is not a valid version. Please use a version in the format vX.Y.Z))
$(MAKE) release release-publish-images VERSION=$(RELEASE_TAG)
# Only create a release if the tag is vX.Y.Z
$(eval GITHUB_RELEASE := $(shell echo $(RELEASE_TAG) | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+$$' && echo true))
$(if $(GITHUB_RELEASE), $(MAKE) release-github VERSION=$(RELEASE_TAG))


release-notes: var-require-all-VERSION-GITHUB_TOKEN clean
@docker build -t tigera/release-notes -f build/Dockerfile.release-notes .
Expand Down
33 changes: 0 additions & 33 deletions hack/maybe-build-release.sh

This file was deleted.

0 comments on commit ca8efd8

Please sign in to comment.