Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply our customizations on top of upstream release-2.7 #612

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
version: 2.1
orbs:
go: circleci/go@1.11.0

jobs:
test:
resource_class: large
executor:
name: go/default
tag: "1.22.3"
steps:
- checkout
- go/load-cache
- go/mod-download
- run:
command: make setup-envtest
- go/save-cache
- run:
command: make test

build:
machine:
image: "ubuntu-2204:2024.05.1"
environment:
ALL_ARCH: "amd64 arm64"
REGISTRY_AZURE: gsoci.azurecr.io/giantswarm
REGISTRY_QUAY: quay.io/giantswarm
REGISTRY_CHINA: giantswarm-registry.cn-shanghai.cr.aliyuncs.com/giantswarm
steps:
- checkout

- run:
name: Ensure 'make generate' matches commit
command: |
make generate
git diff --exit-code || { echo "There are differences in generated files. Please run and commit 'make generate'. Else we can run into CRDs mismatching the code."; exit 1; }

- run:
name: Build the CAPA docker images
command: |
for registry in $REGISTRY_AZURE $REGISTRY_QUAY $REGISTRY_CHINA; do
make docker-build-all ALL_ARCH="$ALL_ARCH" TAG=$CIRCLE_SHA1 REGISTRY=$registry

if [ -n "$CIRCLE_TAG" ]; then
echo "Building tag $CIRCLE_TAG"
make docker-build-all ALL_ARCH="$ALL_ARCH" TAG="$CIRCLE_TAG" REGISTRY=$registry
fi
done

- run:
name: Push to Azure
command: |
docker login --username $ACR_GSOCI_USERNAME --password $ACR_GSOCI_PASSWORD "${REGISTRY_AZURE%/*}"

make docker-push-all ALL_ARCH="$ALL_ARCH" TAG=$CIRCLE_SHA1 REGISTRY=$REGISTRY_AZURE

if [ -n "$CIRCLE_TAG" ]; then
echo "Pushing tag $CIRCLE_TAG"
make docker-push-all ALL_ARCH="$ALL_ARCH" TAG="$CIRCLE_TAG" REGISTRY=$REGISTRY_AZURE
fi

- run:
name: Push to quay
command: |
docker login --username $QUAY_USERNAME --password $QUAY_PASSWORD quay.io

make docker-push-all ALL_ARCH="$ALL_ARCH" TAG=$CIRCLE_SHA1 REGISTRY=$REGISTRY_QUAY

if [ -n "$CIRCLE_TAG" ]; then
echo "Pushing tag $CIRCLE_TAG"
make docker-push-all ALL_ARCH="$ALL_ARCH" TAG="$CIRCLE_TAG" REGISTRY=$REGISTRY_QUAY
fi

- run:
name: Push to aliyun
command: |
for n in $(seq 1 5); do
(
set -eu
docker login --username $ALIYUN_USERNAME --password $ALIYUN_PASSWORD giantswarm-registry.cn-shanghai.cr.aliyuncs.com

make docker-push-all ALL_ARCH="$ALL_ARCH" TAG=$CIRCLE_SHA1 REGISTRY=$REGISTRY_CHINA

if [ -n "${CIRCLE_TAG:-}" ]; then
echo "Pushing tag $CIRCLE_TAG"
make docker-push-all ALL_ARCH="$ALL_ARCH" TAG="$CIRCLE_TAG" REGISTRY=$REGISTRY_CHINA
fi
) || { echo "Failed attempt ${n}"; sleep 30; continue; }

echo "Succeeded in attempt ${n}"
exit 0
done

exit 1

workflows:
version: 2
build_and_update:
jobs:
- build:
context:
- architect
filters:
tags:
only: /^v.*/
- test
56 changes: 39 additions & 17 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
# As opposed to https://github.com/kubernetes-sigs/cluster-api (CAPI), the CAPA upstream project does not offer
# a GitHub action to automatically create releases from tags (as of 2023-08-21). Therefore, this is a Giant Swarm
# fork-specific addition. We require a GitHub release containing the YAML manifests which we use in
# cluster-api-provider-aws-app. Since doing this manually is very error-prone (see
# `docs/book/src/development/releasing.md`), we run the needed commands here.

name: release

on:
push:
tags:
- 'v*'
- 'v*'

permissions:
contents: write # required to write to github release.
contents: write # allow creating a release

jobs:
release:
build:
name: Create draft release
runs-on: ubuntu-latest
env:
GH_ORG_NAME: giantswarm
steps:
- name: Set env
run: |
if echo "${GITHUB_REF}" | grep -qF "vX.Y"; then
>&2 echo "ERROR: Oops, you copy-pasted verbatim from the README.md - please ensure to replace 'vX.Y.Z' with an actual tag"
exit 1
fi

echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV # strip off `refs/tags/` prefix

- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Set version info
run: |
echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "PREVIOUS_VERSION=$(git describe --abbrev=0 2> /dev/null)" >> $GITHUB_ENV
echo "RELEASE_BRANCH=release-$(echo ${GITHUB_REF_NAME} | grep -Eo '[0-9]\.[0-9]+')" >> $GITHUB_ENV
echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Run release
run: |
echo "Version is: $VERSION"
echo "Previous version is: $PREVIOUS_VERSION"
echo "Release branch is: $RELEASE_BRANCH"
echo "Release tag is: $RELEASE_TAG"
make release
cache-dependency-path: |
./go.sum
./hack/tools/go.sum

- name: Generate release artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: "unused" # since we create the release without using CAPA's Makefile target
run: |
make REGISTRY="registry.k8s.io/cluster-api-aws" RELEASE_TAG="${RELEASE_TAG}" release-manifests

# Instead of `make VERSION="${RELEASE_TAG}" create-gh-release upload-gh-artifacts`, which requires GitHub CLI
# authentication, use an action which does the same.
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # tag=v1
with:
draft: true
files: out/*
body: "This fork does not provide release changelogs."
# `name` not needed since this takes the tag by default (which we also use above as ${RELEASE_TAG})
Loading
Loading