Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify script to allow release from non-main branch #760

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Changes from 2 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
47 changes: 21 additions & 26 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ IFS=$'\n\t'
echo_help() {
cat << EOF
USAGE:
./scripts/publish.sh
./scripts/publish.sh <branch-name>
EOF
}

Expand Down Expand Up @@ -52,20 +52,18 @@ Remember to create a release on GitHub with a changelog notes:
EOF
}

if [ $# -gt 0 ]; then
# Show help message if -h, --help, or help passed
case $1 in
-h | --help | help)
echo_help
exit 0
;;
*)
echo "Invalid argument $1"
echo ""
echo_help
exit 1
;;
esac
if [ $# -ne 1 ]; then
echo "Error: Branch name is mandatory"
echo ""
echo_help
exit 1
fi

BRANCH_NAME=$1

if [ "$BRANCH_NAME" = "main" ]; then
echo "Error! Cannot publish from the 'main' branch."
exit 1
fi

# Make sure our working dir is the repo root directory
Expand All @@ -74,15 +72,17 @@ cd "$(git rev-parse --show-toplevel)"
echo "Fetching git remotes"
git fetch

GIT_STATUS=$(git status)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

if ! grep -q 'On branch main' <<< "$GIT_STATUS"; then
echo "Error! Must be on main branch to publish"
if [ "$CURRENT_BRANCH" != "$BRANCH_NAME" ]; then
echo "Error! Must be on branch '$BRANCH_NAME' to publish"
exit 1
fi

if ! grep -q "Your branch is up to date with 'origin/main'." <<< "$GIT_STATUS"; then
echo "Error! Must be up to date with origin/main to publish"
GIT_STATUS=$(git status)

if ! grep -q "Your branch is up to date with 'origin/$BRANCH_NAME'." <<< "$GIT_STATUS"; then
echo "Error! Must be up to date with origin/$BRANCH_NAME to publish"
exit 1
fi

Expand All @@ -104,9 +104,4 @@ echo "Tagging and publishing release"
yarn -s --ignore-scripts publish --access=public

echo "Pushing git commit and tag"
git push --follow-tags

echo "Publish successful!"
echo ""

create_github_release
Copy link
Collaborator

Choose a reason for hiding this comment

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

intentionally rm'd? and is the --follow-tags not needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope lost in copy paste, added back

git push