helm-gitea/.gitea/workflows/changelog.yml
pat-s 6cb068ae12 ci: create upcoming changelog via git-sv (#794)
https://github.com/thegeeklab/git-sv

- Creates a changelog from conventional commits
- Updates the changelog in an static issue (creates the issue if missing)
- Only runs after a new commit was merged into `main`
- Automatically determines the next version based on conv commits logic
- Follows up on #788

---

The logic can also be used to create the release notes on `tag` events and the subsequent Gitea release. Didn't wanted to add all at once, though.

Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/794
Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.com>
Co-authored-by: pat-s <patrick.schratz@gmail.com>
Co-committed-by: pat-s <patrick.schratz@gmail.com>
2025-02-23 14:20:33 +00:00

29 lines
1.2 KiB
YAML

name: changelog
on:
push:
branches:
- main
jobs:
changelog:
runs-on: ubuntu-latest
container: docker.io/thegeeklab/git-sv:1.0.11
steps:
- uses: actions/checkout@v4
- name: Generate upcoming changelog
run: |
apk add -q --no-cache curl jq sed
git sv rn -o changelog.md
export RELEASE_NOTES=$(cat changelog.md)
export ISSUE_NUMBER=$(curl -s "${{ gitea.event.repository.html_url }}/api/v1/repos/${{ gitea.repository }}/issues?state=open&q=Changelog%20for%20upcoming%20version" | jq '.[].number')
echo $RELEASE_NOTES
JSON_DATA=$(echo "" | jq -Rs --arg title 'Changelog for upcoming version' --arg body "$(cat changelog.md)" '{title: $title, body: $body}')
if [ -z "$ISSUE_NUMBER" ]; then
curl -s -X POST "${{ gitea.event.repository.html_url }}/api/v1/repos/${{ gitea.repository }}/issues?token=${{ secrets.ISSUE_RW_TOKEN }}" -H "Content-Type: application/json" -d "$JSON_DATA"
else
curl -s -X PATCH "${{ gitea.event.repository.html_url }}/api/v1/repos/${{ gitea.repository }}/issues/$ISSUE_NUMBER?token=${{ secrets.ISSUE_RW_TOKEN }}" -H "Content-Type: application/json" -d "$JSON_DATA"
fi