diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml index 63214c275..572d9331d 100644 --- a/.github/workflows/update-changelog.yaml +++ b/.github/workflows/update-changelog.yaml @@ -4,6 +4,7 @@ on: release: types: - published + workflow_dispatch: jobs: Changelog-Update: @@ -27,6 +28,17 @@ jobs: commit_message: Update CHANGELOG file_pattern: CHANGELOG.md create_branch: true + # Create Pull Request + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "docs: :memo: Update CHANGELOG for ${{ github.event.release.tag_name }}" + title: "docs: :memo: Update CHANGELOG for ${{ github.event.release.tag_name }}" + body: | + This Pull Request was automatically created by the Changelog Updater Action. + It updates the CHANGELOG.md with the release notes from the latest release. + Release-Documentation: if: ${{ contains(github.event.release.prerelease, false) }} name: Build Documentation from new release branch 'release/${{ github.event.release.tag_name }}' @@ -54,6 +66,28 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" + - name: Fetch tags + run: git fetch --tags --prune --unshallow + - name: Get previous tag + id: prev_tag + run: echo "::set-output name=prev_tag::$(git rev-list --tags --skip=1 --max-count=1)" + - name: Get latest tag + id: latest_tag + run: echo "::set-output name=latest_tag::$(git rev-list --tags --max-count=1)" + - name: Check if release is minor + id: is_minor + run: | + current_tag=${{ github.event.release.tag_name }} + prev_tag=${{ steps.prev_tag.outputs.prev_tag }} + latest_tag=$(git describe --tags --abbrev=0 ${{ steps.latest_tag.outputs.latest_tag }}) + if [[ $current_tag =~ ^${latest_tag%.*}\.[0-9]+$ && $prev_tag =~ ^${latest_tag%.*}\.[0-9]+\.[0-9]+$ ]]; then + echo "::set-output name=is_minor::true" + else + echo "::set-output name=is_minor::false" + fi + - name: Delete previous documentation + if: steps.is_minor.outputs.is_minor == 'true' + run: poetry run mike delete --version ${{ steps.prev_tag.outputs.prev_tag }} - name: Deploy documentation develops run: | poetry run mike deploy --push --rebase --update-aliases ${{ github.event.release.tag_name }} latest --message "Release ${{ github.event.release.tag_name }}"