-
Notifications
You must be signed in to change notification settings - Fork 8
79 lines (72 loc) · 2.73 KB
/
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
name: Release Charts
on:
push:
branches:
- main
jobs:
check-release:
runs-on: ubuntu-latest
outputs:
release_exists: ${{ steps.check_release.outputs.release_exists }}
steps:
- uses: actions/checkout@v4
- name: Check if release with the same chart version exists
id: check_release
run: |
VERSION=$(yq ".name + \"-\" + .version" charts/netbird/Chart.yaml)
echo "Checking for release $VERSION..."
RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$VERSION")
if [[ "$RELEASE" == *"Not Found"* ]]; then
echo "No release found for version $VERSION. Continuing steps..."
echo "release_exists=false" >> $GITHUB_ENV
echo "release_exists=false" >> $GITHUB_OUTPUT
else
echo "Release for version $VERSION exists. Skipping steps..."
echo "release_exists=true" >> $GITHUB_ENV
echo "release_exists=true" >> $GITHUB_OUTPUT
fi
helm-validate:
needs: [check-release]
if: needs.check-release.outputs.release_exists == 'false'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bmuschko/setup-kubeconform@v1
- name: Validate Helm Charts
shell: bash
run: |
set -o pipefail
for chart in $(find charts -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sort | uniq); do helm dep up ${chart}; done
for d in charts/*/ ; do
echo "$d"
helm lint --quiet "$d"
helm template x "$d" --include-crds > helm_output.yaml
echo "Validate K8s 1.30"
cat helm_output.yaml | kubeconform -summary -strict -ignore-missing-schemas -kubernetes-version=1.30.0 -cache /tmp
echo "Validate K8s 1.31"
cat helm_output.yaml | kubeconform -summary -strict -ignore-missing-schemas -kubernetes-version=1.31.0 -cache /tmp
done
release:
needs: [helm-validate]
if: needs.check-release.outputs.release_exists == 'false'
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"