Skip to content

Commit

Permalink
chore: Update pull_request_template.md (#239)
Browse files Browse the repository at this point in the history
## Motivation

Minor fixes to GH related stuff.
  • Loading branch information
nieomylnieja authored Jan 24, 2024
1 parent 3c0fad1 commit 8cd967d
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report
about: Create a bug report to help us solve the issue
about: Create a bug report to help us solve the issue.
title: "[BUG]"
labels: bug
assignees: ''
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Feature request
about: Suggest an idea to help us improve the SDK
about: Suggest an idea to help us improve the SDK.
title: "[FEAT]"
labels: enhancement
assignees: ''
Expand Down
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ List related changes from other PRs (if any).
## Testing

- Describe how to check introduced code changes manually. Simple `main.go` which takes advantage of the introduced changes is preferred (if possible and useful).
- Take care of test coverage on unit, integration or even end-to-end tests level.
- Take care of test coverage on unit, integration or even end-to-end levels.

## Checklist

- [ ] Include this change in Release Notes?
- If yes, write 1-3 sentences about the changes here and explicitly list all changes that can surprise our users.
- [ ] Are these changes required to be in sync with the API? Example of such can be extending a `manifest.Object` with a new field.
It won't be usable until Nobl9 platform version is rolled out which can handle this field.
- If yes, **MUST NOT** create an official release, use a pre-release version, like `v1.1.0-rc1` instead.
It won't be usable until Nobl9 platform version is rolled out which can handle this field.
- If yes, you **MUST NOT** create an official release, instead, use a pre-release version, like `v1.1.0-rc1`.
- If the changes are independent of Nobl9 platform version, you can release an offical version, like `v1.1.0`.
5 changes: 3 additions & 2 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"rebaseWhen": "conflicted",
"rangeStrategy": "pin",
"branchPrefix": "renovate_",
"commitMessagePrefix": "chore:",
// This will run go mod tidy after each go.mod update.
"postUpdateOptions": ["gomodTidy"],
"packageRules": [
// Groups:
{
Expand All @@ -39,8 +42,6 @@
"addLabels": ["javascript"],
},
],
// This will run go mod tidy after each go.mod update.
"postUpdateOptions": ["gomodTidy"],
// Custom version extraction from Makefile.
"regexManagers": [
{
Expand Down
80 changes: 80 additions & 0 deletions .github/scripts/release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash

set -euo pipefail

if [ "$#" -ne 1 ]; then
echo "Provide a single argument with a version of the release draft to use." >&2
echo "Usage: $0 <VERSION>"
exit 1
fi

VERSION="$1"

RELEASE_NOTES=$(gh release view "$VERSION" --json body --jq .body)

BREAKING_CHANGES_HEADER="Breaking Changes"
RELEASE_NOTES_HEADER="Release Notes"

commit_message_re="-\s(.*)\s(\(#[0-9]+\)\s@.*)"
rls_header_re="^##.*(Features|$BREAKING_CHANGES_HEADER|Bug Fixes|Fixed Vulnerabilities)"

extract_header() {
local commit="$1"
local header_name="$2"
awk "
/^\s?$/ {next}
/## $header_name/ {rn=1}
rn && !/^##/ {print};
/##/ && !/## $header_name/ {rn=0}" <<<"$commit"
}

indent() {
while IFS= read -r line; do
printf " %s\n" "${line%"${line##*[![:space:]]}"}"
done <<<"$1"
}

new_notes=""
rls_header=""
while IFS= read -r line; do
new_notes+="$line\n"
if [[ $line == \##* ]]; then
if ! [[ $line =~ $rls_header_re ]]; then
rls_header=""
continue
fi
rls_header="${BASH_REMATCH[1]}"
fi
if [[ $rls_header == "" ]]; then
continue
fi
if [[ $line != -* ]]; then
continue
fi
if ! [[ $line =~ $commit_message_re ]]; then
continue
fi
commit_msg="${BASH_REMATCH[1]}"
commit_body=$(git log --grep "$commit_msg" -n1 --pretty="%b")

add_notes() {
local notes="$1"
if [[ $notes != "" ]]; then
new_notes+=$(indent "> $notes")
new_notes+="\n"
fi
}

rn=$(extract_header "$commit_body" "$RELEASE_NOTES_HEADER")
bc=$(extract_header "$commit_body" "$BREAKING_CHANGES_HEADER")

case $rls_header in
"$BREAKING_CHANGES_HEADER") add_notes "$bc" ;;
*) add_notes "$rn" ;;
esac

done <<<"$RELEASE_NOTES"

echo "Uploading release notes for $VERSION"
# shellcheck disable=2059
printf "$new_notes" | gh release edit "$VERSION" --verify-tag -F -
13 changes: 13 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on:
pull_request:
types: [opened, reopened, edited]
merge_group:
name: pr-title
jobs:
pr-title-check:
runs-on: ubuntu-latest
steps:
- uses: Slashgear/[email protected]
with:
regexp: "(feat|fix|sec|infra|test|chore|doc): .{5,}"
helpMessage: "Example: 'feat: new pr title check BE-143' <- prefix, colon, space, PR title of at least 5 chars (with ticket number strongly suggested, but not mandatory)"
37 changes: 37 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Drafter

on:
push:
branches:
- main
# pull_request event is required only for autolabeler
# 'edited' event is required to account for initial invalid PR names
pull_request:
types: [opened, reopened, synchronize, edited]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_LABELER_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
# Drafts your next Release notes as Pull Requests are merged into "main"
- id: drafter
uses: release-drafter/release-drafter@v5
- name: Add release notes to the draft
if: github.event_name == 'push'
run: .github/scripts/release-notes.sh ${{ steps.drafter.outputs.tag_name }}

0 comments on commit 8cd967d

Please sign in to comment.