Skip to content

Commit 7fae16a

Browse files
author
gurghet
committed
fix: semantic release outputs and helm publishing
1 parent 7951053 commit 7fae16a

1 file changed

Lines changed: 18 additions & 20 deletions

File tree

.github/workflows/release.yaml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,32 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Setup Node.js
33-
uses: actions/setup-node@v3
33+
uses: actions/setup-node@v4
3434
with:
35-
node-version: "lts/*"
35+
node-version: 'lts/*'
3636

3737
- name: Install dependencies
3838
run: npm install -g semantic-release @semantic-release/git @semantic-release/github
3939

40-
- name: Create Release
40+
- name: Release
4141
id: semantic_release
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444
run: |
4545
NEW_VERSION=$(npx semantic-release --dry-run | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+' || true)
4646
if [ -n "$NEW_VERSION" ]; then
4747
echo "new_release_version=$NEW_VERSION" >> $GITHUB_OUTPUT
48+
echo "new_release_published=true" >> $GITHUB_OUTPUT
4849
npx semantic-release
4950
else
5051
echo "No new version to be released"
51-
exit 0
52+
echo "new_release_version=" >> $GITHUB_OUTPUT
53+
echo "new_release_published=false" >> $GITHUB_OUTPUT
5254
fi
5355
5456
build-and-push:
5557
needs: release
56-
if: needs.release.outputs.new_release_version != ''
58+
if: needs.release.outputs.new_release_published == 'true'
5759
runs-on: ubuntu-latest
5860
permissions:
5961
contents: read
@@ -77,41 +79,37 @@ jobs:
7779
with:
7880
context: .
7981
push: true
80-
tags: ghcr.io/${{ github.repository }}/operator:latest
82+
tags: |
83+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
84+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.new_release_version }}
8185
cache-from: type=gha
8286
cache-to: type=gha,mode=max
8387

8488
publish-helm:
8589
needs: release
86-
if: needs.release.outputs.new_release_version != ''
90+
if: needs.release.outputs.new_release_published == 'true'
8791
runs-on: ubuntu-latest
8892
permissions:
8993
contents: write
9094
steps:
9195
- name: Checkout
9296
uses: actions/checkout@v4
93-
with:
94-
fetch-depth: 0
95-
96-
- name: Configure Git
97-
run: |
98-
git config user.name "${{ github.actor }}"
99-
git config user.email "${{ github.actor }}@users.noreply.github.com"
10097

10198
- name: Install Helm
10299
uses: azure/setup-helm@v3
103100
with:
104101
version: v3.12.1
105102

106-
- name: Install yq
103+
- name: Configure Git
107104
run: |
108-
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
109-
sudo chmod a+x /usr/local/bin/yq
105+
git config user.name "${{ github.actor }}"
106+
git config user.email "${{ github.actor }}@users.noreply.github.com"
110107
111-
- name: Update chart version
108+
- name: Update Helm chart version
112109
run: |
113-
yq e -i '.version = "${{ needs.release.outputs.new_release_version }}"' charts/github-deploy-key-operator/Chart.yaml
114-
yq e -i '.appVersion = "${{ needs.release.outputs.new_release_version }}"' charts/github-deploy-key-operator/Chart.yaml
110+
VERSION=${{ needs.release.outputs.new_release_version }}
111+
sed -i "s/^version:.*$/version: $VERSION/" charts/github-deploy-key-operator/Chart.yaml
112+
sed -i "s/^appVersion:.*$/appVersion: \"$VERSION\"/" charts/github-deploy-key-operator/Chart.yaml
115113
116114
- name: Package Helm chart
117115
run: |

0 commit comments

Comments
 (0)