Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -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:
- "*"
40 changes: 23 additions & 17 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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}"
git add "${CHGLOG_FILE}"
git commit -m "docs: update changelog for ${TARGET_TAG_NAME} [skip ci]"
git push origin main
44 changes: 44 additions & 0 deletions .github/workflows/pr-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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,
'revert': null,
};
Comment on lines +18 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our current mergify rule is contains: fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release. Do we need to do anything special for the revert tag? I don't see it listed here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRs that don't have a label would end up in an uncategorized liast at the end... I'll add it with a null entry (similar to chore/build/style)


const match = title.match(/^(\w+)[\(!\:]/);
if (!match) return;

const prefix = match[1];
const label = labelMap[prefix];
if (!label) return;
Comment on lines +33 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, an early return here just means that the PR doesn't get a label? This will never stop a PR from being opened / processed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's correct : no impact to PR creation, it just wouldn't have a label


await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: [label],
});
Loading