Skip to content

Commit dfe93c1

Browse files
Merge pull request #1 from sourcebot-dev/bkellam/helm_release
2 parents e21b6d9 + af021b4 commit dfe93c1

29 files changed

+1615
-1003
lines changed

.github/workflows/release.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'charts/*/Chart.yaml'
9+
10+
jobs:
11+
release:
12+
name: Release Helm Chart
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure Git
24+
run: |
25+
git config user.name "$GITHUB_ACTOR"
26+
git config user.email "[email protected]"
27+
28+
- name: Install Helm
29+
uses: azure/setup-helm@v3
30+
31+
- name: Update dependencies
32+
run: helm dependency update charts/sourcebot/
33+
34+
- name: Set Chart Version
35+
id: chart-version
36+
run: |
37+
# Extract chart version from the Chart.yaml
38+
CHART_DIR=$(find ./charts -name "Chart.yaml" -not -path "*/\.git/*" | head -1 | xargs dirname)
39+
CHART_NAME=$(yq e '.name' "$CHART_DIR/Chart.yaml")
40+
CHART_VERSION=$(yq e '.version' "$CHART_DIR/Chart.yaml")
41+
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
42+
echo "chart_dir=$CHART_DIR" >> $GITHUB_OUTPUT
43+
echo "chart_name=$CHART_NAME" >> $GITHUB_OUTPUT
44+
echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT
45+
echo "repo_lower=$REPO_LOWER" >> $GITHUB_OUTPUT
46+
echo "Chart: $CHART_NAME:$CHART_VERSION in $CHART_DIR"
47+
48+
- name: Login to GitHub Container Registry
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Package Helm Chart
56+
run: |
57+
helm package ${{ steps.chart-version.outputs.chart_dir }} --version ${{ steps.chart-version.outputs.chart_version }}
58+
59+
- name: Push to GitHub Container Registry
60+
run: |
61+
helm push ${{ steps.chart-version.outputs.chart_name }}-${{ steps.chart-version.outputs.chart_version }}.tgz oci://ghcr.io/${{ steps.chart-version.outputs.repo_lower }}/charts
62+
63+
- name: Run chart-releaser
64+
uses: helm/[email protected]
65+
env:
66+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
67+
CR_GENERATE_RELEASE_NOTES: "true"
68+

.github/workflows/test.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Unit Tests
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
unit-tests:
10+
name: Run Helm Unit Tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Helm
19+
uses: azure/setup-helm@v3
20+
with:
21+
version: v3.13.2
22+
23+
- name: Install helm-unittest plugin
24+
run: |
25+
helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v1.0.0
26+
27+
- name: Update dependencies
28+
run: helm dependency update charts/sourcebot/
29+
30+
- name: Run unit tests
31+
run: |
32+
helm unittest charts/sourcebot/ --color --output-type JUnit --output-file test-results.xml
33+
34+
- name: Publish Test Results
35+
uses: EnricoMi/publish-unit-test-result-action@v2
36+
if: always()
37+
with:
38+
files: test-results.xml
39+
check_name: "Helm Unit Test Results"
40+
comment_title: "Helm Unit Test Results"

.github/workflows/validate.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Validate Helm Chart
2+
on:
3+
pull_request:
4+
paths:
5+
- 'charts/**'
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
validate:
12+
name: Validate Helm Chart
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Helm
21+
uses: azure/setup-helm@v3
22+
with:
23+
version: v3.13.2
24+
25+
- name: Install helm-docs
26+
run: |
27+
cd /tmp
28+
curl -L https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz | tar xz
29+
sudo mv helm-docs /usr/local/bin/
30+
31+
- name: Update dependencies
32+
run: helm dependency update charts/sourcebot/
33+
34+
- name: Run helm lint
35+
run: helm lint charts/sourcebot/ -f charts/sourcebot/values.lint.yaml
36+
37+
- name: Validate helm-docs
38+
run: |
39+
helm-docs charts/sourcebot/
40+
if [[ $(git diff --stat) != '' ]]; then
41+
echo 'Chart documentation is out of date. Please run helm-docs and commit the changes.'
42+
echo 'Git diff:'
43+
git diff
44+
exit 1
45+
fi
46+

0 commit comments

Comments
 (0)