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
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": "6.6.0",
"version": "7.0.0-rc.0",
"description": "Firebase SDK for Cloud Functions",
"keywords": [
"firebase",
Expand Down
13 changes: 11 additions & 2 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ VERSION=$1
if [[ $VERSION == "" ]]; then
printusage
exit 1
elif [[ ! ($VERSION == "patch" || $VERSION == "minor" || $VERSION == "major") ]]; then
elif [[ ! ($VERSION == "patch" || $VERSION == "minor" || $VERSION == "major" || $VERSION == "prerelease") ]]; then
printusage
exit 1
fi
Expand Down Expand Up @@ -89,7 +89,11 @@ echo "Ran publish build."

echo "Making a $VERSION version..."
if [[ $PRE_RELEASE != "" ]]; then
npm version pre$VERSION --preid=rc
if [[ $VERSION == "prerelease" ]]; then
npm version prerelease --preid=rc
else
npm version pre$VERSION --preid=rc
fi
else
npm version $VERSION
fi
Expand Down Expand Up @@ -118,6 +122,10 @@ fi
npm publish "${PUBLISH_ARGS[@]}"
echo "Published to npm."

echo "Pushing to GitHub..."
git push origin master --tags
echo "Pushed to GitHub."

if [[ $PRE_RELEASE != "" ]]; then
echo "Published a pre-release version. Skipping post-release actions."
exit
Comment on lines +125 to 131
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While adding the git push here correctly pushes pre-release tags, it introduces a code duplication issue. For a full release, git push origin master --tags is now called twice: once here, and once again on line 147 after the changelog is cleaned up. This results in an extra, unnecessary push operation for full releases.

To improve this, you can move the push logic inside the if [[ $PRE_RELEASE != "" ]] block. This ensures the push only happens once at the correct time for both pre-releases and full releases, making the script cleaner and more efficient.

Suggested change
echo "Pushing to GitHub..."
git push origin master --tags
echo "Pushed to GitHub."
if [[ $PRE_RELEASE != "" ]]; then
echo "Published a pre-release version. Skipping post-release actions."
exit
if [[ $PRE_RELEASE != "" ]]; then
echo "Pushing to GitHub..."
git push origin master --tags
echo "Pushed to GitHub."
echo "Published a pre-release version. Skipping post-release actions."
exit
fi

Expand All @@ -136,6 +144,7 @@ git commit -m "[firebase-release] Removed change log and reset repo after ${NEW_
echo "Cleaned up release notes."

echo "Pushing to GitHub..."
# Push the changelog cleanup commit.
git push origin master --tags
echo "Pushed to GitHub."

Expand Down
Loading