googleapis / release-please-action

automated releases based on conventional commits
Apache License 2.0
1.61k stars 207 forks source link

Wrong CHANGELOG generated if a previous release has been deleted #934

Closed stratoss closed 6 months ago

stratoss commented 6 months ago

TL;DR

Reverting a release then initiating a new one with fixed bugs causes the release-please-action to create a release including information from ALL commits instead of ones between the last release and now.

Expected behavior

The new CHANGELOG entry to contain only information extracted since the last existing release/tag and now.

Observed behavior

The following CHANGELOG was generated: https://github.com/stratoss/test/blob/staging/CHANGELOG.md

Action YAML

name: "AutoDeploy on Production"
on:
  push:
    branches:
      - main
    paths-ignore:
      - CHANGELOG.md
      - composer.json
permissions:
  contents: write
  pull-requests: write
jobs:
  release_changelog:
    name: Update CHANGELOG
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v4
        with:
          release-type: php
          package-name: release-please-action
          target-branch: main
          labels: automerge
          token: ${{ secrets.GH_API_KEY }}
  merge_changelog:
    needs: release_changelog
    runs-on: ubuntu-latest
    steps:
      - run: echo start...; PRID=$(gh pr list -R stratoss/test | grep release-please--branches | cut -f 1); echo Pending PR $PRID; if [[ "$PRID" -ne "" ]]; then gh pr merge $PRID -R stratoss/test --admin -m -d; fi; echo done;
        env:
          GH_TOKEN: ${{ secrets.GH_API_KEY }}
  tag_release:
    needs: merge_changelog
    name: Tag release
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v4
        with:
          release-type: php
          package-name: release-please-action
          target-branch: main
          labels: automerge
          token: ${{ secrets.GH_API_KEY }}
  backmerge_changelog:
    needs: tag_release
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ secrets.GH_API_KEY }}
    steps:
      - uses: actions/checkout@v2
      - name: Sync CHANGELOG
        run: |
          echo start backmerging...
          git config --global user.name 'Stanimir Stoyanov'
          git config --global user.email 'ss@stansoft.bg'
          git fetch
          git checkout main
          git pull
          git checkout staging
          git checkout -b sync_changelog
          git checkout main -- CHANGELOG.md composer.json
          git commit -am "Back-merge CHANGELOG.md and composer.json" || exit 0
          git push -f origin sync_changelog
          PRID=$(gh pr create -R  stratoss/test -B staging -H sync_changelog -a stratoss -t "Sync CHANGELOG.MD and composer.json" -b "" | cut -d/ -f7);
          gh pr merge $PRID -R stratoss/test --admin -m;
          echo Back-merge succeeded

Log output

https://github.com/stratoss/test/actions/runs/7724799551/job/21057661487

Additional information

The following workflow has been run before the wrongly generated CHANGELOG - https://github.com/stratoss/test/actions/runs/7724772034