Skip to content

Release

Release #104

Workflow file for this run

name: Release
on:
schedule:
# Every Monday at 07:00 (UTC)
- cron: '00 7 * * MON'
workflow_dispatch:
inputs:
release_branch:
description: Branch to release
required: true
default: staging
type: string
jobs:
initialize:
name: Initialize
runs-on: ubuntu-20.04
outputs:
release_type: ${{ steps.release_type.outputs.release_type }}
releasing_version: ${{ steps.releasing_version.outputs.releasing_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.release_branch || github.ref_name }}
- 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: |
DO_RELEASE=$(python minor.py)
if [[ $DO_RELEASE == "1" ]]
then
echo "release_type=minor" >> $GITHUB_OUTPUT
else
echo "release_type=skip" >> $GITHUB_OUTPUT
fi
- name: Determine releasing version
if: ${{ steps.release_type.outputs.release_type != 'skip' }}
id: releasing_version
run: |
CURRENT_VERSION=$(awk '/## NEXT/,/url/' config.toml | grep -o '\"v.*\"' | tr -d '\"' | xargs)
# The following command adds the .z part of the version
RAW_VERSION=$(echo "$CURRENT_VERSION.0")
echo "releasing_version=$(python bump.py minor $RAW_VERSION)" >> $GITHUB_OUTPUT
- name: Cleanup
run: rm bump.py minor.py
- name: Log information
run: |
echo "Releasing version: ${{ steps.releasing_version.outputs.releasing_version }}"
release:
name: Release
if: ${{ needs.initialize.outputs.release_type != 'skip' && ((github.event_name == 'schedule' && github.repository == 'kiali/kiali.io') || github.event_name != 'schedule') }}
runs-on: ubuntu-20.04
needs: [initialize]
env:
RELEASING_VERSION: ${{ needs.initialize.outputs.releasing_version }}
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: Create release
run: |
echo "Resolved current website version: $RELEASING_VERSION"
./scripts/release.sh -cv $RELEASING_VERSION -rn origin -gd true