-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (66 loc) · 2.26 KB
/
publish.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
name: Release Charts
on:
push:
tags:
# Semantic versioning; must be equal to version in Chart.yaml
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
publish:
name: Publish Helm chart
if: github.repository == 'logicalclocks/rondb-helm'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout main repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
echo "GH ref: ${{ github.ref }}"
echo "GH ref_name: ${{ github.ref_name }}"
- name: Only allow main branch to publish
run: |
branch=$(git branch -r --contains ${{ github.ref }} --format "%(refname:lstrip=3)")
echo "Current branch: $branch"
# Exit if branch is not main
if [ "$branch" != "main" ]; then
echo "Branch is not main, exiting"
exit 1
fi
- name: Check that Git tag matches Chart.yaml version
run: |
TAG=$(echo ${{ github.ref_name }} | sed 's/v//')
CHART_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}')
if [ "$TAG" != "$CHART_VERSION" ]; then
echo "Tag $TAG does not match Chart.yaml version $CHART_VERSION"
exit 1
fi
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: '3.13.3'
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Package Helm Charts
run: helm package . --destination ./charts/
# This will fail if the Helm package already exists; But Git tags can't
# be duplicated anyways and a release shouldn't be overwritten either.
- name: Checkout gh-pages branch
run: |
git fetch origin gh-pages
git checkout gh-pages
- name: Generate index.yaml corresponding to the existing charts
run: helm repo index . --url https://logicalclocks.github.io/rondb-helm/
- name: Commit and Push to gh-pages
run: |
git add ./charts/*
git add index.yaml
git commit -m "Release RonDB Helm chart ${{ github.ref_name }}"
git push origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}