Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"analytics": {
"tag_prefix": "v",
"pyproject_toml": "pyproject.toml",
"version_files": ["mixpanel/__init__.py"],
"changelog": "CHANGELOG.md",
"readme": "README.md",
"package_name": "mixpanel"
},
"openfeature": {
"tag_prefix": "openfeature/v",
"pyproject_toml": "openfeature-provider/pyproject.toml",
"version_files": [],
"changelog": "openfeature-provider/CHANGELOG.md",
"readme": "openfeature-provider/README.md",
"package_name": "mixpanel-openfeature"
}
}
87 changes: 87 additions & 0 deletions .github/scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -euo pipefail

MODULE="$1"
VERSION_LABEL="$2"
REPO_URL="$3"
END_REF="${4:-HEAD}"

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
MODULES_JSON="$SCRIPT_DIR/../modules.json"

TAG_PREFIX=$(jq -e -r --arg m "$MODULE" '.[$m].tag_prefix' "$MODULES_JSON") || {
echo "Unknown module: $MODULE. Valid modules: $(jq -r 'keys | join(", ")' "$MODULES_JSON")" >&2
exit 1
}
TAG_GLOB="${TAG_PREFIX}*"

PREVIOUS_TAG=$(git tag --sort=-creatordate --list "$TAG_GLOB" | head -1 || true)

if [ -z "$PREVIOUS_TAG" ]; then
RANGE="$END_REF"
else
RANGE="${PREVIOUS_TAG}..${END_REF}"
fi

DATE=$(date +%Y-%m-%d)
SAFE_URL=$(printf '%s' "$REPO_URL" | sed 's|[&/\]|\\&|g')

declare -a FEATURES=()
declare -a FIXES=()
declare -a CHORES=()

while IFS= read -r line; do
[ -z "$line" ] && continue
MSG=$(echo "$line" | cut -d' ' -f2-)

# feat / fix: include whether bare, scoped to our module, or scoped to
# `all` (cross-cutting changes that appear in every module's changelog).
# chore: include only when explicitly scoped to our module or `all` —
# bare `chore:` is the convention for changes intentionally hidden from
# the changelog (release prep PRs, CI tweaks, lockfile bumps, internal
# docs).
if [[ "$MSG" =~ ^(feat|fix)(\((${MODULE}|all)\))?:\ (.+) ]]; then
TYPE="${BASH_REMATCH[1]}"
DESC="${BASH_REMATCH[4]}"
DESC=$(echo "$DESC" | sed -E "s|\(#([0-9]+)\)|([#\1](${SAFE_URL}/pull/\1))|g")
case "$TYPE" in
feat) FEATURES+=("$DESC") ;;
fix) FIXES+=("$DESC") ;;
esac
elif [[ "$MSG" =~ ^chore\((${MODULE}|all)\):\ (.+) ]]; then
DESC="${BASH_REMATCH[2]}"
DESC=$(echo "$DESC" | sed -E "s|\(#([0-9]+)\)|([#\1](${SAFE_URL}/pull/\1))|g")
CHORES+=("$DESC")
fi
done < <(git log --oneline "$RANGE")

echo "## [${VERSION_LABEL}](${REPO_URL}/tree/${VERSION_LABEL}) (${DATE})"
echo ""

if [ ${#FEATURES[@]} -gt 0 ]; then
echo "### Features"
for entry in "${FEATURES[@]}"; do
echo "- ${entry}"
done
echo ""
fi

if [ ${#FIXES[@]} -gt 0 ]; then
echo "### Fixes"
for entry in "${FIXES[@]}"; do
echo "- ${entry}"
done
echo ""
fi

if [ ${#CHORES[@]} -gt 0 ]; then
echo "### Chores"
for entry in "${CHORES[@]}"; do
echo "- ${entry}"
done
echo ""
fi

if [ -n "$PREVIOUS_TAG" ]; then
echo "[Full Changelog](${REPO_URL}/compare/${PREVIOUS_TAG}...${VERSION_LABEL})"
fi
51 changes: 51 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: PR Title Check

on:
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
contents: read

jobs:
check-title:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: .github/modules.json
sparse-checkout-cone-mode: false

- name: Check PR title format
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
MODULE_LIST=$(jq -r 'keys | join("|")' .github/modules.json)
# Scope is optional. Bare, scoped to a known module, or scoped to
# `all` (cross-cutting changes that appear in every module's
# changelog) all pass.
MAIN_PATTERN="^(feat|fix|chore)(\((${MODULE_LIST}|all)\))?: .+"
RELEASE_PATTERN="^release: .+"

if [[ "$PR_TITLE" =~ $MAIN_PATTERN ]] || [[ "$PR_TITLE" =~ $RELEASE_PATTERN ]]; then
echo "PR title is valid: $PR_TITLE"
exit 0
fi

echo "PR title does not match the required format."
echo ""
echo " Got: $PR_TITLE"
echo ""
echo "Expected one of:"
echo " feat: description"
echo " fix: description"
echo " chore: description"
echo " feat(<module>|all): description"
echo " fix(<module>|all): description"
echo " chore(<module>|all): description"
echo " release: description"
echo ""
echo "Valid scopes: ${MODULE_LIST//|/, }, all"
exit 1
Loading
Loading