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

Create release workflow #236

Merged
merged 2 commits into from
Oct 9, 2023
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
36 changes: 23 additions & 13 deletions .github/scripts/test_operator.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
#!/bin/bash
set -e -a

VERSION=$(sed -n 's/^.*Version.*=.*"\(.*\)".*$/\1/p' ./version/version.go)
DASH_VERSION=$(echo "$VERSION" | sed -n 's/^[0-9\.]*-\([^-+]*\).*$/-\1/p')
if [[ ! $OPERATOR_VERSION ]]; then
OPERATOR_VERSION=$(sed -n 's/.*Version.*=.*"\(.*\)".*/\1/p' ./version/version.go)
fi
OPERATOR_VERSION_SUFFIX=$(echo "$OPERATOR_VERSION" | sed -n 's/^[0-9\.]*-\([^-+]*\).*$/-\1/p')

echo $VERSION
echo $DASH_VERSION
if [[ ! $OPERAND_VERSION ]]; then
OPERAND_VERSION="2.x"
fi
LC_OPERAND_VERSION=$(echo $OPERAND_VERSION | tr A-Z a-z)

OPERATOR_IMAGE="quay.io/apicurio/apicurio-registry-operator:$VERSION"
CSV_VERSION=1.1.0-dev-v2.x
OPERATOR_METADATA_IMAGE="quay.io/apicurio/apicurio-registry-operator-bundle:$CSV_VERSION"
OLM_CSV="apicurio-registry-operator.v$CSV_VERSION"
CATALOG_SOURCE_IMAGE="quay.io/apicurio/apicurio-registry-operator-catalog:latest$DASH_VERSION"
if [[ ! $OPERATOR_IMAGE_REPOSITORY ]]; then
OPERATOR_IMAGE_REPOSITORY="quay.io/apicurio"
fi

BUNDLE_URL=${PWD}/dist/install.yaml
OPERATOR_PROJECT_DIR=${PWD}
PACKAGE_VERSION="$OPERATOR_VERSION-v$LC_OPERAND_VERSION"

OPERATOR_IMAGE="$OPERATOR_IMAGE_REPOSITORY/apicurio-registry-operator:$OPERATOR_VERSION"
BUNDLE_IMAGE="$OPERATOR_IMAGE_REPOSITORY/apicurio-registry-operator-bundle:$PACKAGE_VERSION"
CATALOG_IMAGE="$OPERATOR_IMAGE_REPOSITORY/apicurio-registry-operator-catalog:latest$OPERATOR_VERSION_SUFFIX"

OPERATOR_PROJECT_DIR=$(pwd)

make dist

git clone https://github.com/Apicurio/apicurio-registry-k8s-tests-e2e.git

pushd apicurio-registry-k8s-tests-e2e

git checkout master
./scripts/install_kind.sh

make run-operator-ci

popd

git reset --hard
git clean -df
rm -rf apicurio-registry-k8s-tests-e2e dist

set +e +a
10 changes: 4 additions & 6 deletions .github/workflows/build-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on: [ pull_request ]

env:
IMAGE_REGISTRY: quay.io
IMAGE_REGISTRY_ORG: apicurio

jobs:
test:
name: Build and test a pull request
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio'
steps:
- uses: actions/checkout@v3

Expand All @@ -19,19 +19,17 @@ jobs:
- run: go version

- name: Setup the environment
run: ./.github/scripts/setup.sh
run: .github/scripts/setup.sh

- name: Build
id: build
run: make build bundle bundle-build

- name: Test
id: test
run: CI_BUILD=true ./.github/scripts/test_operator.sh
run: CI_BUILD=true .github/scripts/test_operator.sh

- name: Collect logs
if: failure()
run: ./.github/scripts/collect_logs.sh
run: .github/scripts/collect_logs.sh

- name: Upload tests logs artifacts
if: failure()
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/publish-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:

env:
IMAGE_REGISTRY: quay.io
IMAGE_REGISTRY_ORG: apicurio

# TODO Regenerate install/install.yaml file
jobs:
main:
name: Build and publish from main
Expand All @@ -18,31 +18,31 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '^1.16.8'
go-version: '^1.17.10'
- run: go version

- name: Setup the environment
run: ./.github/scripts/setup.sh
run: .github/scripts/setup.sh

- name: Setup Docker
run: |
docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" "${IMAGE_REGISTRY}"

- name: Build
id: build
run: make all
run: make build bundle bundle-build dist

- name: Test Before
run: CI_BUILD=true .github/scripts/test_operator.sh

- name: Publish
id: publish
run: make all-push
run: make docker-push bundle-push catalog-build catalog-push

- name: Test
id: test
run: ./.github/scripts/test_operator.sh
- name: Test After
run: .github/scripts/test_operator.sh

- name: Collect logs
if: failure()
run: ./.github/scripts/collect_logs.sh
run: .github/scripts/collect_logs.sh

- name: Upload tests logs artifacts
if: failure()
Expand Down
100 changes: 0 additions & 100 deletions .github/workflows/release-api-model.yaml

This file was deleted.

128 changes: 128 additions & 0 deletions .github/workflows/release-phase1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Release Phase 1 - Prepare release branch, build, test, and push images
on:
workflow_dispatch:
inputs:
operator-release-version:
description: Operator version being released
operand-release-version:
description: Operand version to use
required: true
branch:
description: Branch to release from
required: true
default: main
release-branch:
description: Branch used during the release
required: true
default: release
debug:
type: boolean
description: Debug with tmate on failure

env:
IMAGE_REGISTRY: quay.io
EXTRA_CHECKS: "true"
OPERAND_VERSION: ${{ github.event.inputs.operand-release-version }}
RELEASE_BRANCH: ${{ github.event.inputs.release-branch }}

jobs:
release:
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio'
steps:

- name: Checkout the Operator repository
run: |
git init
git config user.name apicurio-ci
git config user.email [email protected]
git remote add origin "https://apicurio-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apicurio/apicurio-registry-operator.git"
git fetch
git checkout --track "origin/${{ github.event.inputs.branch }}"
git checkout -b "$RELEASE_BRANCH"

- name: Configure env. variables
run: |
if [[ -z "${{ github.event.inputs.operator-release-version }}" ]]; then
echo "OPERATOR_VERSION=$(make get-variable-operator-version-prefix)" >> "$GITHUB_ENV"
else
echo "OPERATOR_VERSION=${{ github.event.inputs.operator-release-version }}" >> "$GITHUB_ENV"
fi

- name: Run make info
run: make info

- name: Update operator and operand versions
run: |
make release-set-operator-version
git add .
git commit -m "release: update operator version"
make release-set-operand-version
git add .
git commit -m "release: update operand version"

- name: Setup go 1.17.10
uses: actions/setup-go@v2
with:
go-version: ^1.17.10
- run: go version

- name: Configure go
run: .github/scripts/setup.sh

- name: Build operator image
run: make build

- name: Commit after build
run: |
git add .
git commit -m "release: update resources"

- name: Run e2e test
run: |
CI_BUILD=true EXTRA_CHECKS=false .github/scripts/test_operator.sh

- name: Bundle
run: make bundle bundle-build

- name: Commit bundle
run: |
git add -f bundle.Dockerfile bundle
git commit -m "release: bundle"

- name: Setup Docker
run: docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" "$IMAGE_REGISTRY"

- name: Publish operator and bundle images
run: make docker-push bundle-push

- name: Build and publish catalog image
run: make catalog-build catalog-push

- name: Generate dist
run: |
RELEASE=true make dist
git add -f dist
git add .
git commit -m "release: dist"

- name: Run e2e tests with release images
run: .github/scripts/test_operator.sh

- name: Push the release branch
run: git push origin "$RELEASE_BRANCH"

- name: Collect logs
if: failure()
run: .github/scripts/collect_logs.sh

- name: Upload tests logs artifacts
if: failure()
uses: actions/[email protected]
with:
name: tests-logs
path: artifacts

- name: Setup tmate session
if: failure() && inputs.debug
uses: mxschmitt/action-tmate@v3
Loading