Skip to content

Commit

Permalink
- Applied changes from external development to keep them as examples …
Browse files Browse the repository at this point in the history
…and use in workflows.
  • Loading branch information
miroslavpojer committed Oct 21, 2024
1 parent 0362f31 commit 7eb8d24
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 43 deletions.
40 changes: 21 additions & 19 deletions .github/workflows/check_pr_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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."

Expand All @@ -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
19 changes: 15 additions & 4 deletions .github/workflows/release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
35 changes: 20 additions & 15 deletions examples/check_pr_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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."

Expand All @@ -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
24 changes: 19 additions & 5 deletions examples/release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit 7eb8d24

Please sign in to comment.