-
Notifications
You must be signed in to change notification settings - Fork 27
75 lines (65 loc) · 2.34 KB
/
Copy pathhelm-publish.yml
File metadata and controls
75 lines (65 loc) · 2.34 KB
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
name: Helm publish
# Tag-based Helm chart release. Pushing a semver tag packages
# charts/etcd-operator and pushes it as an OCI chart to GHCR under the org's
# charts repo (ghcr.io/<owner>/charts/etcd-operator), versioned from the tag.
# Same shape as the legacy v1alpha1 helm-publish, retargeted at this org and
# using the built-in GITHUB_TOKEN.
on:
push:
tags: [ 'v*.*.*' ]
env:
REGISTRY: ghcr.io
CHARTS_REPOSITORY: ${{ github.repository_owner }}/charts
CHART_NAME: etcd-operator
jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# make manifests regenerates the CRDs and manager RBAC rules (controller-gen)
# straight into the chart, so the published package always matches the
# tagged API types and +kubebuilder:rbac markers — never a stale committed
# copy. (ci.yml's drift gate already enforces this on PRs; this is belt-and-
# suspenders at publish time.)
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: 'v3.16.4'
- name: Regenerate CRDs and RBAC into the chart
run: make manifests
- name: Resolve chart versions from tag
env:
REF_NAME: ${{ github.ref_name }}
run: |
TAG="$REF_NAME"
echo "RELEASE_TAG=${TAG}" >> "$GITHUB_ENV"
# Chart version is semver without the leading v; appVersion keeps it.
echo "RELEASE_TAG_TRIMMED_V=${TAG#v}" >> "$GITHUB_ENV"
- name: Helm registry login
env:
ACTOR: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
helm registry login \
--username "$ACTOR" \
--password "$TOKEN" \
"${{ env.REGISTRY }}"
- name: Package chart
working-directory: charts
run: |
helm package "${{ env.CHART_NAME }}" \
--version "${RELEASE_TAG_TRIMMED_V}" \
--app-version "${RELEASE_TAG}"
- name: Push chart
working-directory: charts
run: |
helm push "${{ env.CHART_NAME }}-${RELEASE_TAG_TRIMMED_V}.tgz" \
"oci://${{ env.REGISTRY }}/${{ env.CHARTS_REPOSITORY }}"