Skip to content

Generate changelog

Generate changelog #4

name: Generate changelog
on:
release:
types: [created, edited]
pull_request:
types: [closed]
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: |
# 시맨틱 버전 태그 중 가장 최신 버전 찾기 (v1 제외)
latest_tag="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n1)"
echo "LATEST_TAG=${latest_tag}" >> "$GITHUB_ENV"
# 첫 번째 태그는 v1.0.0으로 고정
echo "FIRST_TAG=v1.0.0" >> "$GITHUB_ENV"
- name: Generate changelog
uses: janheinrichmerker/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
futureRelease: ${{ github.event.release.tag_name || env.LATEST_TAG }}
output: CHANGELOG.md
sinceTag: ${{ env.FIRST_TAG }} # v1.0.0과 같은 구체적인 버전 태그
# excludeTags: "v1,v2" # 명시적으로 제외할 태그
excludeTagsRegex: "^v[0-9]$"
- name: Commit files
run: |
git config --local user.email "[email protected]"
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