Skip to content

Commit

Permalink
Merge branch 'main' into MIJN-9575-varen-service
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryvanWalen authored Feb 3, 2025
2 parents d6aff49 + 48e7790 commit c196dae
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 103 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/create-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Release notification'
on:
push:
tags:
- release-*
run-name: Generating release notes for ${{ github.base_ref }}
permissions:
contents: write
jobs:
create-publish-release-notes:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Generate and update the release notes
run: |
all_tags=$(git tag -l --sort=-creatordate)
latest_tag=$(echo "$all_tags" | sed -n '1p')
previous_tag=$(echo "$all_tags" | sed -n '2p')
release_notes=$(git log "$previous_tag..$latest_tag" --oneline)
release_notes=$(echo "$release_notes" | python3\
./scripts/create-release-notes.py\
"$previous_tag"\
"$latest_tag"\
)
if gh release view "$latest_tag" &>/dev/null; then
echo "Release exists. Updating..."
gh release edit "$latest_tag" --notes "$release_notes"
else
echo "Creating new release..."
gh release create "$latest_tag" --notes "$release_notes"
fi
6 changes: 1 addition & 5 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ jobs:
// Titel moet beginnen met mijn-xxxx-chore/feature/bug! todo mijn- patroon moet weggehaald worden wanneer de workflows van mijn-7620 gemerged zijn
const jiraPattern = /^MIJN-\d+-(CHORE|FEATURE|BUG)/i
const dependabotPattern = /^Build\(deps(-dev)?\): bump/
const disallowedQuotesPattern = /"/
if (disallowedQuotesPattern.test(prTitle)) {
console.log('The PR title contains double quotes, which are not allowed!')
core.setFailed('PR title not valid. Please remove double quotes from the title.')
} else if (!(jiraPattern.test(prTitle) || dependabotPattern.test(prTitle))) {
if (!(jiraPattern.test(prTitle) || dependabotPattern.test(prTitle))) {
console.log('The PR title does not match JIRA ticket format!')
core.setFailed('PR title not valid. Please make sure this PR uses the JIRA ticket or dependabot format.')
} else {
Expand Down
97 changes: 0 additions & 97 deletions .github/workflows/release-notification.yml

This file was deleted.

92 changes: 92 additions & 0 deletions scripts/create-release-notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import sys
import re
from functools import reduce
import argparse

parser = argparse.ArgumentParser(
description="Create release notes for a github workflow."
)

parser.add_argument("previous_release_tag")
parser.add_argument("latest_release_tag")

args = parser.parse_args()

release_notes = sys.stdin.read()
if not release_notes:
raise Exception("Release notes read from the stdin are empty")

categories = {
"features": {
"pattern": re.compile(r'MIJN-[0-9]+-FEATURE', flags=re.IGNORECASE),
"commits": []
},
"chores": {
"pattern": re.compile(r'MIJN-[0-9]+-CHORE', flags=re.IGNORECASE),
"commits": []
},
"bugs": {
"pattern": re.compile(r'MIJN-[0-9]+-BUG', flags=re.IGNORECASE),
"commits": []
},
}

other = {
# Must start with a commit hash
"pattern": re.compile(r'^[a-z\d]+\b'),
"commits": []
}

# Sort release notes
# ==================
for line in release_notes.split('\n'):
def identify(acc, category):
if categories[category]["pattern"].search(line):
return category
return acc

category = reduce(identify, categories, None)

try:
categories[category]["commits"].append(line)
except KeyError:
if other["pattern"].match(line):
other["commits"].append(line)

# Format
# ================================
categories["other"] = other

RELEASE_SUFFIX = 'release-'
previous_version = args.previous_release_tag.removeprefix(RELEASE_SUFFIX)
latest_version = args.latest_release_tag.removeprefix(RELEASE_SUFFIX)

# Lines entered here are at the top of the release notes.
release_notes = [
f"Here are the updates between the {previous_version} and {latest_version} releases.\n",
]

release_notes_size = len(release_notes)

def format_category(acc, category):
commits = categories[category]["commits"]
if not commits:
return acc

# Add title in markdown.
acc.append(f"## {category.title()}\n")

for commit in commits:
acc.append(commit)

# Make sure a newline is added after the block of commits.
acc.append("")

return acc

release_notes = reduce(format_category, categories, release_notes)
if release_notes_size == len(release_notes):
raise Exception("Not a single line added to the release notes.")

print('\n'.join(release_notes))

2 changes: 1 addition & 1 deletion src/universal/config/feature-toggles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const FeatureToggle = {
contactmomentenActive: !IS_PRODUCTION,

// WPI Portaal
svwiLinkActive: !IS_PRODUCTION,
svwiLinkActive: false, // NOTE: The status of this feature is unknown.

// Toeristische verhuur
toeristischeVerhuurActive: true,
Expand Down

0 comments on commit c196dae

Please sign in to comment.