Skip to content

Commit

Permalink
ci: minor release improvements (#28)
Browse files Browse the repository at this point in the history
Make the PR release title correct by default.
Make the GH release title correct by default.
Avoid setting the `latest` label in every new GH release.
Set the plain container image as the `latest` tag.

Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei authored Mar 26, 2024
1 parent 048df79 commit c6e26ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: |
TAG=${GITHUB_REF##*/}
DEST=$(echo ${TAG#v} | awk -F '[.]' '{print "release-"$1"."$2}')
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "TAG=${TAG#v}" >> $GITHUB_ENV
echo "DEST=${DEST}" >> $GITHUB_ENV
-
name: Pull Request
Expand All @@ -30,4 +30,4 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_body: "Automated PR. Will trigger the ${{ env.TAG }} release when approved."
pr_label: release
pr_title: "feat: release ${{ env.TAG }}"
pr_title: "Version tag to ${{ env.TAG }}"
38 changes: 27 additions & 11 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,29 @@ permissions:

jobs:

check-branch:
name: Evaluate release tag
runs-on: ubuntu-22.04
outputs:
is_latest: ${{ env.IS_LATEST }}
steps:
-
name: Check release branch
run: |
tag="${GITHUB_REF#refs/tags/v}"
latest_release_branch=$(git branch -rl 'origin/release-*' | sort -r | head -n1 | sed -e 's/^.*\(release-.*\)/\1/')
current_release_branch=$(echo "${tag}" | sed -e 's/\([0-9]\+.[0-9]\+\).*/release-\1/')
is_latest="false"
if [[ "$latest_release_branch" == "$current_release_branch" ]]; then
is_latest="true"
fi
echo "IS_LATEST=${is_latest}" >> $GITHUB_ENV
release:
name: Create Github release
runs-on: ubuntu-22.04
needs:
- check-branch
steps:
-
name: Checkout
Expand All @@ -46,14 +66,17 @@ jobs:
with:
body_path: release_notes.md
draft: false
name: Release ${{ env.TAG }}
name: v${{ env.TAG }}
files: releases/cnpg-${{ env.VERSION }}.yaml
make_latest: ${{ steps.check-branch.outputs.is_latest }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-binaries:
name: Build containers
runs-on: ubuntu-22.04
needs:
- check-branch
outputs:
version: ${{ steps.build-meta.outputs.version }}
author_name: ${{ steps.build-meta.outputs.author_name }}
Expand Down Expand Up @@ -81,13 +104,6 @@ jobs:
images="${images},ghcr.io/cloudnative-pg/cloudnative-pg-testing"
commit_sha=${{ github.sha }}
commit_date=$(git log -1 --pretty=format:'%ad' --date short "${commit_sha}")
tag="${GITHUB_REF#refs/tags/v}"
skip_krew="false"
latest_release_branch=$(git branch -rl 'origin/release-*' | sort -r | head -n1 | sed -e 's/^.*\(release-.*\)/\1/')
current_release_branch=$(echo "${tag}" | sed -e 's/\([0-9]\+.[0-9]\+\).*/release-\1/')
if [[ "$latest_release_branch" != "$current_release_branch" ]]; then
skip_krew="true"
fi
# get git user and email
author_name=$(git show -s --format='%an' "${commit_sha}")
Expand All @@ -100,7 +116,6 @@ jobs:
echo "DATE=${commit_date}" >> $GITHUB_ENV
echo "version=${commit_version}" >> $GITHUB_OUTPUT
echo "COMMIT=${commit_short}" >> $GITHUB_ENV
echo "SKIP_KREW=${skip_krew}" >> $GITHUB_ENV
echo "author_name=${author_name}" >> $GITHUB_OUTPUT
echo "author_email=${author_email}" >> $GITHUB_OUTPUT
-
Expand Down Expand Up @@ -130,7 +145,7 @@ jobs:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
-
name: Publish Krew
if: ${{ env.SKIP_KREW == 'false' }}
if: ${{ steps.check-branch.outputs.is_latest == 'true' }}
uses: rajatjindal/[email protected]
with:
krew_template_file: dist/krew/cnpg.yaml
Expand All @@ -149,6 +164,7 @@ jobs:
with:
images: ${{ env.IMAGES }}
flavor: |
latest=false
suffix=-ubi8
tags: |
type=semver,pattern={{version}}
Expand All @@ -159,6 +175,7 @@ jobs:
with:
images: ${{ env.IMAGES }}
flavor: |
latest=false
suffix=-ubi9
tags: |
type=semver,pattern={{version}}
Expand Down Expand Up @@ -353,7 +370,6 @@ jobs:
--
<sup>1</sup> If you feel your Operator does not fit any of the pre-defined categories, file an issue against this repo and explain your need
<sup>2</sup> For more information see [here](https://sdk.operatorframework.io/docs/overview/#operator-capability-level)
publish_bundle:
name: Publish OLM Bundle
Expand Down

0 comments on commit c6e26ca

Please sign in to comment.