Skip to content

Release

Release #141

Workflow file for this run

name: Release
on:
schedule:
# Every Monday at 08:00 (UTC) - try to make sure it happens after all Kiali-related images are released
- cron: '00 8 * * MON'
workflow_dispatch:
inputs:
release_type:
description: Release type
required: true
type: choice
options:
- minor
- patch
release_branch:
description: Branch to release
required: true
default: master
type: string
jobs:
initialize:
name: Initialize
runs-on: ubuntu-20.04
outputs:
release_type: ${{ steps.release_type.outputs.release_type }}
release_version: ${{ steps.release_version.outputs.release_version }}
next_version: ${{ steps.next_version.outputs.next_version }}
branch_version: ${{ steps.branch_version.outputs.branch_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.release_branch || github.ref_name }}
fetch-depth: 0
- name: Prepare scripts
run: |
cat <<-EOF > bump.py
import sys
release_type = sys.argv[1]
version = sys.argv[2]
parts = version.split('.')
major = int(parts[0][1:])
minor = int(parts[1])
patch = int(parts[2])
if release_type == 'major':
major = major + 1
minor = 0
patch = 0
elif release_type == 'minor':
minor = minor + 1
patch = 0
elif release_type == 'patch':
patch = patch + 1
print('.'.join(['v' + str(major), str(minor), str(patch)]))
EOF
cat <<-EOF > minor.py
import datetime
# The base date can be any end of sprint from the past
base = int(datetime.datetime.strptime("24/04/2022", "%d/%m/%Y").timestamp())
now = int(datetime.datetime.now().timestamp())
diff = now - base
days_elapsed = int(diff / (24*60*60))
weeks_elapsed = int(days_elapsed / 7)
weeks_mod3 = int(weeks_elapsed % 3)
print(weeks_mod3)
EOF
- name: Determine release type
id: release_type
run: |
if [ -z ${{ github.event.inputs.release_type }} ];
then
DO_RELEASE=$(python minor.py)
if [[ $DO_RELEASE == "1" ]]
then
echo "release_type=minor" >> $GITHUB_OUTPUT
else
echo "release_type=skip" >> $GITHUB_OUTPUT
fi
else
echo "release_type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
fi
- name: Determine release version
if: ${{ steps.release_type.outputs.release_type != 'skip' }}
env:
RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
id: release_version
run: |
RAW_VERSION=$(sed -rn 's/^VERSION \?= (.*)/\1/p' Makefile)
# Remove any pre release identifier (ie: "-SNAPSHOT")
RELEASE_VERSION=${RAW_VERSION%-*}
if [[ $RELEASE_TYPE == "patch" ]]
then
RELEASE_VERSION=$(python bump.py $RELEASE_TYPE $RELEASE_VERSION)
elif [[ $RELEASE_TYPE == "minor" ]]
then
RELEASE_VERSION=$RELEASE_VERSION
fi
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
- name: Determine next version
if: ${{ steps.release_type.outputs.release_type != 'skip' }}
env:
RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
RELEASE_VERSION: ${{ steps.release_version.outputs.release_version }}
id: next_version
run: |
if [[ $RELEASE_TYPE == "patch" ]]
then
NEXT_VERSION=$(python bump.py $RELEASE_TYPE $RELEASE_VERSION)
elif [[ $RELEASE_TYPE == "minor" ]]
then
NEXT_VERSION=$(python bump.py $RELEASE_TYPE $RELEASE_VERSION)
fi
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Determine branch version
if: ${{ steps.release_type.outputs.release_type != 'skip' }}
env:
RELEASE_VERSION: ${{ steps.release_version.outputs.release_version }}
id: branch_version
run: |
echo "branch_version=$(echo $RELEASE_VERSION | sed 's/\.[0-9]*\+$//')" >> $GITHUB_OUTPUT
- name: Log information
run: |
echo "Release version: ${{ steps.release_version.outputs.release_version }}"
echo "Next version: ${{ steps.next_version.outputs.next_version }}"
echo "Branch version: ${{ steps.branch_version.outputs.branch_version }}"
release:
name: Release
if: ${{ needs.initialize.outputs.release_type != 'skip' && ((github.event_name == 'schedule' && github.repository == 'kiali/helm-charts') || github.event_name != 'schedule') }}
runs-on: ubuntu-20.04
needs: [initialize]
env:
RELEASE_TYPE: ${{ needs.initialize.outputs.release_type }}
RELEASE_VERSION: ${{ needs.initialize.outputs.release_version }}
NEXT_VERSION: ${{ needs.initialize.outputs.next_version }}
BRANCH_VERSION: ${{ needs.initialize.outputs.branch_version }}
RELEASE_BRANCH: ${{ github.event.inputs.release_branch || github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.release_branch || github.ref_name }}
fetch-depth: 0
- name: Configure git
run: |
git config user.email 'kiali-dev@googlegroups.com'
git config user.name 'kiali-bot'
- name: Build Helm charts
run: make -e VERSION=$RELEASE_VERSION clean build-helm-charts
# Switch to `master` branch before updating docs/index.yaml
- name: Checkout master
if: ${{ github.event.inputs.release_type == 'patch'}}
run: git checkout master
# Anticipated preparation of Makefile so that it contains the released
# version when creating the git tag.
#
# This change to the Makefile is not done for patch releases, because that
# would break the next minor build (remember we have already switched to master).
- name: Prepare Makefile
if: ${{ github.event.inputs.release_type != 'patch'}}
run: sed -i -r "s/^VERSION \?= .*/VERSION \?= $RELEASE_VERSION/" Makefile
- name: Update Helm repositories
run: make -e VERSION=$RELEASE_VERSION update-helm-repos
# Tag the release from sources in the master branch
# Note that if we are doing a patch release, this tag won't contain valid `kiali-server` nor `kiali-operator` directories
# because these directories come from `master` rather than the original ones.
- name: Create tag
run: |
git add Makefile docs
git commit -m "Release $RELEASE_VERSION"
git push origin $(git rev-parse HEAD):refs/tags/$RELEASE_VERSION-master
- name: Publish Helm charts
env:
BUILD_TAG: helm-charts-release-${{ github.run_number }}-main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# If we did a minor release, we need to create the vX.Y branch, so that it can
# be used as a base for a patch release.
# Also, we create a vX.Y.Z tag.
if [[ $RELEASE_TYPE == "minor" ]]
then
git push origin $(git rev-parse HEAD):refs/heads/$BRANCH_VERSION
git push origin $(git rev-parse HEAD):refs/tags/$RELEASE_VERSION
# Bump version stored in the Makefile
sed -i -r "s/^VERSION \?= (.*)/VERSION \?= $NEXT_VERSION-SNAPSHOT/" Makefile
git add Makefile
git commit -m "Prepare for next version"
git push origin $(git rev-parse HEAD):refs/heads/$BUILD_TAG
if hack/smoke-test-release-branch.sh --release-branch $BUILD_TAG; then
prtitle="Prepare for next version (smoke test passed)"
prmsg="The smoke test has passed. Please merge to update version numbers and prepare for release $NEXT_VERSION"
else
prtitle="[DO NOT MERGE YET] Prepare for next version"
prmsg="DO NOT MERGE YET! The smoke test failed. Please fix the problem before merging this PR which updates version numbers and prepares for release $NEXT_VERSION"
fi
gh pr create -t "$prtitle" -b "$prmsg" -H $BUILD_TAG -B $RELEASE_BRANCH
# For a patch release, everything is ready to publish the generated charts.
# Let's push to master
elif [[ $RELEASE_TYPE == "patch" ]]
then
git push origin $(git rev-parse HEAD):refs/heads/$BUILD_TAG
if hack/smoke-test-release-branch.sh --release-branch $BUILD_TAG; then
prtitle="Prepare for next version (smoke test passed)"
prmsg="The smoke test has passed. Please merge to update version numbers and prepare for release $NEXT_VERSION"
else
prtitle="[DO NOT MERGE YET] Prepare for next version"
prmsg="DO NOT MERGE YET! The smoke test failed. Please fix the problem before merging this PR which updates version numbers and prepares for release $NEXT_VERSION"
fi
gh pr create -t "$prtitle" -b "$prmsg" -H $BUILD_TAG -B master
# We did a patch release. In this case we need to go back to the version branch and do changes
# to the Makefile in that branch to record what's the current path release. Then, commit and push.
# Also, a vX.Y.Z branch is created
git checkout $RELEASE_BRANCH
sed -i -r "s/^VERSION \?= (.*)/VERSION \?= $RELEASE_VERSION/" Makefile
git add Makefile
git commit -m "Record that $RELEASE_VERSION was released, in preparation for next patch version."
git push origin $(git rev-parse HEAD):$RELEASE_BRANCH
git push origin $(git rev-parse HEAD):refs/tags/$RELEASE_VERSION
fi