定制 claudiodekker/changelog-updater 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

claudiodekker/changelog-updater

最新稳定版本:v1.2.0

Composer 安装命令:

composer require claudiodekker/changelog-updater

包简介

A PHP package to programmatically update your changelog file.

README 文档

README

A PHP library to programmatically update changelogs based on the "Keep a Changelog" 1.0.0 format.

Usage

GitHub Action

This library can be used as a GitHub Action to automatically update your changelog when a pull request is merged. You can see an example of what this looks like here. To set up the GitHub Action, follow the steps below:

  1. Create a new file in your repository at .github/workflows/update_changelog.yml

  2. Copy the following content into the update_changelog.yml file:

    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
  3. Commit and push the file to your repository.

Once done, the GitHub Action will automatically update your changelog when a pull request with a matching label is merged.

统计信息

  • 总下载量: 15.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-11