|
1 | 1 | # This action releases the runtime-class-manager helm chart
|
2 |
| -# The action must run on each commit done against main, however |
3 |
| -# a new release will be performed **only** when a change occurs inside |
4 |
| -# of the `charts` directory. |
| 2 | +# |
| 3 | +# A chart is published to the configured OCI registry on every push to main |
| 4 | +# as well as on semver tag releases (via workflow_call from release.yml). |
5 | 5 | name: Release helm chart
|
6 | 6 |
|
7 |
| -permissions: |
8 |
| - contents: read |
9 |
| - |
10 | 7 | on:
|
11 | 8 | push:
|
12 | 9 | branches:
|
13 | 10 | - main
|
| 11 | + workflow_call: |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + packages: write |
| 16 | + |
| 17 | +env: |
| 18 | + REGISTRY: ghcr.io |
| 19 | + CHART_NAME: runtime-class-manager |
14 | 20 |
|
15 | 21 | jobs:
|
16 | 22 | release:
|
17 |
| - runs-on: ubuntu-latest |
18 |
| - |
19 |
| - permissions: |
20 |
| - id-token: write |
21 |
| - packages: write |
22 |
| - contents: write |
| 23 | + name: Release chart |
| 24 | + runs-on: ubuntu-22.04 |
23 | 25 |
|
24 | 26 | steps:
|
25 |
| - - name: Checkout |
26 |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Install helm |
| 30 | + uses: Azure/setup-helm@v4 |
27 | 31 | with:
|
28 |
| - fetch-depth: 0 |
| 32 | + version: v3.16.3 |
29 | 33 |
|
30 |
| - - name: Configure Git |
| 34 | + - name: Determine chart version |
31 | 35 | run: |
|
32 |
| - git config user.name "$GITHUB_ACTOR" |
33 |
| - git config user.email "[email protected]" |
| 36 | + if [[ "${{ startsWith(github.ref, 'refs/tags/v') }}" == "true" ]]; then |
| 37 | + # NOTE: We remove the leading 'v' to comply with helm's versioning requirements |
| 38 | + echo "CHART_VERSION=$(echo -n ${{ github.ref_name }} | sed -rn 's/(v)?(.*)/\2/p')" >> $GITHUB_ENV |
| 39 | + echo "APP_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV |
| 40 | + else |
| 41 | + # NOTE: We can replace 0.0.0 with e.g. $(git describe --tags $(git rev-list --tags --max-count=1)) once we have a first tag |
| 42 | + # However, we'll also need to update the checkout step with 'fetch-depth: 0' if we list tags |
| 43 | + echo "CHART_VERSION=0.0.0-$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 44 | + # Setting to 'latest' to match tag used in container-image.yml |
| 45 | + echo "APP_VERSION=latest" >> $GITHUB_ENV |
| 46 | + fi |
34 | 47 |
|
35 |
| - - name: Install Helm |
36 |
| - uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 |
| 48 | + - name: Log into registry ${{ env.REGISTRY }} |
| 49 | + uses: docker/login-action@v3 |
37 | 50 | with:
|
38 |
| - version: v3.14.0 |
| 51 | + registry: ${{ env.REGISTRY }} |
| 52 | + username: ${{ github.actor }} |
| 53 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + |
| 55 | + - name: Package chart |
| 56 | + run: make helm-package |
| 57 | + |
| 58 | + - name: Lint packaged chart |
| 59 | + run: make helm-lint |
39 | 60 |
|
40 |
| - - name: Run chart-releaser |
41 |
| - if: github.ref == 'refs/heads/main' |
42 |
| - uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0 |
| 61 | + - name: Upload chart as GitHub artifact |
| 62 | + uses: actions/upload-artifact@v4 |
43 | 63 | with:
|
44 |
| - charts_dir: deploy/helm |
| 64 | + name: ${{ env.CHART_NAME }} |
| 65 | + path: _dist/${{ env.CHART_NAME }}-${{ env.CHART_VERSION }}.tgz |
| 66 | + |
| 67 | + - name: Publish chart |
45 | 68 | env:
|
46 |
| - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
47 |
| - CR_RELEASE_NAME_TEMPLATE: "{{ .Name }}-chart-{{ .Version }}" |
| 69 | + CHART_REGISTRY: ${{ env.REGISTRY }}/${{ github.repository_owner }}/charts |
| 70 | + run: | |
| 71 | + make helm-publish |
| 72 | +
|
| 73 | + echo '### Helm chart published:' >> $GITHUB_STEP_SUMMARY |
| 74 | + echo '- `Reference: ${{ env.CHART_REGISTRY }}/${{ env.CHART_NAME }}`' >> $GITHUB_STEP_SUMMARY |
| 75 | + echo '- `Version: ${{ env.CHART_VERSION }}`' >> $GITHUB_STEP_SUMMARY |
0 commit comments