claudiodekker / changelog-updater
一个PHP包,用于程序化更新您的变更日志文件。
v1.1.0
2024-01-31 22:39 UTC
Requires
- php: ~8.2.0|~8.3.0
- illuminate/support: ^10.6
- phar-io/version: ^3.2
Requires (Dev)
- phpunit/phpunit: ^8.4|^9.5.8
This package is auto-updated.
Last update: 2024-08-30 01:55:21 UTC
README
一个PHP库,用于根据"Keep a Changelog" 1.0.0格式程序化更新变更日志。
用法
GitHub Action
此库可以用作GitHub Action,在合并pull request时自动更新您的变更日志。您可以在以下链接中查看示例:这里。要设置GitHub Action,请按照以下步骤操作
-
在您的仓库中创建一个新文件
.github/workflows/update_changelog.yml
-
将以下内容复制到
update_changelog.yml
文件中name: Update Changelog on PR Merge on: pull_request_target: types: - closed jobs: update-changelog: name: Update Changelog runs-on: ubuntu-latest if: github.event.pull_request.merged == true permissions: contents: write steps: - name: Checkout code uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.base.ref }} fetch-depth: 0 - name: Determine changelog section to update id: sections run: | section="" labels=$(echo '${{ toJSON(github.event.pull_request.labels.*.name) }}' | jq -r '.[]') for label in $labels; do lower_label=$(echo "$label" | tr '[:upper:]' '[:lower:]') case "$lower_label" in enhancement|feature) section="Added"; break;; bug|bugfix|fix|patch) section="Fixed"; break;; change) section="Changed"; break;; optimization|improvement|performance|refactor) section="Optimized"; break;; deprecation|deprecated) section="Deprecated"; break;; revert) section="Reverted"; break;; removal) section="Removed"; break;; security) section="Security"; break;; esac done if [ -z "$section" ]; then echo "No matching label found for changelog entry, skipping changelog update." exit 0 else echo "section=$section" >> $GITHUB_OUTPUT fi - name: Add entry to CHANGELOG.md if: steps.sections.outputs.section != '' uses: claudiodekker/changelog-updater@master with: section: "${{ steps.sections.outputs.section }}" entry-text: "${{ github.event.pull_request.title }}" entry-link: "${{ github.event.pull_request.html_url }}" - name: Commit updated CHANGELOG if: steps.sections.outputs.section != '' uses: stefanzweifel/git-auto-commit-action@v4 with: branch: ${{ github.event.pull_request.base.ref }} commit_message: "Update CHANGELOG.md w/ PR #${{ github.event.pull_request.number }}" file_pattern: CHANGELOG.md
-
提交并推送文件到您的仓库。
完成后,GitHub Action将在合并具有匹配标签的pull request时自动更新您的变更日志。