From 2254c87b23412ac9bed76280c5edd4990ee24c4b Mon Sep 17 00:00:00 2001 From: ivan katliarchuk Date: Mon, 5 Apr 2021 14:12:32 +0100 Subject: [PATCH] work with changelogs --- .github/workflows/changelog.yml | 8 --- .github/workflows/release.yml | 112 ++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 3bf27b8..ad4f486 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -5,14 +5,6 @@ on: workflow_dispatch: schedule: - cron: "20 23 * * *" - push: - tags: - - 'v*' - branches: - - main - paths-ignore: - - "README.md" - - "CHANGELOG.md" env: BRANCH: main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cac4711..1940b47 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,3 +81,115 @@ jobs: tag: ${{ needs.update-tag.outputs.tag }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + update-changelog: + runs-on: ubuntu-latest + needs: [ release ] + name: changelog generator + timeout-minutes: 5 + if: ${{ !contains(github.event.head_commit.message, 'skip') && needs.update-tag.outputs.draft && github.ref == 'refs/heads/main' }} + steps: + # To use this repository's private action, you must check out the repository + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 30 + submodules: 'true' + + # https://github.com/marketplace/actions/tag-changelog + - name: create changelog text + uses: loopwerk/conventional-changelog-action@latest + id: ch + with: + token: ${{ secrets.GITHUB_TOKEN }} + config_file: .github/tag-changelog-config.js + + - name: read 'templates/changelog.history' + id: ch-history + uses: juliangruber/read-file-action@v1 + with: + path: .github/templates/changelog.history + + - name: read 'templates/changelog' + id: ch-template + uses: juliangruber/read-file-action@v1 + with: + path: .github/templates/changelog + + - name: write to changelog.md + uses: DamianReeves/write-file-action@master + with: + path: CHANGELOG.md + contents: | + ${{ steps.ch-template.outputs.content }}${{ steps.ch.outputs.changelog }}${{ steps.ch-history.outputs.content }} + write-mode: overwrite + + - name: write to 'templates/changelog.history' + uses: DamianReeves/write-file-action@master + with: + path: .github/templates/changelog.history + contents: | + ${{ steps.ch.outputs.changelog }}${{ steps.ch-history.outputs.content }} + write-mode: overwrite + + - name: check local changes + id: diff + run: | + changed_files=$(git status --porcelain --untracked-files=all | wc -l) + echo ::set-output name=count::$changed_files + echo ::set-output name=created::$(date) + shell: bash + + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.35.0 + id: tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DRY_RUN: true + + - + name: create pull request + uses: peter-evans/create-pull-request@v3 + id: cpr + if: ${{ steps.ch.outputs.changes }} + with: + branch: docs/changelog + base: ${{ github.head_ref }} + delete-branch: true + labels: | + kind/docs + :memo: documentation + :memo: docs + :bell: approved + :bell: automerge + :robot: bot + committer: ${{ env.COMMITTER_BOT }} + author: ${{ env.AUTHOR_BOT }} + title: | + "docs: update changelog "${{ steps.tag.outputs.tag }} #${{ github.run_number }}" ' + commit-message: | + 'docs: Update CHANGELOG.md "${{ github.workflow }} #${{ github.run_number }}" [skip ci]' + body: | + ## Description + + Update CHANGELOG.md + + ${{ steps.changelog.outputs.changelog }} + + ## Update report workflow + + - Updated with *today's* date **`${{ steps.diff.outputs.created }}`** + - Current Tag: **`${{ steps.tag.outputs.tag }}`** + - Name: **${{ github.workflow }}** + - Run ID: **${{ github.run_id }}** + - Run Number: **${{ github.run_number }}** + + _Auto-generated by [create-pull-request][1] + + [1]: https://github.com/peter-evans/create-pull-request + + - name: check outputs + if: ${{ steps.changelog.outputs.changes }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"