diff --git a/.github/workflows/check_pr_release_notes.yml b/.github/workflows/check_pr_release_notes.yml index c0b76e32..7b91a679 100644 --- a/.github/workflows/check_pr_release_notes.yml +++ b/.github/workflows/check_pr_release_notes.yml @@ -14,20 +14,22 @@ # limitations under the License. # -name: Check Release Notes in PR description +name: Check PR Release Notes in Description on: pull_request: types: [opened, synchronize, reopened, edited, labeled, unlabeled] branches: [ master ] +env: + SKIP_LABEL: 'no RN' + RLS_NOTES_TAG_REGEX: 'Release Notes:' + jobs: check-release-notes: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + steps: - name: Get Pull Request Info id: pr_info uses: actions/github-script@v7 @@ -40,11 +42,11 @@ jobs: pull_number: pr_number }); const labels = pr.data.labels ? pr.data.labels.map(label => label.name) : []; - - // Check if "skip-release-notes-check" label is present - if (labels.includes("skip-release-notes-check")) { - console.log("Skipping release notes check because 'skip-release-notes-check' label is present."); + + if (labels.includes("${{ env.SKIP_LABEL }}")) { + console.log("Skipping release notes check because '${{ env.SKIP_LABEL }}' label is present."); core.setOutput("skip_check", 'true'); + core.setOutput("pr_body", ""); return; } @@ -59,7 +61,7 @@ jobs: core.setOutput("skip_check", 'false'); return; - - name: Skip check if 'skip-release-notes-check' label is present + - name: Skip check if SKIP_LABEL is present if: steps.pr_info.outputs.skip_check == 'true' run: echo "Skipping release notes validation." @@ -68,18 +70,18 @@ jobs: run: | # Extract the body from the previous step PR_BODY="${{ steps.pr_info.outputs.pr_body }}" - - # Check if "Release notes:" exists - if ! echo "$PR_BODY" | grep -q 'Release Notes:'; then - echo "Error: 'Release Notes:' not found in pull request description." + + # Check if "Release Notes:" exists + if ! echo "$PR_BODY" | grep -q '${{ env.RLS_NOTES_TAG_REGEX }}'; then + echo "Error: release notes tag not found in pull request description. Has to adhere to format '${{ env.RLS_NOTES_TAG_REGEX }}'." exit 1 fi - - # Extract text after "Release notes:" line - RELEASE_NOTES=$(echo "$PR_BODY" | sed -n '/Release.*Notes/,$p' | tail -n +2) - + + # Extract text after "Release Notes:" line + TEXT_BELOW_RELEASE_NOTES_TAG=$(echo "$PR_BODY" | sed -n '/${{ env.RLS_NOTES_TAG_REGEX }}/,$p' | tail -n +2) + # Check if there's a bullet list (lines starting with '-', '+' or '*') - if ! echo "$RELEASE_NOTES" | grep -qE '^\s*[-+*]\s+.+$'; then - echo "Error: No bullet list found under 'Release Notes:'." + if ! echo "$TEXT_BELOW_RELEASE_NOTES_TAG" | grep -qE '^\s*[-+*]\s+.+$'; then + echo "Error: No bullet list found under release notes tag." exit 1 fi diff --git a/.github/workflows/release_draft.yml b/.github/workflows/release_draft.yml index 35731fc4..22249417 100644 --- a/.github/workflows/release_draft.yml +++ b/.github/workflows/release_draft.yml @@ -26,7 +26,7 @@ jobs: check-tag: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -78,11 +78,11 @@ jobs: tag-name: ${{ github.event.inputs.tag-name }} - generate-release-notes: + release-draft: needs: check-tag runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -98,13 +98,24 @@ jobs: with: tag-name: ${{ github.event.inputs.tag-name }} chapters: '[ + {"title": "No entry 🚫", "label": "duplicate"}, + {"title": "No entry 🚫", "label": "invalid"}, + {"title": "No entry 🚫", "label": "wontfix"}, + {"title": "No entry 🚫", "label": "no RN"}, {"title": "Breaking Changes 💥", "label": "breaking-change"}, {"title": "New Features 🎉", "label": "enhancement"}, {"title": "New Features 🎉", "label": "feature"}, - {"title": "Bugfixes 🛠", "label": "bug"} + {"title": "Bugfixes 🛠", "label": "bug"}, + {"title": "Infrastructure ⚙️", "label": "infrastructure"}, + {"title": "Silent-live 🤫", "label": "silent-live"}, + {"title": "Documentation 📜", "label": "documentation"} ]' + skip-release-notes-label: 'no RN' verbose: true + warnings: true + print-empty-chapters: true + chapters-to-pr-without-issue: true - name: Create and Push Tag diff --git a/examples/check_pr_release_notes.yml b/examples/check_pr_release_notes.yml index dbe73909..bc1820e5 100644 --- a/examples/check_pr_release_notes.yml +++ b/examples/check_pr_release_notes.yml @@ -5,9 +5,14 @@ on: types: [opened, synchronize, reopened, edited, labeled, unlabeled] branches: [ master ] +env: + SKIP_LABEL: 'no RN' + RLS_NOTES_TAG_REGEX: 'Release Notes:' + jobs: check-release-notes: runs-on: {your-runner} + steps: - name: Checkout code uses: actions/checkout@v4 @@ -24,11 +29,11 @@ jobs: pull_number: pr_number }); const labels = pr.data.labels ? pr.data.labels.map(label => label.name) : []; - - // Check if "skip-release-notes-check" label is present - if (labels.includes("skip-release-notes-check")) { - console.log("Skipping release notes check because 'skip-release-notes-check' label is present."); + + if (labels.includes("${{ env.SKIP_LABEL }}")) { + console.log("Skipping release notes check because '${{ env.SKIP_LABEL }}' label is present."); core.setOutput("skip_check", 'true'); + core.setOutput("pr_body", ""); return; } @@ -43,7 +48,7 @@ jobs: core.setOutput("skip_check", 'false'); return; - - name: Skip check if 'skip-release-notes-check' label is present + - name: Skip check if SKIP_LABEL is present if: steps.pr_info.outputs.skip_check == 'true' run: echo "Skipping release notes validation." @@ -52,18 +57,18 @@ jobs: run: | # Extract the body from the previous step PR_BODY="${{ steps.pr_info.outputs.pr_body }}" - - # Check if "Release notes:" exists - if ! echo "$PR_BODY" | grep -q 'Release Notes:'; then - echo "Error: 'Release Notes:' not found in pull request description." + + # Check if "Release Notes:" exists + if ! echo "$PR_BODY" | grep -q '${{ env.RLS_NOTES_TAG_REGEX }}'; then + echo "Error: release notes tag not found in pull request description. Has to adhere to format '${{ env.RLS_NOTES_TAG_REGEX }}'." exit 1 fi - - # Extract text after "Release notes:" line - RELEASE_NOTES=$(echo "$PR_BODY" | sed -n '/Release.*Notes/,$p' | tail -n +2) - + + # Extract text after "Release Notes:" line + TEXT_BELOW_RELEASE_NOTES_TAG=$(echo "$PR_BODY" | sed -n '/${{ env.RLS_NOTES_TAG_REGEX }}/,$p' | tail -n +2) + # Check if there's a bullet list (lines starting with '-', '+' or '*') - if ! echo "$RELEASE_NOTES" | grep -qE '^\s*[-+*]\s+.+$'; then - echo "Error: No bullet list found under 'Release Notes:'." + if ! echo "$TEXT_BELOW_RELEASE_NOTES_TAG" | grep -qE '^\s*[-+*]\s+.+$'; then + echo "Error: No bullet list found under release notes tag." exit 1 fi diff --git a/examples/release_draft.yml b/examples/release_draft.yml index 3d2a50ba..a0eb8a5a 100644 --- a/examples/release_draft.yml +++ b/examples/release_draft.yml @@ -9,8 +9,9 @@ on: jobs: check-tag: runs-on: {your-runner} + steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -62,11 +63,12 @@ jobs: tag-name: ${{ github.event.inputs.tag-name }} - generate-release-notes: + release-draft: needs: check-tag runs-on: {your-runner} + steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -82,14 +84,26 @@ jobs: with: tag-name: ${{ github.event.inputs.tag-name }} chapters: '[ + {"title": "No entry 🚫", "label": "duplicate"}, + {"title": "No entry 🚫", "label": "invalid"}, + {"title": "No entry 🚫", "label": "wontfix"}, + {"title": "No entry 🚫", "label": "no RN"}, {"title": "Breaking Changes 💥", "label": "breaking-change"}, {"title": "New Features 🎉", "label": "enhancement"}, {"title": "New Features 🎉", "label": "feature"}, - {"title": "Bugfixes 🛠", "label": "bug"} + {"title": "Bugfixes 🛠", "label": "bug"}, + {"title": "Infrastructure ⚙️", "label": "infrastructure"}, + {"title": "Silent-live 🤫", "label": "silent-live"}, + {"title": "Documentation 📜", "label": "documentation"} ]' - skip-release-notes-label: 'ignore-in-release' # changing default value of label + skip-release-notes-label: 'no RN' verbose: true + warnings: true + print-empty-chapters: true + chapters-to-pr-without-issue: true + + - name: Create and Push Tag uses: actions/github-script@v7 with: