Skip to content

Commit c77c7f5

Browse files
committed
ci: fix release action
1 parent 1fd7efd commit c77c7f5

4 files changed

Lines changed: 125 additions & 84 deletions

File tree

.chglog/CHANGELOG.tpl.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{ range .Versions }}
2+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
3+
4+
{{ range .CommitGroups -}}
5+
### {{ .Title }}
6+
7+
{{ range .Commits -}}
8+
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
9+
{{ end }}
10+
{{ end -}}
11+
{{ end -}}

.chglog/config.yml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
style: github
2-
template: |
3-
## {{ if .PreviousTag }}[{{ .Version }}]({{ .Info.RepositoryURL }}/compare/{{ .PreviousTag }}...{{ .Version }}){{ else }}{{ .Version }}{{ end }} - {{ .Info.Date.Format "2006-01-02" }}
4-
5-
{{ range .Commits -}}
6-
{{- if or (contains .Commit.Header "feat") (contains .Commit.Header "fix") (contains .Commit.Header "docs") }}
7-
{{- if or (contains .Commit.Header "refactor") (contains .Commit.Header "perf") (contains .Commit.Header "test") }}
8-
{{- if or (contains .Commit.Header "build") (contains .Commit.Header "ci") (contains .Commit.Header "chore") }}
9-
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
10-
{{ end -}}{{ end -}}{{ end -}}
11-
{{ end }}
12-
2+
template: CHANGELOG.tpl.md
133
info:
144
title: CHANGELOG
155
repository_url: https://github.com/wikodit/charts
166
options:
17-
commit_filters:
18-
Type:
19-
- feat
20-
- fix
21-
- docs
22-
- refactor
23-
- perf
24-
- test
25-
- build
26-
- ci
27-
- chore
7+
commits:
8+
sort_by: Scope
9+
filters:
10+
Type:
11+
- feat
12+
- fix
13+
- perf
14+
- refactor
15+
- docs
16+
- test
17+
- build
18+
- ci
19+
- chore
20+
commit_groups:
21+
title_maps:
22+
feat: Features
23+
fix: Bug Fixes
24+
perf: Performance Improvements
25+
refactor: Code Refactoring
26+
docs: Documentation
27+
test: Tests
28+
build: Build System
29+
ci: CI/CD
30+
chore: Chores
2831
header:
2932
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?!?: (.*)$"
30-
maps:
31-
- Type: 1
32-
- Scope: 2
33-
- Subject: 3
33+
pattern_maps:
34+
- Type
35+
- Scope
36+
- Subject
3437
notes:
3538
keywords:
3639
- BREAKING CHANGE

.github/workflows/release.yaml

Lines changed: 81 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020

2121
concurrency:
2222
group: release-${{ github.ref }}
23-
cancel-in-progress: 'false'
23+
cancel-in-progress: false
2424

