Skip to content

feat: synchronize config files #314

feat: synchronize config files

feat: synchronize config files #314

Workflow file for this run

# Copyright 2024 CS Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Publish Helm charts
# TODO: is it possible to run this workflow only if the check-code-quality workflow has completed successfully ?
# I've tried workflow_run but see:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
# Note: This event will only trigger a workflow run if the workflow file is on the default branch.
# Run workflow only for new git tags (including hierarchical tags like v1.0/beta), or manually
on:
push:
tags:
- '**'
branches:
- 'feat**'
workflow_dispatch:
env:
DOCKER_REGISTRY: ghcr.io
jobs:
#######################
# Publish Helm charts #
#######################
rs-server-helm-chart:
runs-on: ubuntu-latest
name: "rs-server Helm chart"
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all branches and tags.
- name: Get the rs-server version tag
id: get_version
shell: bash
run: |
# Enable pipefail so git command failures do not result in null versions downstream
set -x
if [ "$GITHUB_REF_TYPE" == "tag" ]; then
if [[ "$GITHUB_REF_NAME" =~ v[0-9].[0-9][ab] || "$GITHUB_REF_NAME" =~ v[0-9][ab] ]] ; then
# Sprint release
# v0.1a10
echo "APP_VERSION=$(\
git ls-remote --tags --refs --sort="v:refname" \
https://github.com/RS-PYTHON/rs-server.git | grep -E 'v[0-9](.)?([0-9])?[ab]' | tail -n1 | sed 's/.*\///' \
)" >> $GITHUB_OUTPUT
# v0.1a10
# Ugly workaround to transform the chart_version into SemVer 2, required by Helm
CHART_VERSION_TMP=$(echo $GITHUB_REF_NAME | sed 's/.*\///' | sed 's/^v//')
CHART_VERSION_PREFIX=${CHART_VERSION_TMP%[ab]*}
CHART_VERSION_SUFFIX=${CHART_VERSION_TMP/#$CHART_VERSION_PREFIX}
while [[ ${#CHART_VERSION_PREFIX} -lt 5 ]]; do
CHART_VERSION_PREFIX+=".0"
done
if [[ ${#CHART_VERSION_PREFIX} -eq 5 ]]; then
echo "CHART_VERSION=$CHART_VERSION_PREFIX-$CHART_VERSION_SUFFIX" >> $GITHUB_OUTPUT
fi
# v0.1a7 => 0.1.0-a7
# v1a7 => 1.0.0-a7
elif [[ "$GITHUB_REF_NAME" = v[0-9].[0-9] || "$GITHUB_REF_NAME" = v[0-9] ]] ; then
# Checkpoint release
# v0.1 or v1
echo "APP_VERSION=$(\
git ls-remote --tags --refs --sort="v:refname" \
https://github.com/RS-PYTHON/rs-server.git | grep -E 'v[0-9](.)?([0-9])?$' | tail -n1 | sed 's/.*\///' \
)" >> $GITHUB_OUTPUT
# v0.1
CHART_VERSION=$(echo $GITHUB_REF_NAME | sed 's/.*\///' | sed 's/^v//')
while [[ ${#CHART_VERSION} -lt 5 ]]; do
CHART_VERSION+=".0"
done
if [[ ${#CHART_VERSION} -eq 5 ]]; then
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_OUTPUT
fi
# v0.1 => 0.1.0
# v1 => 1.0.0
fi
elif [ "$GITHUB_REF_TYPE" == "branch" ]; then
echo "APP_VERSION=$(\
git ls-remote --tags --refs --sort="v:refname" \
https://github.com/RS-PYTHON/rs-server.git | grep -E 'v[0-9](.)?([0-9])?[ab]' | tail -n1 | sed 's/.*\///' \
)" >> $GITHUB_OUTPUT
# v0.1a10
# Ugly workaround to transform the chart_version into SemVer 2, required by Helm
CHART_VERSION_TMP=$(git ls-remote --tags --refs --sort="v:refname" \
https://github.com/RS-PYTHON/rs-server.git | grep -E 'v[0-9](.)?([0-9])?[ab]' | tail -n1 | sed 's/.*\///' | sed 's/^v//')
CHART_VERSION_PREFIX=${CHART_VERSION_TMP%[ab]*}
CHART_VERSION_SUFFIX=${CHART_VERSION_TMP/#$CHART_VERSION_PREFIX}
while [[ ${#CHART_VERSION_PREFIX} -lt 5 ]]; do
CHART_VERSION_PREFIX+=".0"
done
if [[ ${#CHART_VERSION_PREFIX} -eq 5 ]]; then
echo "CHART_VERSION=$CHART_VERSION_PREFIX-$CHART_VERSION_SUFFIX-$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
fi
# v0.1a7 => 0.1.0-a7-1tr5hrt
# v1a7 => 1.0.0-a7-1tr5hrt
fi
- name: Update version number in chart.yaml
shell: bash
run: |
for chart in $(find charts -name Chart.yaml); do
sed -i "s,{{APP_VERSION}},${{ steps.get_version.outputs.APP_VERSION }}," $chart
sed -i "s,{{CHART_VERSION}},${{ steps.get_version.outputs.CHART_VERSION }}," $chart
done
- id: publish-chart
uses: ./.github/actions/publish-chart
with:
github_token: ${{ secrets.GITHUB_TOKEN }}