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

fix(ci): fix release CI to work with release branches #206

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 18 additions & 8 deletions .github/workflows/__release-workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Reusable release
run-name: "Release ${{ format('{0} (type: {1})', inputs.tag, inputs.release-type) }} "
run-name: "Release ${{ format('{0} (type: {1}) (branch: {2})', inputs.tag, inputs.release-type, inputs.base) }} "

on:
workflow_call:
Expand Down Expand Up @@ -28,6 +28,11 @@ on:
description: The version to release (e.g. v1.2.3)
type: string
required: true
base:
description: The base branch from which to release and against which to create a release PR.
type: string
default: 'main'
required: false
latest:
description: Whether to mark this release latest
type: boolean
Expand Down Expand Up @@ -181,15 +186,14 @@ jobs:
- test-integration-current-kubernetes
- test-e2e-current-kubernetes
steps:
# Use the main branch as a base for the release.
# Any changes made on the branch that the workflow was triggered on will not be included
# in the release PR. If anything needs to be fixed before a release, it should be
# done on the main branch.
# Use the branch set via inputs as a base for the release.
# If anything needs to be fixed before the release, it should be done on the base branch
# before the release workflow is triggered.
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
ref: ${{ inputs.base }}

- name: Configure Git for private repositories (this is needed by repositories that include this workflow and have other private dependencies)
run: git config --global url."https://${{ secrets.gh-pat }}@github.com".insteadOf "https://github.com"
Expand Down Expand Up @@ -221,7 +225,8 @@ jobs:

# The generated bundle is part of the release PR.
# This is done locally in this job, to avoid including unintended changes.
# If anything needs to be fixed before a release, it should be done on the main branch.
# If anything needs to be fixed before the release, it should be done on the base branch
# before the release workflow is triggered.
- name: Generate bundle
if: ${{ inputs.regenerate-bundle }}
run: make bundle
Expand All @@ -234,12 +239,17 @@ jobs:
git_user_signingkey: true
git_commit_gpgsign: true

# PRs to the main branch will update the version file and manifests
# PRs to the base branch will update the version file and manifests
# NOTE: This will not update the VERSION and config on the main branch when a release
# on release branch is made.
# This could be improved to trigger PRs for both main and release branch but
# using a different commit message to not cause the release-bot.yaml to trigger.
- name: Create a release PR
uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83
with:
token: ${{ secrets.gh-pat }}
path: .
base: ${{ inputs.base }}
add-paths: |
VERSION
config
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- 'main'
- 'release/*'

jobs:
look_for_release:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
name: release
run-name: "Release ${{ format('{0} (type: {1})', inputs.tag, inputs.release_type) }} "
run-name: "Release ${{ format('{0} (type: {1}) (branch: {2})', inputs.tag, inputs.release-type, inputs.base) }} "

on:
workflow_dispatch:
inputs:
tag:
description: The version to release (e.g. v1.2.3)
required: true
base:
description: The base branch from which to release and against which to create a release PR.
type: string
default: 'main'
required: false
latest:
description: Whether to tag this build latest
type: boolean
Expand All @@ -33,5 +38,6 @@ jobs:
image-name: ${{ vars.DOCKERHUB_IMAGE_NAME }}
latest: ${{ inputs.latest }}
tag: ${{ inputs.tag }}
base: ${{ inputs.base }}
release-type: ${{ inputs.release_type }}
regenerate-manifests: true
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ go 1.22

toolchain go1.22.0

retract (
// 1.2.2 was released on main branch with a breaking change that was not
// intended to be released in 1.2.x:
// https://github.com/Kong/gateway-operator/commit/3876430e09e61edce58bd8464989e33236bd1872
// This retraction is to prevent it from being used and from breaking builds of dependent projects.
v1.2.2
)

require (
github.com/Masterminds/semver v1.5.0
github.com/cert-manager/cert-manager v1.14.4
Expand Down
Loading