-
Notifications
You must be signed in to change notification settings - Fork 890
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
artifacthub.io/changes
changelog annotation to the relea…
…sed chart
- Loading branch information
1 parent
a052ad9
commit e548335
Showing
3 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,50 +24,64 @@ jobs: | |
with: | ||
version: v3.12.0 | ||
|
||
- name: Run chart-releaser | ||
id: chart_releaser | ||
uses: helm/[email protected] | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
# Retrieve last tag pushed by cr | ||
- name: Checkout | ||
if: steps.chart_releaser.outputs.changed_charts != '' | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get Last Tag | ||
id: last_tag | ||
if: steps.chart_releaser.outputs.changed_charts != '' | ||
run: echo "tag=$(git describe --abbrev=0 --tags)" >> "${GITHUB_OUTPUT}" | ||
|
||
- name: Extract last tag changelog | ||
id: last_tag_changelog | ||
if: steps.chart_releaser.outputs.changed_charts != '' | ||
- name: Retrieve version from Chart.yaml | ||
id: chart_version | ||
run: | | ||
echo "version=$(yq '.version' charts/jenkins/Chart.yaml)" >> "${GITHUB_OUTPUT}" | ||
- name: Extract version changelog | ||
id: version_changelog | ||
env: | ||
LAST_TAG: ${{ steps.last_tag.outputs.tag }} | ||
VERSION: ${{ steps.chart_version.outputs.version }} | ||
run: | | ||
changelog=$(awk -v tag="${LAST_TAG#jenkins-}" ' | ||
changelog=$(awk -v version="${VERSION}" ' | ||
/^(##|###) [0-9]+.[0-9]+.[0-9]+/ { | ||
if (p) { exit }; | ||
if ($2 == tag) { | ||
if ($2 == version) { | ||
p = 1; next | ||
} | ||
} p | ||
' charts/jenkins/CHANGELOG.md) | ||
# Remove first line if empty | ||
changelog=$(echo "${changelog}") | ||
delimiter="$(openssl rand -hex 8)" | ||
# shellcheck disable=SC2129 | ||
echo "changelog<<${delimiter}" >> "${GITHUB_OUTPUT}" | ||
echo "${changelog}" >> "${GITHUB_OUTPUT}" | ||
echo "${delimiter}" >> "${GITHUB_OUTPUT}" | ||
- name: Annotate Chart.yaml with version changelog | ||
if: steps.version_changelog.outputs.changelog != '' | ||
env: | ||
CHANGELOG: ${{steps.version_changelog.outputs.changelog}} | ||
run: | | ||
# Cleanup changelog: | ||
# - Remove first line if empty | ||
# - Replace emojis by spaces (issue with yq/chart-releaser which break multiline) | ||
stripped_changelog=$(echo "$CHANGELOG" | sed -e '2,$b' -e '/^$/d' | iconv -c -f utf8 -t ascii) | ||
# - Remove leading spaces | ||
stripped_changelog="${stripped_changelog#"${stripped_changelog%%[![:space:]]*}"}" | ||
# Update chart annotations | ||
yq --inplace ".annotations.\"artifacthub.io/changes\" = \"${stripped_changelog}\"" charts/jenkins/Chart.yaml | ||
- name: Show updated Chart.yaml | ||
run: | | ||
yq charts/jenkins/Chart.yaml | ||
- name: Run chart-releaser | ||
id: chart_releaser | ||
uses: helm/[email protected] | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Retrieve release info | ||
id: release_info | ||
if: steps.chart_releaser.outputs.changed_charts != '' | ||
env: | ||
LAST_TAG: ${{ steps.last_tag.outputs.tag }} | ||
LAST_TAG: "jenkins-${{ steps.chart_version.outputs.version }}" | ||
REPOSITORY: ${{ github.repository }} | ||
run: | | ||
release=$(curl -L "https://api.github.com/repos/${REPOSITORY}/releases/tags/${LAST_TAG}") | ||
|
@@ -87,7 +101,7 @@ jobs: | |
env: | ||
ID: ${{ steps.release_info.outputs.id }} | ||
BODY: ${{steps.release_info.outputs.body}} | ||
CHANGELOG: ${{steps.last_tag_changelog.outputs.changelog}} | ||
CHANGELOG: ${{steps.version_changelog.outputs.changelog}} | ||
with: | ||
script: | | ||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters