diff --git a/.github/workflows/release-checks.yml b/.github/workflows/release-checks.yml new file mode 100644 index 0000000..0153506 --- /dev/null +++ b/.github/workflows/release-checks.yml @@ -0,0 +1,42 @@ +name: Release Checks +on: + workflow_call: + inputs: + next-release-label-check: + type: boolean + default: false + pull_request: + +permissions: + contents: read + +jobs: + next-release-label-check: + name: Check for "next release" label + runs-on: ubuntu-latest + if: inputs.next-release-label-check + steps: + - + name: Check for "next release" label + uses: actions/github-script@v6 + with: + script: | + const { data: pulls } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + }); + + // check for open PRs which contain the 'next release' label + const openPRs = pulls.filter(pr => + pr.labels.some(label => label.name === 'next release') + ).map(pr => ` - #${pr.number}: ${pr.title}`); + + if (openPRs.length > 0) { + const errorMessage = 'Found "next release" label on the following open pull requests:\n' + + openPRs.join('\n') + + '\nPlease merge them before release.'; + core.setFailed(errorMessage); + } else { + console.log('No "next release" label found on any open pull requests!'); + } diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 636e786..e8fbe7d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,11 @@ jobs: static-analysis: uses: ./.github/workflows/static-analysis.yml + release_checks: + uses: ./.github/workflows/release-checks.yml + with: + next-release-label-check: true + build_docs: uses: ./.github/workflows/doctum.yml with: