Skip to content

Commit 12f0384

Browse files
authored
chore: GH actions changes (#31)
1 parent f052932 commit 12f0384

File tree

5 files changed

+143
-23
lines changed

5 files changed

+143
-23
lines changed

.github/pull_request_template.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Motivation
22

3-
Describe what is the motivation behind the proposed changes. If possible reference the current solution/state of affairs.
3+
Describe what is the motivation behind the proposed changes.
4+
If possible reference the current solution/state of affairs.
45

56
## Summary
67

@@ -15,11 +16,14 @@ List related changes from other PRs (if any).
1516
- Describe how to check introduced code changes manually. Provide example invocations and applied YAML configs.
1617
- Take care of test coverage on unit and end-to-end levels.
1718

18-
## Checklist
19+
## Release Notes
1920

20-
- [ ] Include this change in Release Notes?
21-
- If yes, write 1-3 sentences about the changes here and explicitly list all changes that can surprise our users.
22-
- [ ] Are these changes required to be in sync with the API? Example of such can be extending adding support of new API.
23-
It won't be usable until Nobl9 platform version is rolled out which exposes this API.
24-
- If yes, you **MUST NOT** create an official release, instead, use a pre-release version, like `v1.1.0-rc1`.
25-
- If the changes are independent of Nobl9 platform version, you can release an offical version, like `v1.1.0`.
21+
If this change should be part of the Release Notes,
22+
**replace this entire paragraph** with 1-3 sentences about the changes.
23+
Otherwise, you **MUST** remove this section entirely.
24+
25+
## Breaking Changes
26+
27+
Does this PR contain any breaking changes?
28+
If so **replace this entire paragraph** with a description of these changes.
29+
Otherwise, you **MUST** remove this section entirely.

.github/renovate.json5

+1-15
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,7 @@
1515
"rebaseWhen": "conflicted",
1616
"rangeStrategy": "pin",
1717
"branchPrefix": "renovate_",
18-
// Auto-merge section.
19-
// Only
20-
"automergeType": "pr",
21-
"lockFileMaintenance": {
22-
"automerge": true
23-
},
24-
"minor": {
25-
"automerge": true
26-
},
27-
"patch": {
28-
"automerge": true
29-
},
30-
"pin": {
31-
"automerge": true
32-
},
18+
"commitMessagePrefix": "chore:",
3319
// This will run go mod tidy after each go.mod update.
3420
"postUpdateOptions": ["gomodTidy"],
3521
// Groups:

.github/scripts/release-notes.sh

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [ "$#" -ne 1 ]; then
6+
echo "Provide a single argument with a version of the release draft to use." >&2
7+
echo "Usage: $0 <VERSION>"
8+
exit 1
9+
fi
10+
11+
VERSION="$1"
12+
13+
RELEASE_NOTES=$(gh release view "$VERSION" --json body --jq .body)
14+
15+
BREAKING_CHANGES_HEADER="Breaking Changes"
16+
RELEASE_NOTES_HEADER="Release Notes"
17+
18+
commit_message_re="-\s(.*)\s(\(#[0-9]+\)\s@.*)"
19+
rls_header_re="^##.*(Features|$BREAKING_CHANGES_HEADER|Bug Fixes|Fixed Vulnerabilities)"
20+
21+
extract_header() {
22+
local commit="$1"
23+
local header_name="$2"
24+
awk "
25+
/^\s?$/ {next}
26+
/## $header_name/ {rn=1}
27+
rn && !/^##/ {print};
28+
/##/ && !/## $header_name/ {rn=0}" <<<"$commit"
29+
}
30+
31+
indent() {
32+
while IFS= read -r line; do
33+
printf " %s\n" "${line%"${line##*[![:space:]]}"}"
34+
done <<<"$1"
35+
}
36+
37+
new_notes=""
38+
rls_header=""
39+
while IFS= read -r line; do
40+
new_notes+="$line\n"
41+
if [[ $line == \##* ]]; then
42+
if ! [[ $line =~ $rls_header_re ]]; then
43+
rls_header=""
44+
continue
45+
fi
46+
rls_header="${BASH_REMATCH[1]}"
47+
fi
48+
if [[ $rls_header == "" ]]; then
49+
continue
50+
fi
51+
if [[ $line != -* ]]; then
52+
continue
53+
fi
54+
if ! [[ $line =~ $commit_message_re ]]; then
55+
continue
56+
fi
57+
commit_msg="${BASH_REMATCH[1]}"
58+
commit_body=$(git log --grep "$commit_msg" -n1 --pretty="%b")
59+
60+
add_notes() {
61+
local notes="$1"
62+
if [[ $notes != "" ]]; then
63+
new_notes+=$(indent "> $notes")
64+
new_notes+="\n"
65+
fi
66+
}
67+
68+
rn=$(extract_header "$commit_body" "$RELEASE_NOTES_HEADER")
69+
bc=$(extract_header "$commit_body" "$BREAKING_CHANGES_HEADER")
70+
71+
case $rls_header in
72+
"$BREAKING_CHANGES_HEADER") add_notes "$bc" ;;
73+
*) add_notes "$rn" ;;
74+
esac
75+
76+
done <<<"$RELEASE_NOTES"
77+
78+
echo "Uploading release notes for $VERSION"
79+
# shellcheck disable=2059
80+
printf "$new_notes" | gh release edit "$VERSION" --verify-tag -F -

.github/workflows/pr-title.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
on:
2+
pull_request:
3+
types: [opened, reopened, edited]
4+
merge_group:
5+
name: pr-title
6+
jobs:
7+
pr-title-check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: Slashgear/[email protected]
11+
with:
12+
regexp: "(feat|fix|sec|infra|test|chore|doc): .{5,}"
13+
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)"

.github/workflows/release-drafter.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# pull_request event is required only for autolabeler
8+
# 'edited' event is required to account for initial invalid PR names
9+
pull_request:
10+
types: [opened, reopened, synchronize, edited]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
update_release_draft:
17+
permissions:
18+
# write permission is required to create a github release
19+
contents: write
20+
# write permission is required for autolabeler
21+
# otherwise, read permission is required at least
22+
pull-requests: write
23+
runs-on: ubuntu-latest
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.RELEASE_LABELER_TOKEN }}
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
ref: main
31+
fetch-depth: 0
32+
# Drafts your next Release notes as Pull Requests are merged into "main"
33+
- id: drafter
34+
uses: release-drafter/release-drafter@v5
35+
- name: Add release notes to the draft
36+
if: github.event_name == 'push'
37+
run: .github/scripts/release-notes.sh ${{ steps.drafter.outputs.tag_name }}

0 commit comments

Comments
 (0)