Skip to content

Commit

Permalink
Improve relnotes.yml workflow
Browse files Browse the repository at this point in the history
.# GitHub token

`edb-slonik` user token (`secrets.GH_SLONIK`) doesn't have enough
rights to create/update PRs in the `tpa-internal` repo.

This commit changes the workflow so it uses `secrets.GITHUBSECURITYTOKEN`
instead of `secrets.GH_SLONIK` when creating/updating the PR.

.# breaking changes type

This commit adds the `breaking_change` relnote type. That type is currently
not used, but might be helpful in the soon future.

.# Add relnote YAML template

We add a relnote template file at `release_notes/relnote.yml.template`. It should
be an easy start when creating release notes files during development.

As a consequence we changed the step `Clean up release notes YAML files` so it only
removes `.yml` and `.yaml` files, so the template won't be removed by the workflow
execution.

Signed-off-by: Israel Barth Rubio <[email protected]>
Co-authored-by: Jonathan Renon <[email protected]>
  • Loading branch information
2 people authored and haroon-github committed Jan 31, 2024
1 parent 3a195c2 commit 3211a0d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/relnotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ on:
default: '41898282+github-actions[bot]@users.noreply.github.com'

env:
# edb-slonik GitHub user must have enough rights to create a branch and a PR
# in the repository
GITHUB_TOKEN: ${{ secrets.GH_SLONIK }}
SOURCE_REPO_PATH: source_repo
SOURCE_DIRECTORY: source_repo/${{ inputs.source_directory }}
OUTPUT_FILE: source_repo/${{ inputs.output_file }}
Expand All @@ -69,15 +66,14 @@ jobs:
with:
path: ${{ env.SOURCE_REPO_PATH }}
ref: ${{ inputs.base_branch }}
token: ${{ env.GITHUB_TOKEN }}

- name: Checkout repo-actions
uses: actions/checkout@v4
with:
repository: EnterpriseDB/repo-actions
path: .github/repo-actions
ref: v1
token: ${{ env.GITHUB_TOKEN }}
token: ${{ secrets.GH_SLONIK }}

- name: Start a new branch from main
run: |
Expand All @@ -103,7 +99,7 @@ jobs:
- name: Clean up release notes YAML files
run: |
rm "${{ env.SOURCE_DIRECTORY }}"/*
rm "${{ env.SOURCE_DIRECTORY }}"/*.{yml,yaml}
- name: Add changes, commit and push new branch
run: |
Expand All @@ -119,7 +115,8 @@ jobs:
- name: Create a PR with the release notes
uses: ./.github/repo-actions/create-pull-request
with:
"token": ${{ env.GITHUB_TOKEN }}
# Use a token with permission to create/update PR in tpa-internal
token: ${{ secrets.GITHUBSECURITYTOKEN }}
path: ${{ env.SOURCE_REPO_PATH }}
head: ${{ env.RELEASE_NOTES_BRANCH }}
repo: ${{ github.repository }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/relnotes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ It should be written in markdown syntax. This is optional.
- `type`: type of the release note. Should be one among:
- `notable_change`: a bigger impact change.
- `minor_change`: some punctual change.
- `bugfix`: bugfix patch.`
- `bugfix`: bugfix patch.
- `breaking_change`: a change that breaks backward compatibility.
- `jira_tickets`: a list of Jira tickets related with this release note. This is
optional.
- `support_tickets`: a list of Support tickets related with this release note. This
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/relnotes/relnotes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class RelNoteType(Enum):
* ``NOTABLE_CHANGE``: a bigger impact change;
* ``MINOR_CHANGE``: some punctual change;
* ``BUGFIX``: bugfix patch.
* ``BUGFIX``: bugfix patch;
* ``BREAKING_CHANGE``: a change which breaks backward compatibility.
"""

NOTABLE_CHANGE = 1
MINOR_CHANGE = 2
BUGFIX = 3
BREAKING_CHANGE = 4

def to_markdown(self) -> str:
"""Generate markdown string corresponding to *self*.
Expand Down Expand Up @@ -62,7 +64,9 @@ def __init__(self, *, summary: str, description: str = "", type: str,
* ``notable_change``: a bigger impact change;
* ``minor_change``: some punctual change;
* ``bugfix``: bugfix patch.
* ``bugfix``: bugfix patch;
* ``breaking_change``: a change which breaks backward
compatibility.
:param jira_tickets: a list of 0 or more Jira tickets related to this
release note.
Expand All @@ -80,8 +84,8 @@ def __init__(self, *, summary: str, description: str = "", type: str,
self.type = RelNoteType.__members__[type.strip().upper()]
except KeyError:
raise RelNoteInvalidType(f"Type `{type}` is invalid. Use one among"
" `notable_change`, `minor_change`, or "
"`bugfix`.")
" `notable_change`, `minor_change`, "
"`bugfix` or `breaking_change`.")
self.tickets: List[str] = jira_tickets + support_tickets
if len(self.tickets) == 0:
raise RelNoteNoTicket("Concatenation of Jira tickets and Support "
Expand Down
17 changes: 17 additions & 0 deletions release_notes/relnote.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- summary: Some short description to be used as the first line
description: |
A longer description which will explain in details what the change is and
why it has been introduced
# Possible types: notable_change, minor_change, bugfix or breaking_change
type: notable_change
# At least one between jira_tickets or support_tickets must be defined. You
# can define both if you want
# You must have at least one list item in each *_tickets section that is
# defined
jira_tickets:
- TPA-123
- TPA-456
- TPA-789
support_tickets:
- RT12345
- RT67890

0 comments on commit 3211a0d

Please sign in to comment.