-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (116 loc) · 5.31 KB
/
publish-helm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 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 }}