forked from temporalio/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (119 loc) · 4.8 KB
/
publish-chart-in-cast.yaml
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
132
name: Build
on:
push:
branches:
- main
release:
types:
- published
pull_request:
branches:
- main
env:
CR_CONFIGFILE: "${{ github.workspace }}/cr.yaml"
CR_INDEX_PATH: "${{ github.workspace }}/.cr-index"
CR_PACKAGE_PATH: "${{ github.workspace }}/.cr-release-packages"
CR_TOOL_PATH: "${{ github.workspace }}/.cr-tool"
CHART_PATH: "${{ github.workspace }}/charts/temporal"
jobs:
build:
name: Publish Helm Chart in castai/helm-charts
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout helm-charts
if: ${{ github.event_name == 'release' }}
# The cr tool only works if the target repository is already checked out
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: castai/helm-charts
path: castai-helm-charts
token: ${{ secrets.HELM_CHARTS_REPO_TOKEN }}
- name: Configure Git for helm-charts
if: ${{ github.event_name == 'release' }}
run: |
cd castai-helm-charts
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
if: ${{ github.event_name == 'release' }}
uses: azure/[email protected]
id: install
- name: Install CR tool
if: ${{ github.event_name == 'release' }}
run: |
mkdir "${CR_TOOL_PATH}"
mkdir "${CR_PACKAGE_PATH}"
mkdir "${CR_INDEX_PATH}"
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/v1.6.1/chart-releaser_1.6.1_linux_amd64.tar.gz"
tar -xzf cr.tar.gz -C "${CR_TOOL_PATH}"
rm -f cr.tar.gz
- name: Bump chart version
if: ${{ github.event_name == 'release' }}
run: |
echo "Release tag is ${{env.RELEASE_TAG}}"
python ./.github/workflows/bump_chart.py ${CHART_PATH}/Chart.yaml ${{env.RELEASE_TAG}}
- name: Parse Chart.yaml
if: ${{ github.event_name == 'release' }}
id: parse-chart
run: |
description=$(yq ".description" < ${CHART_PATH}/Chart.yaml)
name=$(yq ".name" < ${CHART_PATH}/Chart.yaml)
version=$(yq ".version" < ${CHART_PATH}/Chart.yaml)
echo "chartpath=${CHART_PATH}" >> $GITHUB_OUTPUT
echo "desc=${description}" >> $GITHUB_OUTPUT
echo "tagname=${name}-${version}" >> $GITHUB_OUTPUT
echo "packagename=${name}-${version}" >> $GITHUB_OUTPUT
- name: Create helm package
if: ${{ github.event_name == 'release' }}
run: |
"${CR_TOOL_PATH}/cr" package "${{ steps.parse-chart.outputs.chartpath }}" --config "${CR_CONFIGFILE}" --package-path "${CR_PACKAGE_PATH}"
echo "Result of chart package:"
ls -l "${CR_PACKAGE_PATH}"
git status
- name: Make helm charts github release
if: ${{ github.event_name == 'release' }}
uses: softprops/[email protected]
with:
body: |
${{ steps.parse-chart.outputs.desc }}
Source commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
files: |
${{ env.CR_PACKAGE_PATH }}/${{ steps.parse-chart.outputs.packagename }}.tgz
${{ env.CR_PACKAGE_PATH }}/${{ steps.parse-chart.outputs.packagename }}.tgz.prov
repository: castai/helm-charts
tag_name: ${{ steps.parse-chart.outputs.tagname }}
token: ${{ secrets.HELM_CHARTS_REPO_TOKEN }}
- name: Update helm repo index.yaml
if: ${{ github.event_name == 'release' }}
run: |
cd helm-charts
"${CR_TOOL_PATH}/cr" index --config "${CR_CONFIGFILE}" --token "${{ secrets.HELM_CHARTS_REPO_TOKEN }}" --index-path "${CR_INDEX_PATH}" --package-path "${CR_PACKAGE_PATH}" --push
- name: Commit Chart.yaml changes
if: ${{ github.event_name == 'release' }}
run: |
git status
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add charts/temporal/Chart.yaml
git stash
git fetch
git checkout main
git stash pop
git add charts/temporal/Chart.yaml
git commit -m "[Release] Update Chart.yaml"
git push
- name: Sync chart with helm-charts github
if: ${{ github.event_name == 'release' }}
run: |
cd helm-charts
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git checkout main
mkdir -p ./charts/temporal
cp -r ${CHART_PATH}/* ./charts/temporal
git add charts/temporal
git commit -m "Update Temporal chart to ${{env.RELEASE_TAG}}"
git push