Skip to content

Commit 8553ca3

Browse files
author
gurghet
committed
fix: update workflow to properly publish helm chart
1 parent 6532b61 commit 8553ca3

1 file changed

Lines changed: 31 additions & 110 deletions

File tree

.github/workflows/release.yaml

Lines changed: 31 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
8-
branches:
9-
- master
107

118
env:
129
REGISTRY: ghcr.io
@@ -15,32 +12,26 @@ env:
1512
jobs:
1613
release:
1714
runs-on: ubuntu-latest
18-
if: github.event_name != 'pull_request'
1915
permissions:
2016
contents: write
21-
issues: write
22-
pull-requests: write
2317
packages: write
24-
2518
outputs:
2619
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
2720
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
28-
2921
steps:
3022
- name: Checkout
3123
uses: actions/checkout@v4
3224
with:
3325
fetch-depth: 0
34-
26+
3527
- name: Setup Node.js
36-
uses: actions/setup-node@v4
28+
uses: actions/setup-node@v3
3729
with:
38-
node-version: 'lts/*'
39-
40-
- name: Install semantic-release
41-
run: |
42-
npm install -g semantic-release @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/github
43-
30+
node-version: "lts/*"
31+
32+
- name: Install dependencies
33+
run: npm install -g semantic-release @semantic-release/git @semantic-release/github
34+
4435
- name: Create Release
4536
id: semantic
4637
env:
@@ -54,9 +45,8 @@ jobs:
5445
permissions:
5546
contents: read
5647
packages: write
57-
5848
steps:
59-
- name: Checkout repository
49+
- name: Checkout
6050
uses: actions/checkout@v4
6151

6252
- name: Set up Docker Buildx
@@ -69,130 +59,61 @@ jobs:
6959
username: ${{ github.actor }}
7060
password: ${{ secrets.GITHUB_TOKEN }}
7161

72-
- name: Extract metadata for Docker
73-
id: meta
74-
uses: docker/metadata-action@v5
75-
with:
76-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
77-
tags: |
78-
type=semver,pattern={{version}},value=v${{ needs.release.outputs.new_release_version }}
79-
type=semver,pattern={{major}}.{{minor}},value=v${{ needs.release.outputs.new_release_version }}
80-
type=raw,value=latest
81-
8262
- name: Build and push Docker image
8363
uses: docker/build-push-action@v5
8464
with:
8565
context: .
8666
push: true
87-
tags: ${{ steps.meta.outputs.tags }}
88-
labels: ${{ steps.meta.outputs.labels }}
67+
tags: |
68+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
69+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ needs.release.outputs.new_release_version }}
8970
cache-from: type=gha
9071
cache-to: type=gha,mode=max
9172

92-
release-chart:
73+
publish-helm:
9374
needs: release
9475
if: needs.release.outputs.new_release_published == 'true'
9576
runs-on: ubuntu-latest
9677
permissions:
9778
contents: write
98-
9979
steps:
10080
- name: Checkout
10181
uses: actions/checkout@v4
82+
with:
83+
fetch-depth: 0
10284

10385
- name: Configure Git
10486
run: |
105-
git config user.name "$GITHUB_ACTOR"
106-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
107-
87+
git config user.name "${{ github.actor }}"
88+
git config user.email "${{ github.actor }}@users.noreply.github.com"
89+
10890
- name: Install Helm
10991
uses: azure/setup-helm@v3
11092
with:
11193
version: v3.12.1
11294

95+
- name: Update chart version
96+
run: |
97+
yq e -i '.version = "${{ needs.release.outputs.new_release_version }}"' charts/github-deploy-key-operator/Chart.yaml
98+
yq e -i '.appVersion = "${{ needs.release.outputs.new_release_version }}"' charts/github-deploy-key-operator/Chart.yaml
99+
113100
- name: Package Helm chart
114101
run: |
115102
mkdir -p .cr-release-packages
116-
helm package charts/github-deploy-key-operator --version ${{ needs.release.outputs.new_release_version }} --destination .cr-release-packages
103+
helm package charts/github-deploy-key-operator --version ${{ needs.release.outputs.new_release_version }} -d .cr-release-packages
117104
118-
- name: Upload Helm chart
119-
uses: actions/upload-artifact@v3
120-
with:
121-
name: helm-chart
122-
path: .cr-release-packages/*.tgz
123-
124-
- name: Download previous charts
105+
- name: Checkout gh-pages branch
125106
run: |
107+
git fetch origin gh-pages || true
126108
git checkout gh-pages || git checkout --orphan gh-pages
127109
git rm -rf . || true
128-
git clean -fxd
129-
mkdir -p charts
130-
131-
- name: Download chart artifact
132-
uses: actions/download-artifact@v3
133-
with:
134-
name: helm-chart
135-
path: charts
110+
git clean -fxd || true
136111
137-
- name: Generate Helm repo index
112+
- name: Update Helm repository
138113
run: |
114+
mkdir -p charts
115+
mv .cr-release-packages/* charts/
139116
helm repo index charts/
140-
cp charts/index.yaml index.yaml
141-
142-
- name: Push to gh-pages
143-
run: |
144117
git add charts/
145-
git add index.yaml
146-
git commit -m "chore: publish helm chart ${{ needs.release.outputs.new_release_version }}"
147-
git push origin gh-pages -f
148-
149-
publish-chart:
150-
needs: release-chart
151-
if: needs.release.outputs.new_release_published == 'true'
152-
runs-on: ubuntu-latest
153-
permissions:
154-
contents: write
155-
pages: write
156-
157-
steps:
158-
- name: Checkout
159-
uses: actions/checkout@v4
160-
with:
161-
fetch-depth: 0
162-
163-
- name: Configure Git
164-
run: |
165-
git config user.name "$GITHUB_ACTOR"
166-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
167-
168-
- name: Install Helm
169-
uses: azure/setup-helm@v3
170-
171-
- name: Update chart version
172-
env:
173-
VERSION: ${{ needs.release.outputs.new_release_version }}
174-
run: |
175-
yq e -i '.version = env(VERSION)' charts/github-deploy-key-operator/Chart.yaml
176-
yq e -i '.appVersion = env(VERSION)' charts/github-deploy-key-operator/Chart.yaml
177-
178-
- name: Package Helm chart
179-
run: |
180-
helm package charts/github-deploy-key-operator
181-
182-
- name: Setup GitHub Pages
183-
uses: actions/configure-pages@v4
184-
185-
- name: Upload GitHub Pages artifact
186-
uses: actions/upload-pages-artifact@v3
187-
with:
188-
path: '.'
189-
190-
- name: Deploy GitHub Pages
191-
uses: actions/deploy-pages@v4
192-
193-
- name: Upload chart to release
194-
uses: softprops/action-gh-release@v1
195-
with:
196-
tag_name: v${{ needs.release.outputs.new_release_version }}
197-
files: github-deploy-key-operator-*.tgz
198-
generate_release_notes: true
118+
git commit -m "chore: publish helm chart v${{ needs.release.outputs.new_release_version }}"
119+
git push origin gh-pages

0 commit comments

Comments
 (0)