|
| 1 | +# .github/workflows/pr-dry-run.yml |
| 2 | +name: PR Checks and Release Dry Run |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + changelog_version_check: |
| 11 | + uses: ./.github/workflows/reusable-changelog-version-diff.yml |
| 12 | + with: |
| 13 | + begin_ref: ${{ github.event.pull_request.base.sha }} |
| 14 | + end_ref: ${{ github.event.pull_request.head.sha }} |
| 15 | + |
| 16 | + changelog_version_enforce: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + needs: changelog_version_check |
| 19 | + permissions: |
| 20 | + pull-requests: write |
| 21 | + contents: read |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 25 | + |
| 26 | + - name: Check if tag for new version exists |
| 27 | + if: ${{ needs.changelog_version_check.outputs.before_version != needs.changelog_version_check.outputs.after_version }} |
| 28 | + run: | |
| 29 | + git fetch --tags |
| 30 | + if git tag --list "${{ needs.changelog_version_check.outputs.after_version }}" | grep -q .; then |
| 31 | + echo "::error::Tag ${{ needs.changelog_version_check.outputs.after_version }} already exists. Please update the version in CHANGELOG.md." |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | +
|
| 35 | + - name: Add/Update PR comment if version did not change |
| 36 | + if: ${{ needs.changelog_version_check.outputs.before_version == needs.changelog_version_check.outputs.after_version }} |
| 37 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
| 38 | + with: |
| 39 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + issue-number: ${{ github.event.pull_request.number }} |
| 41 | + body: | |
| 42 | + <!-- changelog-version-warning --> |
| 43 | + :warning: Version in CHANGELOG.md did not change (still ${{ needs.changelog_version_check.outputs.before_version }}). |
| 44 | + This PR will not result in the creation of a new release. |
| 45 | +
|
| 46 | + - name: Add/Update PR comment if version changed |
| 47 | + if: ${{ needs.changelog_version_check.outputs.before_version != needs.changelog_version_check.outputs.after_version }} |
| 48 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
| 49 | + with: |
| 50 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + issue-number: ${{ github.event.pull_request.number }} |
| 52 | + body: | |
| 53 | + <!-- changelog-version-info --> |
| 54 | + :information_source: Version in CHANGELOG.md updated to ${{ needs.changelog_version_check.outputs.after_version }}. |
| 55 | + This will trigger the creation of a new release when merged into main. |
| 56 | +
|
| 57 | + call_dry_run_workflow: |
| 58 | + needs: changelog_version_enforce |
| 59 | + uses: ./.github/workflows/reusable-release-provider.yml |
| 60 | + with: |
| 61 | + dry_run: true # This tells the reusable workflow to perform a dry run |
| 62 | + secrets: |
| 63 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 64 | + PASSPHRASE: ${{ secrets.PASSPHRASE }} |
0 commit comments