Release Tag Creator #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Tag Creator | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_branches: | |
description: Branches to tag (Separate branches by commas) | |
required: true | |
default: v1.73,v2.4,v2.11 | |
type: string | |
bump_next_version: | |
description: Bump to next version after creating release tag | |
required: true | |
default: true | |
type: boolean | |
jobs: | |
initialize: | |
name: Initialize | |
runs-on: ubuntu-latest | |
outputs: | |
branches: ${{ env.branches }} | |
steps: | |
- name: Prepare script to var | |
id: script_convert | |
run: | | |
cat <<-EOF > conversor.py | |
import sys, json | |
branch_arg = sys.argv[1] | |
branches = branch_arg.split(',') | |
print(json.dumps(branches)) | |
EOF | |
- name: Set Branch | |
id: branches | |
env: | |
TAG_BRANCHES: ${{ github.event.inputs.tag_branches }} | |
run: | | |
BRANCHES=$(python conversor.py $TAG_BRANCHES) | |
echo "branches=$BRANCHES" >> $GITHUB_ENV | |
release_tag: | |
needs: [initialize] | |
runs-on: ubuntu-latest | |
strategy: | |
# Allow other branches to continue even if one of the branches failed | |
fail-fast: false | |
matrix: | |
branch: ${{fromJson(needs.initialize.outputs.branches)}} | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v5 | |
with: | |
ref: ${{matrix.branch}} | |
# We need to fetch the full history to determine the latest tag | |
fetch-depth: 0 | |
- name: Configure git | |
run: | | |
git config user.email '[email protected]' | |
git config user.name 'kiali-bot' | |
- name: Create Release Tag in kiali/openshift-servicemesh-plugin | |
run: | | |
RELEASE_VERSION=$(sed -rn 's/^VERSION \?= (.*)/\1/p' Makefile) | |
LATEST_TAG=$(git describe --tags --abbrev=0) | |
# Check if the latest tag is the current ossm version tag | |
if [[ "$LATEST_TAG" == "$RELEASE_VERSION-ossm" ]]; then | |
# Delete the ossm version tag | |
echo "Deleting existing ossm version tag: $RELEASE_VERSION-ossm" | |
git push origin --delete refs/tags/$RELEASE_VERSION-ossm | |
# Create the release tag | |
echo "Creating release tag $RELEASE_VERSION" | |
git push origin $(git rev-parse HEAD):refs/tags/$RELEASE_VERSION | |
else | |
echo "Error: Latest tag $LATEST_TAG does not match expected $RELEASE_VERSION-ossm tag" | |
exit 1 | |
fi | |
bump_version: | |
name: Bump to Next Version | |
needs: [initialize, release_tag] | |
# Allow other branches to bump to the next version even if one of the branches failed to create the release tag | |
if: ${{ inputs.bump_next_version && always() }} | |
uses: ./.github/workflows/bump-release-version.yml | |
with: | |
tag_branches: ${{ inputs.tag_branches }} |