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
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,26 @@ before sending PRs. We cannot accept code without this.
### Code sample

<!-- Proposing an API change? Provide code samples showing how the API will be used. -->

### Release notes

<!--
Your PR description must contain a "relnote:" line.
Our CI release notes linter will verify this before allowing a merge.

Please keep EXACTLY ONE of the options below:
-->

relnote: none

<!--
Alternative Options (Replace the "relnote: none" line above with one of these if applicable):

1. For a user-facing change:
relnote: Added support for second-generation memory allocation optimizations

2. For a manual/legacy override (stops the script from automatically appending this PR number):
relnote: Consolidated memory allocation upgrades (#884, #885)

Multiple relnotes may be included in a single PR, each with their own relnote line
-->
37 changes: 37 additions & 0 deletions .github/workflows/lint-relnotes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint Release Notes

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

permissions:
contents: read

jobs:
lint-pr-body:
runs-on: ubuntu-latest
steps:
- name: Validate PR Release Notes
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
echo "Analyzing PR description for release notes..."

# 1. Check if the body contains a 'relnote:' or 'relnotes:' line (case-insensitive)
if ! echo "$PR_BODY" | grep -qiE '^[Rr]elnotes?:'; then
echo "❌ Error: Could not find a 'relnote:' or 'relnotes:' line in the PR description."
echo "Please ensure your PR description includes a line matching: 'relnote: <your note>' or 'relnote: none'"
exit 1
fi

# 2. Extract the actual note content to ensure it isn't blank
# This grabs the line, strips the prefix, and trims trailing/leading spaces
NOTE_CONTENT=$(echo "$PR_BODY" | grep -iE '^[Rr]elnotes?:' | head -n 1 | sed -E 's/^[Rr]elnotes?:[[:space:]]*//g' | xargs)

if [ -z "$NOTE_CONTENT" ]; then
echo "❌ Error: The 'relnote:' field is empty."
echo "Please provide a brief release note or write 'relnote: none' if this change doesn't require one."
Comment thread
inlined marked this conversation as resolved.
exit 1
fi

echo "✅ Success! Found valid release note: '$NOTE_CONTENT'"
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebase-functions",
"version": "7.2.6-rc.0",
"version": "0.0.0-development",
Comment thread
inlined marked this conversation as resolved.
"description": "Firebase SDK for Cloud Functions",
"keywords": [
"firebase",
Expand Down
91 changes: 91 additions & 0 deletions scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
set -e

# Ensure we run from the repository root
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR/.."

PREVIOUS_TAG=""
for tag in $(git log --tags --simplify-by-decoration --pretty="format:%d" | grep -o 'tag: [^,)]*' | sed 's/tag: //'); do
if echo "$tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
PREVIOUS_TAG="$tag"
break
fi
done

if [ -z "$PREVIOUS_TAG" ]; then
echo "Initial release."
exit 0
fi

# First pass: Identify all reverted PRs and SHAs in the interval
REVERTED_PRS=" "
REVERTED_SHAS=" "
while read -r sha; do
COMMIT_SUBJECT=$(git log -1 --format="%s" "$sha")
if [[ "$COMMIT_SUBJECT" =~ ^Revert[[:space:]]\" ]]; then
# Extract PR number from revert subject: e.g. Revert "feat: foo (#123)" -> 123
REVERTED_PR=$(echo "$COMMIT_SUBJECT" | grep -oE '\(#[0-9]+\)' | tr -d '(#)' || true)
if [ -n "$REVERTED_PR" ]; then
REVERTED_PRS+="$REVERTED_PR "
fi

# Extract reverted commit SHA from the body: e.g. "This reverts commit 8ec5..."
REVERTED_SHA=$(git log -1 --format="%b" "$sha" | grep -iE 'this reverts commit' | sed -E 's/.*[Tt]his reverts commit[[:space:]]+([0-9a-fA-F]+).*/\1/' || true)
if [ -n "$REVERTED_SHA" ]; then
RESOLVED_SHA=$(git rev-parse "$REVERTED_SHA" 2>/dev/null || echo "$REVERTED_SHA")
REVERTED_SHAS+="$RESOLVED_SHA "

# Also try to get the PR number associated with the reverted commit
REVERTED_SHA_SUBJECT=$(git log -1 --format="%s" "$RESOLVED_SHA" 2>/dev/null || true)
if [ -n "$REVERTED_SHA_SUBJECT" ]; then
REVERTED_SHA_PR=$(echo "$REVERTED_SHA_SUBJECT" | grep -oE '\(#[0-9]+\)' | tr -d '(#)' || true)
if [ -n "$REVERTED_SHA_PR" ]; then
REVERTED_PRS+="$REVERTED_SHA_PR "
fi
fi
fi
fi
done < <(git rev-list "${PREVIOUS_TAG}..HEAD")

CHANGELOG_NOTES=""
while read -r sha; do
# Check if this SHA was reverted
FULL_SHA=$(git rev-parse "$sha")
if [[ "$REVERTED_SHAS" =~ " $FULL_SHA " ]]; then
continue
fi

COMMIT_SUBJECT=$(git log -1 --format="%s" "$sha")

# Skip revert commits themselves
if [[ "$COMMIT_SUBJECT" =~ ^Revert[[:space:]]\" ]]; then
continue
fi

PR_SUFFIX=$(echo "$COMMIT_SUBJECT" | grep -oE '\(#[0-9]+\)$' || true)
if [ -n "$PR_SUFFIX" ]; then
PR_NUM=$(echo "$PR_SUFFIX" | tr -d '(#)')
if [[ "$REVERTED_PRS" =~ " $PR_NUM " ]]; then
continue
fi
fi

while read -r line; do
if [ -n "$line" ]; then
if echo "$line" | grep -qE '\(#[0-9]+\)$'; then
CHANGELOG_NOTES+="- $line"$'\n'
elif [ -n "$PR_SUFFIX" ]; then
CHANGELOG_NOTES+="- $line $PR_SUFFIX"$'\n'
else
CHANGELOG_NOTES+="- $line"$'\n'
fi
fi
done < <(git log -1 --format="%b" "$sha" | \
grep -iE '^relnotes?:' | \
grep -vi 'relnotes?:[[:space:]]*none' | \
sed -E 's/^[Rr]elnotes?:[[:space:]]*//g' | \
sed -E 's/[[:space:]]*$//')
done < <(git rev-list "${PREVIOUS_TAG}..HEAD")

echo -e "$CHANGELOG_NOTES"
Loading
Loading