Skip to content

Commit 4b691c3

Browse files
authored
ci: fix helm setup action (#3)
1 parent 0160e7c commit 4b691c3

1 file changed

Lines changed: 119 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 119 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: Build and Release Helm Chart
22

33
on:
44
push:
5+
branches:
6+
- main # Main branch updates
57
tags:
6-
- 'v*'
8+
- 'v*' # v* tags for release
79

810
jobs:
911
build-and-release:
@@ -18,18 +20,45 @@ jobs:
1820
fetch-depth: 0
1921

2022
- name: Set up Helm
21-
uses: helm/setup-helm-action@v3
23+
uses: azure/setup-helm@v4.3.0
2224
with:
2325
version: 'latest'
2426

25-
- name: Extract tag version
27+
- name: Extract tag/version information
2628
id: tag
2729
run: |
28-
TAG=${GITHUB_REF#refs/tags/}
30+
# Handle tag push
31+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
32+
TAG=${GITHUB_REF#refs/tags/}
33+
IS_TAG=true
34+
IS_MAIN_BRANCH=false
35+
# Handle main branch push
36+
elif [[ "$GITHUB_REF" == refs/heads/main ]]; then
37+
TAG="latest"
38+
IS_TAG=false
39+
IS_MAIN_BRANCH=true
40+
else
41+
echo "Error: Unexpected ref: $GITHUB_REF"
42+
exit 1
43+
fi
44+
45+
# Extract version from tag (remove 'v' prefix if present)
46+
if [[ "$TAG" == v* ]]; then
47+
VERSION=${TAG#v}
48+
elif [ "$IS_MAIN_BRANCH" == "true" ]; then
49+
# For main branch, use commit SHA as version identifier
50+
VERSION="main-${GITHUB_SHA:0:7}"
51+
else
52+
VERSION=$TAG
53+
fi
54+
2955
echo "tag=$TAG" >> $GITHUB_OUTPUT
30-
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
31-
echo "Tag: $TAG"
32-
echo "Version: ${TAG#v}"
56+
echo "version=$VERSION" >> $GITHUB_OUTPUT
57+
echo "is_tag=$IS_TAG" >> $GITHUB_OUTPUT
58+
echo "is_main_branch=$IS_MAIN_BRANCH" >> $GITHUB_OUTPUT
59+
echo "Tag/Version: $TAG ($VERSION)"
60+
echo "Is Tag: $IS_TAG"
61+
echo "Is Main Branch: $IS_MAIN_BRANCH"
3362
3463
- name: Validate Helm chart
3564
run: |
@@ -52,16 +81,80 @@ jobs:
5281
sha256sum *.tgz > checksums.txt
5382
echo "Generated checksums.txt"
5483
55-
- name: Create GitHub Release
84+
- name: Determine release type
85+
id: release
86+
run: |
87+
IS_V_TAG=false
88+
if [[ "${{ steps.tag.outputs.tag }}" == v* ]]; then
89+
IS_V_TAG=true
90+
fi
91+
92+
# v* tags create normal releases
93+
# main branch updates create/update "latest" release
94+
if [ "${{ steps.tag.outputs.is_tag }}" == "true" ] && [ "$IS_V_TAG" == "true" ]; then
95+
RELEASE_TYPE="tag"
96+
RELEASE_TAG="${{ steps.tag.outputs.tag }}"
97+
elif [ "${{ steps.tag.outputs.is_main_branch }}" == "true" ]; then
98+
RELEASE_TYPE="latest"
99+
RELEASE_TAG="latest"
100+
else
101+
RELEASE_TYPE="none"
102+
RELEASE_TAG=""
103+
fi
104+
105+
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
106+
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
107+
echo "should_release=$([ "$RELEASE_TYPE" != "none" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
108+
echo "Release Type: $RELEASE_TYPE"
109+
echo "Release Tag: $RELEASE_TAG"
110+
111+
- name: Create/Update GitHub Release (v* tag)
112+
if: steps.release.outputs.release_type == 'tag'
56113
uses: softprops/action-gh-release@v2
57114
with:
58-
name: Release ${{ steps.tag.outputs.tag }}
115+
tag_name: ${{ steps.release.outputs.release_tag }}
116+
name: Release ${{ steps.release.outputs.release_tag }}
59117
body: |
60-
## Helm Chart Release ${{ steps.tag.outputs.tag }}
118+
## Helm Chart Release ${{ steps.release.outputs.release_tag }}
61119
62120
### Chart Information
63121
- **Chart Version**: ${{ steps.tag.outputs.version }}
64-
- **Tag**: ${{ steps.tag.outputs.tag }}
122+
- **Tag**: ${{ steps.release.outputs.release_tag }}
123+
- **Commit**: ${{ github.sha }}
124+
125+
### Installation
126+
127+
```bash
128+
helm install curvine ./helm/dist/${{ steps.package.outputs.chart_name }}
129+
```
130+
131+
### Files
132+
- Chart package: `${{ steps.package.outputs.chart_name }}`
133+
- Checksums: `checksums.txt`
134+
files: |
135+
helm/dist/*.tgz
136+
helm/dist/checksums.txt
137+
draft: false
138+
prerelease: ${{ contains(steps.release.outputs.release_tag, '-') || contains(steps.release.outputs.release_tag, 'alpha') || contains(steps.release.outputs.release_tag, 'beta') || contains(steps.release.outputs.release_tag, 'rc') }}
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
142+
- name: Create/Update GitHub Release (main branch -> latest)
143+
if: steps.release.outputs.release_type == 'latest'
144+
uses: softprops/action-gh-release@v2
145+
with:
146+
tag_name: latest
147+
name: Latest Release (main branch)
148+
body: |
149+
## Latest Helm Chart Release
150+
151+
This release is automatically updated on every push to the `main` branch.
152+
153+
### Chart Information
154+
- **Version**: ${{ steps.tag.outputs.version }}
155+
- **Branch**: main
156+
- **Commit**: ${{ github.sha }}
157+
- **Commit Message**: ${{ github.event.head_commit.message }}
65158
66159
### Installation
67160
@@ -72,11 +165,13 @@ jobs:
72165
### Files
73166
- Chart package: `${{ steps.package.outputs.chart_name }}`
74167
- Checksums: `checksums.txt`
168+
169+
> **Note**: This is an automatically updated release. For stable versions, use tagged releases (v*).
75170
files: |
76171
helm/dist/*.tgz
77172
helm/dist/checksums.txt
78173
draft: false
79-
prerelease: ${{ contains(steps.tag.outputs.tag, '-') || contains(steps.tag.outputs.tag, 'alpha') || contains(steps.tag.outputs.tag, 'beta') || contains(steps.tag.outputs.tag, 'rc') }}
174+
prerelease: false
80175
env:
81176
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82177

@@ -88,4 +183,16 @@ jobs:
88183
helm/dist/*.tgz
89184
helm/dist/checksums.txt
90185
retention-days: 90
186+
187+
- name: Build Summary
188+
run: |
189+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
190+
echo "- **Tag/Version**: ${{ steps.tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
191+
echo "- **Chart Version**: ${{ steps.tag.outputs.version }}" >> $GITHUB_STEP_SUMMARY
192+
echo "- **Chart Package**: ${{ steps.package.outputs.chart_name }}" >> $GITHUB_STEP_SUMMARY
193+
echo "- **Release Type**: ${{ steps.release.outputs.release_type }}" >> $GITHUB_STEP_SUMMARY
194+
echo "- **Release Tag**: ${{ steps.release.outputs.release_tag }}" >> $GITHUB_STEP_SUMMARY
195+
echo "- **Is Tag**: ${{ steps.tag.outputs.is_tag }}" >> $GITHUB_STEP_SUMMARY
196+
echo "- **Is Main Branch**: ${{ steps.tag.outputs.is_main_branch }}" >> $GITHUB_STEP_SUMMARY
197+
echo "- **GitHub Release Created**: ${{ steps.release.outputs.should_release }}" >> $GITHUB_STEP_SUMMARY
91198

0 commit comments

Comments
 (0)