-
Notifications
You must be signed in to change notification settings - Fork 22
86 lines (72 loc) · 2.52 KB
/
release.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
name: Release Helm charts
on:
push:
branches:
- main
paths:
- '**/Chart.yaml'
jobs:
get-list-of-charts:
runs-on: ubuntu-latest
name: 'Get list of charts to be released'
outputs:
charts: ${{ steps.get-charts.outputs.charts }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: get-charts
name: Get list of charts to be released
run: |
# Get list of Chart.yaml files changed in the last commit
files_changed="$(git show --pretty="" --name-only | grep Chart.yaml)"
charts=()
for file in $files_changed; do
count=$(git show "$file" | grep -c "+version" || true)
if [ $count -eq 0 ]; then
echo "No version change in $file"
continue
fi
charts+=("$(echo "$file" | xargs dirname)")
done
if [ ${#charts[@]} -eq 0 ]; then
echo "No charts to be released"
echo "charts=none" >> "$GITHUB_OUTPUT"
else
echo "charts=$(jq 'split(" ")' -Rc <(echo ${charts[@]}))" >> "$GITHUB_OUTPUT"
fi
release-charts:
runs-on: ubuntu-latest
needs: get-list-of-charts
if: needs.get-list-of-charts.outputs.charts != 'none'
strategy:
matrix:
chart: ${{ fromJson(needs.get-list-of-charts.outputs.charts) }}
steps:
- name: Git Checkout
uses: actions/checkout@v3
- name: Setup Helm
uses: azure/setup-helm@v3
with:
version: v3.5.3
- name: Read Helm Chart version
id: chart-version
run: echo "version=$(awk '/^version:/ {print $2}' ${{ matrix.chart }}/Chart.yaml)" >> "$GITHUB_OUTPUT"
- name: Helm Chart package file name
id: file-name
run: |
echo "fileName=$(basename ${{ matrix.chart }})-${{ steps.chart-version.outputs.version }}.tgz"
echo "fileName=$(basename ${{ matrix.chart }})-${{ steps.chart-version.outputs.version }}.tgz" >> "$GITHUB_OUTPUT"
- name: Update dependencies
run: helm dependency update ${{ matrix.chart }}
- name: Package Helm Chart
run: helm package ${{ matrix.chart }} --version ${{ steps.chart-version.outputs.version }}
- name: Push Helm Chart
uses: cloudsmith-io/[email protected]
with:
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
command: "push"
format: "helm"
owner: "tyk"
repo: "helm"
file: "${{ steps.file-name.outputs.fileName }}"