diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index e4296305a2..a016259291 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -41,13 +41,15 @@ jobs: fi - name: Check for changelog fragment + env: + PR_NUMBER: ${{ github.event.pull_request.number }} run: | # Check for any new fragment files in any .changelog/ directory fragments=$(git diff --diff-filter=A --name-only FETCH_HEAD -- '**/.changelog/*' '.changelog/*' | grep -v '.gitignore' || true) if [[ -z "$fragments" ]]; then echo "No changelog fragment found for this PR." echo "" - echo "Add a file named .changelog/${{ github.event.pull_request.number }}." + echo "Add a file named .changelog/${PR_NUMBER}." echo "where is one of: added, changed, deprecated, removed, fixed" echo "" echo "For coordinated packages, add to the root .changelog/ directory." @@ -57,6 +59,24 @@ jobs: echo "Or add the \"Skip Changelog\" label if this job should be skipped." exit 1 fi + invalid=() + while IFS= read -r f; do + base=$(basename "$f") + if [[ ! "$base" =~ ^([0-9]+)\.(added|changed|deprecated|removed|fixed)$ ]]; then + invalid+=("$f (expected .; type one of added, changed, deprecated, removed, fixed)") + continue + fi + if [[ "${BASH_REMATCH[1]}" != "${PR_NUMBER}" ]]; then + invalid+=("$f (PR number ${BASH_REMATCH[1]} does not match this PR's number ${PR_NUMBER})") + fi + done <<< "$fragments" + if (( ${#invalid[@]} > 0 )); then + echo "Invalid changelog fragment(s):" + for msg in "${invalid[@]}"; do + echo " $msg" + done + exit 1 + fi echo "Found changelog fragment(s):" echo "$fragments" diff --git a/pyproject.toml b/pyproject.toml index a46fbd743b..ba53af4d43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -249,6 +249,7 @@ issue_format = "[#{issue}](https://github.com/open-telemetry/opentelemetry-pytho wrap = true issue_pattern = "^(\\d+)" +# NOTE: remember to update the changelog workflow if these types change [[tool.towncrier.type]] directory = "added" name = "Added"