Skip to content

Commit 6b13d0a

Browse files
author
gurghet
committed
feat: add semantic-release and OCI helm chart publishing
1 parent b3b7380 commit 6b13d0a

2 files changed

Lines changed: 91 additions & 3 deletions

File tree

.github/workflows/release.yaml

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,65 @@ on:
66
- master
77

88
permissions:
9+
contents: write
910
packages: write
1011

1112
env:
1213
REGISTRY: ghcr.io
1314
IMAGE_NAME: ${{ github.repository }}/operator
1415

1516
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
21+
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
22+
permissions:
23+
contents: write
24+
issues: write
25+
pull-requests: write
26+
packages: write
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
persist-credentials: false
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "lts/*"
38+
cache: 'npm'
39+
40+
- name: Install dependencies
41+
run: |
42+
npm init -y
43+
npm install --save-dev \
44+
semantic-release \
45+
@semantic-release/git \
46+
@semantic-release/changelog \
47+
@semantic-release/github
48+
49+
- name: Semantic Release
50+
id: semantic
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: npx semantic-release
54+
1655
build-and-push:
56+
needs: release
57+
if: needs.release.outputs.new_release_published == 'true'
1758
runs-on: ubuntu-latest
1859
permissions:
1960
contents: read
2061
packages: write
2162
steps:
2263
- name: Checkout
2364
uses: actions/checkout@v4
65+
with:
66+
fetch-depth: 0
67+
ref: master
2468

2569
- name: Set up Docker Buildx
2670
uses: docker/setup-buildx-action@v3
@@ -40,5 +84,44 @@ jobs:
4084
platforms: linux/amd64,linux/arm64
4185
tags: |
4286
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
87+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.new_release_version }}
4388
cache-from: type=gha
44-
cache-to: type=gha,mode=max
89+
cache-to: type=gha,mode=max
90+
91+
publish-helm:
92+
needs: [release, build-and-push]
93+
if: needs.release.outputs.new_release_published == 'true'
94+
runs-on: ubuntu-latest
95+
permissions:
96+
packages: write
97+
steps:
98+
- name: Checkout
99+
uses: actions/checkout@v4
100+
with:
101+
fetch-depth: 0
102+
ref: master
103+
104+
- name: Install Helm
105+
uses: azure/setup-helm@v3
106+
107+
- name: Update Chart version
108+
uses: mikefarah/yq@master
109+
with:
110+
cmd: yq -i '.version = "${{ needs.release.outputs.new_release_version }}"' 'charts/github-deploy-key-operator/Chart.yaml'
111+
112+
- name: Update Chart appVersion
113+
uses: mikefarah/yq@master
114+
with:
115+
cmd: yq -i '.appVersion = "${{ needs.release.outputs.new_release_version }}"' 'charts/github-deploy-key-operator/Chart.yaml'
116+
117+
- name: Log in to GitHub Container Registry
118+
uses: docker/login-action@v3
119+
with:
120+
registry: ${{ env.REGISTRY }}
121+
username: ${{ github.actor }}
122+
password: ${{ secrets.GITHUB_TOKEN }}
123+
124+
- name: Push Helm chart to OCI registry
125+
run: |
126+
helm package charts/github-deploy-key-operator
127+
helm push github-deploy-key-operator-${{ needs.release.outputs.new_release_version }}.tgz oci://${{ env.REGISTRY }}/${{ github.repository }}

.releaserc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"plugins": [
44
"@semantic-release/commit-analyzer",
55
"@semantic-release/release-notes-generator",
6-
"@semantic-release/github"
6+
"@semantic-release/changelog",
7+
"@semantic-release/github",
8+
["@semantic-release/git", {
9+
"assets": ["CHANGELOG.md", "charts/github-deploy-key-operator/Chart.yaml"],
10+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
11+
}]
712
]
8-
}
13+
}

0 commit comments

Comments
 (0)