diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..b353111 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,36 @@ +template: $CHANGES +category-template: "### $TITLE" +name-template: "Release v$RESOLVED_VERSION 🌈" +tag-template: "v$RESOLVED_VERSION" +change-template: "- $TITLE [@$AUTHOR](https://github.com/$AUTHOR) ([#$NUMBER]($URL))" +change-title-escapes: '\<&' +exclude-labels: + - "dependencies" + - "skip-changelog" +categories: + - title: "破坏性变更" + labels: + - "Breaking" + - title: "新功能" + labels: + - "feature" + - "enhancement" + - title: "Bug 修复" + labels: + - "fix" + - "bugfix" + - "bug" + - title: "文档" + labels: + - "documentation" +version-resolver: + major: + labels: + - "major" + minor: + labels: + - "minor" + patch: + labels: + - "patch" + default: patch diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..b1b6fdf --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,39 @@ +name: Release Drafter + +on: + pull_request_target: + branches: + - main + types: + - closed + +jobs: + update-release-drafter: + runs-on: ubuntu-latest + concurrency: + group: pull-request-changelog + cancel-in-progress: true + steps: + - uses: actions/checkout@v3 + + - uses: release-drafter/release-drafter@v5 + id: release-drafter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update Changelog + uses: docker://ghcr.io/nonebot/auto-changelog:master + with: + latest_changes_position: '# Change Log\n\n' + latest_changes_title: "## 最近更新" + replace_regex: '(?<=## 最近更新\n)[\s\S]*?(?=\n## )' + changelog_body: ${{ steps.release-drafter.outputs.body }} + commit_and_push: false + + - name: Commit and Push + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git add . + git diff-index --quiet HEAD || git commit -m ":memo: Update changelog" + git push diff --git a/.github/workflows/release-trigger.yml b/.github/workflows/release-trigger.yml new file mode 100644 index 0000000..f617097 --- /dev/null +++ b/.github/workflows/release-trigger.yml @@ -0,0 +1,34 @@ +name: Trigger Release + +on: + workflow_dispatch: + +jobs: + archive: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + ref: main + + - name: Setup Python environment + uses: ./.github/actions/setup-python + + - run: echo "TAG_NAME=v$(poetry version -s)" >> $GITHUB_ENV + + - name: Archive Changelog + uses: docker://ghcr.io/nonebot/auto-changelog:master + with: + archive_regex: '(?<=## )最近更新(?=\n)' + archive_title: ${{ env.TAG_NAME }} + commit_and_push: false + + - name: Push Tag + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git add . + git commit -m ":bookmark: Release $(poetry version -s)" + git tag ${{ env.TAG_NAME }} + git push && git push --tags