Repository navigation
180 lines (152 loc) · 6.25 KB
/
Copy pathrelease.yaml
File metadata and controls
180 lines (152 loc) · 6.25 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build, Package, Release (Production)
on:
push:
tags:
- '[0-9]*.[0-9]*.[0-9]*'
env:
REGISTRY: ghcr.io
HELMNAME: "renovate-operator"
jobs:
build-operator:
uses: mogenius/github-actions/.github/workflows/build-multiarch.yml@77e5561028e64b7abacc72c0913003085dfe3b2c # v1.17.1
secrets: inherit
with:
version: ${{ github.ref_name }}
image: ghcr.io/mogenius/renovate-operator
push_latest: true
helm-chart:
needs: [build-operator]
runs-on: self-hosted
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_SECRET }}
repositories: |
helm-charts
renovate-operator
owner: mogenius
permission-contents: write
- name: Check out code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0
- name: Install cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version: ">=1.23.2"
- name: Update Chart.yaml
env:
VERSION: ${{ github.ref_name }}
run: |
sed -i "s/^version:.*/version: ${VERSION}/" charts/renovate-operator/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: ${VERSION}/" charts/renovate-operator/Chart.yaml
- name: Run helm-docs
uses: losisin/helm-docs-github-action@9e0787c426fdec38be6288bb5c0559dcb388412c # v2.0.1
with:
chart-search-root: charts/renovate-operator
- name: Generate CRDs
run: |
export GOPATH=$(go env GOPATH)
export PATH=$PATH:$GOPATH/bin
go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest
controller-gen crd paths=./src/... output:crd:dir=charts/renovate-operator/crd
- name: Add Helm repositories
run: |
helm repo add valkey https://valkey.io/valkey-helm/
helm repo update
- name: Package chart
env:
VERSION: ${{ github.ref_name }}
run: |
helm dependency build ./charts/renovate-operator
helm package -d /tmp/ ./charts/renovate-operator --version "${VERSION}" --app-version "${VERSION}"
- name: Log in to Container Registry
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub Pages
env:
VERSION: ${{ github.ref_name }}
TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
git clone --branch gh-pages --single-branch \
"https://x-access-token:${TOKEN}@github.com/mogenius/helm-charts.git" \
/tmp/helm-charts-repo
cp "/tmp/${HELMNAME}-${VERSION}.tgz" /tmp/helm-charts-repo/public/
cd /tmp/helm-charts-repo
helm repo index public --url https://helm.mogenius.com/public --merge public/index.yaml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add public/
git commit -m "chore: publish ${HELMNAME}-${VERSION}"
for attempt in $(seq 1 5); do
if git push; then
echo "::notice::Published ${HELMNAME}-${VERSION} to public"
break
fi
if [ "${attempt}" -eq 5 ]; then
echo "::error::Failed to push after 5 attempts"
exit 1
fi
echo "::warning::Push conflict (attempt ${attempt}/5), retrying..."
git fetch origin gh-pages
git reset --hard origin/gh-pages
cp "/tmp/${HELMNAME}-${VERSION}.tgz" public/
helm repo index public --url https://helm.mogenius.com/public --merge public/index.yaml
git add public/
git commit -m "chore: publish ${HELMNAME}-${VERSION}"
sleep $((attempt * 2))
done
- name: Push to OCI and sign
env:
VERSION: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CHART_DIGEST=$(helm push "/tmp/${HELMNAME}-${VERSION}.tgz" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts" 2>&1 | grep "Digest: sha256:" | awk '{print $2}')
if [ -z "${CHART_DIGEST}" ]; then
echo "Failed to extract chart digest"
exit 1
fi
echo "Chart digest: ${CHART_DIGEST}"
cosign sign --yes "ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts/${HELMNAME}@${CHART_DIGEST}"
- name: Commit version and docs update
env:
VERSION: ${{ github.ref_name }}
run: |
git add charts/renovate-operator/Chart.yaml
git add charts/renovate-operator/crd/*.mogenius.com_*.yaml
git add charts/renovate-operator/README.md || true
if git diff --cached --quiet; then
echo "No changes to commit."
exit 0
fi
git commit -m "chore: update Chart.yaml and documentation for version ${VERSION} [skip ci]"
git pull --rebase
git push origin main
- name: Combine CRDs
run: cat charts/renovate-operator/crd/*.mogenius.com_*.yaml > /tmp/crds.yaml
- name: Upload combined CRDs to the release
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4
with:
tag_name: ${{ github.ref_name }}
files: /tmp/crds.yaml
fail_on_unmatched_files: true