2525
env:
2626
GHCR_REGISTRY: ghcr.io
@@ -53,17 +53,18 @@ jobs:
5353
# Manual trigger with specific chart
5454
CHARTS='["${{ inputs.chart }}"]'
5555
else
56-
# Auto-detect using chart-testing
57-
# Use main as target branch for push events
58-
TARGET_BRANCH="main"
59-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
60-
TARGET_BRANCH="${{ github.base_ref }}"
61-
fi
62-
63-
changed=$(ct list-changed --config ct.yaml --target-branch $TARGET_BRANCH 2>/dev/null || echo "")
64-
if [[ -z "$changed" ]]; then
65-
# Fallback: check git diff
66-
changed=$(git diff --name-only origin/$TARGET_BRANCH HEAD -- charts/ 2>/dev/null | grep -oP 'charts/\K[^/]+' | sort -u || echo "")
56+
# For push events, compare with the commit before the push
57+
if [[ "${{ github.event_name }}" == "push" ]]; then
58+
BEFORE_SHA="${{ github.event.before }}"
59+
if [[ "$BEFORE_SHA" == "0000000000000000000000000000000000000000" ]]; then
60+
# Initial push, check all charts
61+
changed=$(ls -d charts/*/ 2>/dev/null | xargs -I{} basename {} || echo "")
62+
else
63+
changed=$(git diff --name-only "$BEFORE_SHA" HEAD -- charts/ | grep -oP 'charts/\K[^/]+' | sort -u || echo "")
64+
fi
65+
else
66+
# For other events (workflow_dispatch without chart input)
67+
changed=$(git diff --name-only origin/main HEAD -- charts/ 2>/dev/null | grep -oP 'charts/\K[^/]+' | sort -u || echo "")
6768
fi
6869
6970
if [[ -n "$changed" ]]; then
@@ -147,21 +148,21 @@ jobs:
147148
# Check for features
148149
elif echo "$COMMITS" | grep -qiE '^[a-f0-9]+ feat'; then
149150
BUMP_TYPE="minor"
150-
# Check for fixes or any other changes
151-
elif echo "$COMMITS" | grep -qiE '^[a-f0-9]+ (fix|perf|refactor|docs|style|test|chore|ci|build)'; then
152-
BUMP_TYPE="patch"
153-
elif [[ -n "$COMMITS" ]]; then
154-
# Any other commits default to patch
151+
# Check for fixes or performance improvements
152+
elif echo "$COMMITS" | grep -qiE '^[a-f0-9]+ (fix|perf)'; then
155153
BUMP_TYPE="patch"
156154
fi
157155
158156
echo "Bump type: ${BUMP_TYPE}"
159157
160158
if [[ "$BUMP_TYPE" == "none" ]]; then
161-
echo "::error::No commits found since last release. Nothing to bump."
162-
exit 1
159+
echo "::notice::No releasable commits found (need feat, fix, or perf). Skipping automatic release."
160+
echo "skip=true" >> "$GITHUB_OUTPUT"
161+
exit 0
163162
fi
164163
164+
echo "skip=false" >> "$GITHUB_OUTPUT"
165+
165166
# Calculate new version
166167
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
167168
@@ -184,6 +185,7 @@ jobs:
184185
echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
185186
186187
- name: Update Chart.yaml version
188+
if: steps.version-bump.outputs.skip != 'true'
187189
id: update-version
188190
run: |
189191
CHART_PATH="charts/${{ matrix.chart }}"
@@ -197,6 +199,7 @@ jobs:
197199
cat "${CHART_PATH}/Chart.yaml"
198200
199201
- name: Get chart info
202+
if: steps.version-bump.outputs.skip != 'true'
200203
id: chart-info
201204
run: |
202205
CHART_PATH="charts/${{ matrix.chart }}"
@@ -220,6 +223,7 @@ jobs:
220223
echo "App Version: ${APP_VERSION}"
221224
222225
- name: Check if version already released
226+
if: steps.version-bump.outputs.skip != 'true'
223227
id: check-version
224228
run: |
225229
TAG="${{ steps.chart-info.outputs.tag }}"
@@ -237,63 +241,68 @@ jobs:
237241
fi
238242
239243
- name: Update dependencies
244+
if: steps.version-bump.outputs.skip != 'true'
240245
run: |
241246
helm dependency update "${{ steps.chart-info.outputs.path }}" || true
242247
248+
- name: Regenerate README
249+
if: steps.version-bump.outputs.skip != 'true'
250+
run: |
251+
# Install helm-docs
252+
HELM_DOCS_VERSION="1.14.2"
253+
wget -O helm-docs.tar.gz "https://github.com/norwoodj/helm-docs/releases/download/v${HELM_DOCS_VERSION}/helm-docs_${HELM_DOCS_VERSION}_Linux_x86_64.tar.gz"
254+
tar xzf helm-docs.tar.gz
255+
sudo mv helm-docs /usr/local/bin/
256+
257+
# Regenerate README for this chart
258+
helm-docs --chart-search-root "${{ steps.chart-info.outputs.path }}" --template-files README.md.gotmpl
259+
echo "Regenerated README for ${{ steps.chart-info.outputs.name }}"
260+
243261
- name: Generate CHANGELOG
262+
if: steps.version-bump.outputs.skip != 'true'
263+
id: changelog
244264
run: |
245265
# Install git-chglog
246-
wget -O git-chglog.tar.gz https://github.com/git-chglog/git-chglog/releases/latest/download/git-chglog_linux_amd64.tar.gz
266+
CHGLOG_VERSION="0.15.4"
267+
wget -O git-chglog.tar.gz "https://github.com/git-chglog/git-chglog/releases/download/v${CHGLOG_VERSION}/git-chglog_${CHGLOG_VERSION}_linux_amd64.tar.gz"
247268
tar xzf git-chglog.tar.gz
248269
sudo mv git-chglog /usr/local/bin/
249270
250-
# Generate changelog for this chart
251271
CHANGELOG_PATH="${{ steps.chart-info.outputs.path }}/CHANGELOG.md"
272+
NEW_TAG="${{ steps.chart-info.outputs.name }}-v${{ steps.chart-info.outputs.version }}"
252273
253-
# Get previous tag for this chart
254-
PREV_TAG=$(git tag --list "${{ steps.chart-info.outputs.name }}-*" --sort=-version:refname | sed -n '2p' || echo "")
274+
# Create temporary tag for git-chglog
275+
git tag "$NEW_TAG"
255276
256-
if [[ -f "$CHANGELOG_PATH" ]]; then
257-
# Backup existing changelog
258-
cp "$CHANGELOG_PATH" "$CHANGELOG_PATH.bak"
259-
fi
277+
# Generate full changelog for this chart (all versions, only this chart's commits)
278+
git-chglog --config .chglog/config.yml --output "$CHANGELOG_PATH" --tag-filter-pattern "${{ steps.chart-info.outputs.name }}-v.*" --path "${{ steps.chart-info.outputs.path }}"
260279
261-
# Generate new changelog entry
262-
if [[ -n "$PREV_TAG" ]]; then
263-
git-chglog --config .chglog/config.yml --output "$CHANGELOG_PATH" "$PREV_TAG..HEAD" --path "${{ steps.chart-info.outputs.path }}"
264-
else
265-
git-chglog --config .chglog/config.yml --output "$CHANGELOG_PATH" --path "${{ steps.chart-info.outputs.path }}"
266-
fi
267-
268-
# If backup exists, prepend new entries to it
269-
if [[ -f "$CHANGELOG_PATH.bak" ]]; then
270-
echo "# Changelog" > temp_changelog
271-
echo "" >> temp_changelog
272-
cat "$CHANGELOG_PATH" >> temp_changelog
273-
echo "" >> temp_changelog
274-
tail -n +2 "$CHANGELOG_PATH.bak" >> temp_changelog
275-
mv temp_changelog "$CHANGELOG_PATH"
276-
rm "$CHANGELOG_PATH.bak"
277-
else
278-
# Add header if this is a new changelog
279-
{ echo "# Changelog"; echo ""; cat "$CHANGELOG_PATH"; } > temp_changelog
280-
mv temp_changelog "$CHANGELOG_PATH"
281-
fi
280+
# Remove temporary tag (GitHub release will create it)
281+
git tag -d "$NEW_TAG"
282282
283283
echo "Generated CHANGELOG for ${{ steps.chart-info.outputs.name }}"
284284
285+
# Extract changelog for release body
286+
CHANGELOG_CONTENT=$(cat "$CHANGELOG_PATH" | head -100)
287+
echo "changelog<<EOF" >> "$GITHUB_OUTPUT"
288+
echo "$CHANGELOG_CONTENT" >> "$GITHUB_OUTPUT"
289+
echo "EOF" >> "$GITHUB_OUTPUT"
290+
285291
- name: Package chart
292+
if: steps.version-bump.outputs.skip != 'true'
286293
run: |
287294
mkdir -p .packaged
288295
helm package "${{ steps.chart-info.outputs.path }}" -d .packaged/
289296
echo "Packaged: .packaged/${{ steps.chart-info.outputs.name }}-${{ steps.chart-info.outputs.version }}.tgz"
290297
291298
- name: Login to GHCR
299+
if: steps.version-bump.outputs.skip != 'true'
292300
run: |
293301
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.GHCR_REGISTRY }} \
294302
-u ${{ github.actor }} --password-stdin
295303
296304
- name: Push to GHCR
305+
if: steps.version-bump.outputs.skip != 'true'
297306
id: push-ghcr
298307
run: |
299308
PACKAGE=".packaged/${{ steps.chart-info.outputs.name }}-${{ steps.chart-info.outputs.version }}.tgz"
@@ -307,6 +316,7 @@ jobs:
307316
COSIGN_EXPERIMENTAL: "true"
308317

309318
- name: Sign chart in GHCR (keyless)
319+
if: steps.version-bump.outputs.skip != 'true'
310320
env:
311321
COSIGN_EXPERIMENTAL: "1"
312322
run: |
@@ -320,13 +330,13 @@ jobs:
320330
echo "Signed ${IMAGE}"
321331
322332
- name: Login to Harbor
323-
if: vars.HARBOR_REGISTRY != ''
333+
if: steps.version-bump.outputs.skip != 'true' && vars.HARBOR_REGISTRY != ''
324334
run: |
325335
echo "${{ secrets.HARBOR_PASSWORD }}" | helm registry login ${{ vars.HARBOR_REGISTRY }} \
326336
-u "${{ secrets.HARBOR_USERNAME }}" --password-stdin
327337
328338
- name: Push to Harbor
329-
if: vars.HARBOR_REGISTRY != ''
339+
if: steps.version-bump.outputs.skip != 'true' && vars.HARBOR_REGISTRY != ''
330340
run: |
331341
PACKAGE=".packaged/${{ steps.chart-info.outputs.name }}-${{ steps.chart-info.outputs.version }}.tgz"
332342
HARBOR_REPO="${{ vars.HARBOR_REGISTRY }}/${{ vars.HARBOR_PROJECT || 'library' }}"
@@ -335,7 +345,7 @@ jobs:
335345
echo "Pushed to Harbor"
336346
337347
- name: Sign chart in Harbor (keyless)
338-
if: vars.HARBOR_REGISTRY != ''
348+
if: steps.version-bump.outputs.skip != 'true' && vars.HARBOR_REGISTRY != ''
339349
env:
340350
COSIGN_EXPERIMENTAL: "1"
341351
run: |
@@ -349,6 +359,7 @@ jobs:
349359
echo "Signed ${IMAGE}"
350360
351361
- name: Generate SBOM
362+
if: steps.version-bump.outputs.skip != 'true'
352363
run: |
353364
# Generate SBOM for the chart
354365
PACKAGE=".packaged/${{ steps.chart-info.outputs.name }}-${{ steps.chart-info.outputs.version }}.tgz"
@@ -374,6 +385,7 @@ jobs:
374385
echo "Generated SBOM"
375386
376387
- name: Create GitHub Release
388+
if: steps.version-bump.outputs.skip != 'true'
377389
uses: softprops/action-gh-release@v2
378390
with:
379391
tag_name: ${{ steps.chart-info.outputs.tag }}
@@ -399,24 +411,31 @@ jobs:
399411
--certificate-identity-regexp='https://github.com/${{ github.repository }}' \
400412
--certificate-oidc-issuer='https://token.actions.githubusercontent.com'
401413
```
414+
415+
---
416+
417+
${{ steps.changelog.outputs.changelog }}
402418
files: |
403419
.packaged/${{ steps.chart-info.outputs.name }}-${{ steps.chart-info.outputs.version }}.tgz
404420
.packaged/${{ steps.chart-info.outputs.name }}-${{ steps.chart-info.outputs.version }}.sbom.json
405-
generate_release_notes: true
421+
generate_release_notes: false
406422
make_latest: true
407423
env:
408424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
409425

410426
- name: Commit CHANGELOG
411-
if: success()
427+
if: success() && steps.version-bump.outputs.skip != 'true'
412428
run: |
413429
# Configure git
414430
git config --local user.email "github-actions[bot]@users.noreply.github.com"
415431
git config --local user.name "github-actions[bot]"
416432
417-
# Add Chart.yaml (version bump) and CHANGELOG
418-
git add "${{ steps.chart-info.outputs.path }}/Chart.yaml"
419-
git add "${{ steps.chart-info.outputs.path }}/CHANGELOG.md"
433+
# Show what files were modified
434+
echo "Modified files:"
435+
git status --short
436+
437+
# Add all changes from this chart (including Chart.lock from dependency update)
438+
git add "${{ steps.chart-info.outputs.path }}/"
420439
421440
# Check if there are changes to commit
422441
if git diff --staged --quiet; then
@@ -426,15 +445,19 @@ jobs:
426445
-m "Bump version from ${{ steps.version-bump.outputs.current_version }} to ${{ steps.version-bump.outputs.new_version }}" \
427446
-m "Update CHANGELOG.md"
428447
429-
# Pull latest changes to avoid conflicts
430-
git pull --rebase origin main
448+
# Fetch and rebase (discard any untracked/modified files outside chart)
449+
git checkout -- . || true
450+
git clean -fd || true
451+
git fetch origin main
452+
git rebase origin/main
431453
432454
# Push changes
433455
git push https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git main
434456
echo "Version bump and CHANGELOG committed and pushed"
435457
fi
436458
437459
- name: Summary
460+
if: steps.version-bump.outputs.skip != 'true'
438461
run: |
439462
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
440463
## Release Summary

charts/wik-webservice/templates/NOTES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@
5454
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
5555

5656
📚 Documentation: https://github.com/wikodit/charts/tree/main/charts/{{ .Chart.Name }}
57+
🐛 Issues: https://github.com/wikodit/charts/issues
58+
59+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
60+
Maintained by Wikodit | https://www.wikodit.fr

0 commit comments

Comments
 (0)