-
Notifications
You must be signed in to change notification settings - Fork 5
104 lines (93 loc) · 2.95 KB
/
lint_and_release.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
name: Helm Chart Lint and Release
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
helm-lint:
name: Helm lint
runs-on: ubuntu-latest
steps:
- name: Check out repo hosting code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Run helm lint
run: helm lint cloudprober/.
paths-filter:
name: Filter Chart.yaml
outputs:
charts_yaml_changing: ${{ steps.filter.outputs.chartYaml }}
runs-on: ubuntu-latest
needs: [helm-lint]
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
chartYaml:
- 'cloudprober/Chart.yaml'
chart-release:
name: Release chart
runs-on: ubuntu-latest
needs: [paths-filter, helm-lint]
if: needs.paths-filter.outputs.charts_yaml_changing == 'true'
steps:
- name: Check out repo hosting code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
chartYaml:
- 'cloudprober/Chart.yaml'
- name: Compute chart version
run: |-
baseVersion=$(sed -n '/version: /s/version: //p' cloudprober/Chart.yaml)
echo ">> Base version: $baseVersion"
bv=( ${baseVersion//./ } )
appVersion=$(sed -n '/appVersion: /s/appVersion: //p' cloudprober/Chart.yaml)
echo ">> App version: $appVersion"
cpVersion=${appVersion/v/}
cpVersion=$(echo $cpVersion | tr -d "'")
echo ">> Cloudprober version: $cpVersion"
cv=( ${cpVersion//./ } )
newVersion=$((${bv[0]} + ${cv[0]})).$((${bv[1]} + ${cv[1]})).$((${bv[2]} + ${cv[2]}))
echo ">> New version: $newVersion"
echo "CHART_VERSION=${newVersion}" >> $GITHUB_ENV
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ env.CHART_VERSION }}',
sha: context.sha
})
- name: Package chart and build index
run: |-
git worktree add repo gh-pages
cd repo
helm package ../cloudprober/. --version=${CHART_VERSION} -d packages
helm repo index . --url https://helm.cloudprober.org
git add *
git status
- name: Push release
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')
run: |-
cd repo
git add *
git config user.name "Manu Garg"
git config user.email "manugarg@gmail.com"
git commit -m "[automated] Update helm charts repo" || exit 0
git push