Generate changelog #3
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
name: Generate changelog | |
on: | |
release: | |
types: [created, edited] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
generate-changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get first tag | |
id: get_first_tag | |
run: | | |
first_tag="$(git tag -l | sort -V | head -n 1)" | |
echo "FIRST_TAG=${first_tag}" >> "$GITHUB_ENV" | |
latest_tag="$(git describe --tags --abbrev=0 || echo "${first_tag}")" | |
echo "LATEST_TAG=${latest_tag}" >> "$GITHUB_ENV" | |
- name: Generate changelog | |
uses: janheinrichmerker/action-github-changelog-generator@v2.3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
futureRelease: ${{ github.event.release.tag_name || env.LATEST_TAG }} | |
base: CHANGELOG.md | |
output: CHANGELOG.md | |
sinceTag: ${{ env.FIRST_TAG }} | |
- name: Commit files | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add CHANGELOG.md | |
git commit -m "Update changelog" || echo "No changes to commit" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |