Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add artifacthub.io/changes changelog annotation to the released chart #949

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 37 additions & 27 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,20 @@ 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: Retrieve version from Chart.yaml
id: chart_version
run: |
echo "version=$(yq '.version' charts/jenkins/Chart.yaml)" >> "${GITHUB_OUTPUT}"

- name: Extract last tag changelog
id: last_tag_changelog
if: steps.chart_releaser.outputs.changed_charts != ''
- 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
Expand All @@ -63,11 +49,35 @@ jobs:
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: |
# Remove first line if empty and replace emojis by spaces (issue with yq/chart-releaser which break multiline)
# shellcheck disable=SC2016
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}")
Expand All @@ -77,7 +87,7 @@ jobs:
delimiter="$(openssl rand -hex 8)"
# shellcheck disable=SC2129
echo "body<<${delimiter}" >> "${GITHUB_OUTPUT}"
echo "${release}" | jq '.body' >> "${GITHUB_OUTPUT}"
echo "${release}" | jq --raw-output '.body' >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"

- name: Update release description
Expand All @@ -87,15 +97,15 @@ 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 {
await github.rest.repos.updateRelease({
release_id: process.env.ID,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.BODY.slice(1, -1) + "\r\n\r\n## Changelog" + process.env.CHANGELOG,
body: process.env.BODY + "\r\n\r\n## Changelog" + process.env.CHANGELOG,
});
} catch (error) {
core.setFailed(error.message);
Expand Down
5 changes: 4 additions & 1 deletion charts/jenkins/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ Use the following links to reference issues, PRs, and commits prior to v2.6.0.
The changelog until v1.5.7 was auto-generated based on git commits.
Those entries include a reference to the git commit to be able to get more details.

## 4.8.4

Add `artifacthub.io/changes` changelog annotation to the released chart.

## 4.8.3

Update Jenkins image and appVersion to jenkins lts release version 2.426.1


## 4.8.2

Add the ability to modify `retentionTimeout` and `waitForPodSec` default value in JCasC
Expand Down
2 changes: 1 addition & 1 deletion charts/jenkins/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: jenkins
home: https://jenkins.io/
version: 4.8.3
version: 4.8.4
appVersion: 2.426.1
description: Jenkins - Build great things at any scale! The leading open source automation server, Jenkins provides over 1800 plugins to support building, deploying and automating any project.
sources:
Expand Down