[bitnami/*] ci: 👷 Add tag and changelog support (#25359)

* [bitnami/*] chore: 👷 Add tag and changelog support

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

* perf:  Avoid fetching the index branch

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

* chore: 🔧 Do not scan CHANGELOG.md files

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

* chore: 🙈 Update .helmignore files

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

* refactor: ♻️ Separate push-tag section

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

---------

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>
This commit is contained in:
Javier J. Salmerón-García
2024-05-21 10:24:21 +02:00
committed by GitHub
parent c4196e0c9a
commit 91c707c9e4
112 changed files with 279 additions and 2 deletions

View File

@@ -109,7 +109,7 @@ jobs:
helm plugin add https://github.com/zoobab/helm_file_repo
- id: update-index
name: Fetch chart and update index
env:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PUBLISH_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PUBLISH_SECRET_ACCESS_KEY }}
AWS_ASSUME_ROLE_ARN: ${{ secrets.AWS_PUBLISH_ROLE_ARN }}
@@ -164,6 +164,30 @@ jobs:
echo "Could not update the index after $max_attempts attempts"
exit 1
fi
push-tag:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- get-chart
- vib-publish
name: Push tag
if: ${{ needs.get-chart.outputs.result == 'ok' }}
steps:
- id: push-tag
name: 'Push tag'
env:
CHART: ${{ needs.get-chart.outputs.chart }}
run: |
cd charts
# Get chart version and list of tags
chart_version="$(yq e '.version' bitnami/${CHART}/Chart.yaml)"
git fetch --tags
# If the tag does not exist, create and push it (this allows re-executing the job)
if ! git tag | grep ${CHART}/${chart_version}; then
git tag ${CHART}/${chart_version}
git push --tags
fi
# If the CD Pipeline does not succeed we should notify the interested agents
slack-notif:
runs-on: ubuntu-latest

View File

@@ -92,7 +92,7 @@ jobs:
update-pr:
runs-on: ubuntu-latest
needs: [get-chart]
name: Automatically update README and CRDs
name: Automatically update README, CRDs and CHANGELOG
permissions:
contents: write
outputs:
@@ -109,6 +109,40 @@ jobs:
run: |
git config user.name "Bitnami Containers"
git config user.email "bitnami-bot@vmware.com"
# In order to avoid doing a full clone (which would fetch the index branch), we
# unshallow the clone only using the main branch. We need to get the tags to
# regenerate the changelog too
- name: Unshallow main branch and get tags
run: |
git fetch origin main --unshallow
git fetch --tags
- name: Install conventional-changelog-cli
run: npm install -g conventional-changelog-cli
- id: generate-changelog
name: Generate changelog
env:
CHART: ${{ needs.get-chart.outputs.chart }}
run: |
# The generator needs the file to exist
chart_version="$(yq e '.version' bitnami/${CHART}/Chart.yaml)"
changelog_file="bitnami/${CHART}/CHANGELOG.md"
changelog_tmp="bitnami/${CHART}/CHANGELOG.md.tmp"
touch "$changelog_file"
npx conventional-changelog-cli -i ${changelog_file} -s -t ${CHART}/ -r 0 --commit-path bitnami/${CHART}
# Remove unreleased section (includes all intermediate commits in the branch) and create future entry based on PR title
# The unreleased section looks like this "## (YYYY-MM-DD)" whereas a released section looks like this "## 0.0.1 (YYYY-MM-DD)"
# So we only need to find a released section to start printing in the awk script below
awk '/^##[^(]*[0-9]/ {flag=1} flag {print}' ${changelog_file} > ${changelog_tmp}
# Remove extra newlines so the changelog file passes the markdown linter
sed -i -E -e '/^$/d' ${changelog_tmp} && sed -i -E -e 's/(##.*)/\n\1\n/g' ${changelog_tmp}
# Include h1 heading and add entry for the current version. There is no tag for the current version (this will be created once merged), so we need to manually add it.
# We know the final squashed commit title, which will be the PR title. We cannot add a link to the commit in the main branch because it has not been
# merged yet (this will be corrected once a new version regenerates the changelog). Instead, we add the PR url which contains the exact same information.
echo -e -n "# Changelog\n\n## $chart_version ($(date +'%Y-%m-%d'))\n\n* ${{ github.event.pull_request.title }} ([#${{ github.event.number }}](${{ github.server_url }}/${{ github.repository }}/pulls/${{ github.event.number }}))\n" > ${changelog_file}
mv ${changelog_tmp} ${changelog_file}
if git status -s | grep "bitnami/${CHART}/CHANGELOG.md"; then
git add "bitnami/${CHART}/CHANGELOG.md" && git commit -m "Update CHANGELOG.md" --signoff
fi
- name: Install readme-generator-for-helm
if: needs.get-chart.outputs.values-updated == 'true'
run: npm install -g @bitnami/readme-generator-for-helm

View File

@@ -8,6 +8,7 @@ on:
- main
paths:
- '**.md'
- '!**/CHANGELOG.md'
# Remove all permissions by default
permissions: {}
jobs: