From a6ffff6428655b948779018417f6beea7248fd96 Mon Sep 17 00:00:00 2001 From: "Paul S. Schweigert" Date: Thu, 19 Mar 2026 16:20:35 -0400 Subject: [PATCH 1/2] chore: use github tooling to build release notes Signed-off-by: Paul S. Schweigert --- .github/release.yml | 19 +++++++++++++++ .github/scripts/release.sh | 40 +++++++++++++++++-------------- .github/workflows/pr-label.yml | 43 ++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/pr-label.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..fbc42d032 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,19 @@ +changelog: + exclude: + labels: + - duplicate + - invalid + - wontfix + categories: + - title: "New Features" + labels: + - enhancement + - title: "Bug Fixes" + labels: + - bug + - title: "Documentation" + labels: + - documentation + - title: "Other Changes" + labels: + - "*" diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 5f85c6d7f..55f8295af 100755 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -13,13 +13,30 @@ CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}" uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "${TARGET_VERSION}" UV_FROZEN=0 uv lock --upgrade-package mellea -# collect release notes +# push changes +git config --global user.name 'github-actions[bot]' +git config --global user.email 'github-actions[bot]@users.noreply.github.com' + +# Configure the remote with the token +git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + +TARGET_TAG_NAME="v${TARGET_VERSION}" + +# Commit and push version bump first so the tag has the right base +git add pyproject.toml uv.lock +COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]" +git commit -m "${COMMIT_MSG}" +git push origin main + +# create GitHub release (incl. Git tag) with GitHub-native generated notes +gh release create "${TARGET_TAG_NAME}" --generate-notes + +# pull the generated notes back locally to update the changelog REL_NOTES=$(mktemp) -uv run --no-sync semantic-release changelog --unreleased >> "${REL_NOTES}" +gh release view "${TARGET_TAG_NAME}" --json body -q ".body" >> "${REL_NOTES}" # update changelog TMP_CHGLOG=$(mktemp) -TARGET_TAG_NAME="v${TARGET_VERSION}" RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}" printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}" cat "${REL_NOTES}" >> "${TMP_CHGLOG}" @@ -28,17 +45,6 @@ if [ -f "${CHGLOG_FILE}" ]; then fi mv "${TMP_CHGLOG}" "${CHGLOG_FILE}" -# push changes -git config --global user.name 'github-actions[bot]' -git config --global user.email 'github-actions[bot]@users.noreply.github.com' - -# Configure the remote with the token -git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - -git add pyproject.toml uv.lock "${CHGLOG_FILE}" -COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]" -git commit -m "${COMMIT_MSG}" -git push origin main - -# create GitHub release (incl. Git tag) -gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}" \ No newline at end of file +git add "${CHGLOG_FILE}" +git commit -m "docs: update changelog for ${TARGET_TAG_NAME} [skip ci]" +git push origin main \ No newline at end of file diff --git a/.github/workflows/pr-label.yml b/.github/workflows/pr-label.yml new file mode 100644 index 000000000..bea247f42 --- /dev/null +++ b/.github/workflows/pr-label.yml @@ -0,0 +1,43 @@ +name: "Label PR by conventional commit prefix" + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + label: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Apply label based on PR title prefix + uses: actions/github-script@v7 + with: + script: | + const title = context.payload.pull_request.title; + const labelMap = { + 'feat': 'enhancement', + 'fix': 'bug', + 'docs': 'documentation', + 'test': 'testing', + 'perf': 'enhancement', + 'refactor': 'enhancement', + 'ci': 'integrations', + 'chore': null, + 'build': null, + 'style': null, + }; + + const match = title.match(/^(\w+)[\(!\:]/); + if (!match) return; + + const prefix = match[1]; + const label = labelMap[prefix]; + if (!label) return; + + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: [label], + }); From 6ff9625d210d83fa5a0860f3b329ed51c087273f Mon Sep 17 00:00:00 2001 From: "Paul S. Schweigert" Date: Fri, 20 Mar 2026 10:59:58 -0400 Subject: [PATCH 2/2] add revert message prefix to pr label list with null value Signed-off-by: Paul S. Schweigert --- .github/workflows/pr-label.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-label.yml b/.github/workflows/pr-label.yml index bea247f42..af48a29ad 100644 --- a/.github/workflows/pr-label.yml +++ b/.github/workflows/pr-label.yml @@ -26,6 +26,7 @@ jobs: 'chore': null, 'build': null, 'style': null, + 'revert': null, }; const match = title.match(/^(\w+)[\(!\:]/);