Skip to content

Commit 7d1f841

Browse files
committed
add chart publishing
1 parent 5523192 commit 7d1f841

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

.github/workflows/helm-lint.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Helm Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
jobs:
10+
helm-lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Helm with Official Script
17+
run: |
18+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
19+
chmod 700 get_helm.sh
20+
./get_helm.sh
21+
22+
- name: Run Helm Lint on Chart
23+
run: helm lint .
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Helm Package, Push & (Conditional) Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "The tag to use for packaging (must be provided when triggered manually)."
11+
required: true
12+
13+
permissions:
14+
contents: write # Required for creating GitHub releases
15+
16+
jobs:
17+
package-push-release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v3
22+
23+
- name: Install Helm (Official)
24+
run: |
25+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
26+
chmod 700 get_helm.sh
27+
./get_helm.sh
28+
29+
- name: Determine Versions
30+
id: versions
31+
run: |
32+
# Extract chart name and version from Chart.yaml in the repository root.
33+
CHART_VERSION=$(awk -F": " '/^version:/{print $2}' Chart.yaml | tr -d '[:space:]')
34+
CHART_NAME=$(awk -F": " '/^name:/{print $2}' Chart.yaml | tr -d '[:space:]')
35+
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV
36+
echo "CHART_NAME=$CHART_NAME" >> $GITHUB_ENV
37+
38+
# Use the tag from the trigger—manual input (workflow_dispatch) or push event.
39+
if [ -n "${{ github.event.inputs.tag }}" ]; then
40+
EFFECTIVE_VERSION="${{ github.event.inputs.tag }}"
41+
else
42+
EFFECTIVE_VERSION="${GITHUB_REF##*/}"
43+
fi
44+
echo "EFFECTIVE_VERSION=$EFFECTIVE_VERSION" >> $GITHUB_ENV
45+
46+
echo "Chart.yaml version: $CHART_VERSION"
47+
echo "Effective version (tag): $EFFECTIVE_VERSION"
48+
49+
# The following step is necessary even dependencies are not used.
50+
- name: Update Chart Dependencies
51+
run: helm dependency update .
52+
53+
- name: Package Helm Chart
54+
run: |
55+
echo "Packaging chart with version $EFFECTIVE_VERSION"
56+
helm package . --version "$EFFECTIVE_VERSION"
57+
58+
- name: List Packaged Files
59+
run: ls -l *.tgz
60+
61+
- name: Add Helm Repository
62+
run: helm repo add eccr-polytope https://eccr.ecmwf.int/chartrepo/polytope --username '${{ secrets.ECMWF_DOCKER_REGISTRY_USERNAME }}' --password '${{ secrets.ECMWF_DOCKER_REGISTRY_ACCESS_TOKEN }}'
63+
64+
- name: Install cm-push Plugin
65+
run: helm plugin install https://github.com/chartmuseum/helm-push
66+
67+
- name: Push Packaged Chart
68+
run: |
69+
PACKAGE_FILE="${{ env.CHART_NAME }}-${{ env.EFFECTIVE_VERSION }}.tgz"
70+
echo "Pushing package file: $PACKAGE_FILE"
71+
helm cm-push "$PACKAGE_FILE" eccr-polytope
72+
73+
- name: Create GitHub Release if Tag Equals Chart Version
74+
if: ${{ env.EFFECTIVE_VERSION == env.CHART_VERSION }}
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
tag_name: ${{ env.EFFECTIVE_VERSION }}
78+
name: "${{ env.CHART_NAME }} v${{ env.EFFECTIVE_VERSION }}"
79+
generate_release_notes: true
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
apiVersion: v2
2222
name: polytope
23-
version: 0.0.2
23+
version: 0.0.3
2424

2525
dependencies:
2626
- name: mysql

0 commit comments

Comments
 (0)