Skip to content

Commit

Permalink
Fix: Reinforcing release script (#148)
Browse files Browse the repository at this point in the history
- Reset tags to remote tags at beginning
- Cleanup after any sort of failure (by resetting to upstream, including tags)
  • Loading branch information
Jeremy Press authored and tonyjin committed May 26, 2017
1 parent ff6ae22 commit c7137a0
Showing 1 changed file with 49 additions and 23 deletions.
72 changes: 49 additions & 23 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,30 @@ minor_release=false
patch_release=false


lint_and_test() {
yarn run lint && yarn run test
reset_to_master() {
# Update to latest code on Github master
git checkout master || return 1

# Wipe tags
git tag -l | xargs git tag -d || return 1

# Add the upstream remote if it is not present
if ! git remote get-url github-upstream; then
git remote add github-upstream [email protected]:box/box-content-preview.git || return 1
fi

# Fetch latest code with tags
git fetch --tags github-upstream || return 1;

# Reset to latest code and clear unstashed changes
git reset --hard github-upstream/master || return 1
git clean -f || return 1
}


build_lint_and_test() {
# The build command includes linting
yarn run build && yarn run test || return 1
}


Expand Down Expand Up @@ -57,7 +79,7 @@ update_changelog() {
echo "----------------------------------------------------"
echo "Error: Could not update the CHANGELOG for this version"
echo "----------------------------------------------------"
exit 1
return 1
fi
}

Expand Down Expand Up @@ -97,40 +119,30 @@ push_to_github() {
echo "----------------------------------------------------"
echo "Error while pushing version" $VERSION "to git"
echo "----------------------------------------------------"
exit 1
return 1
fi
}


# Check out latest code from git, build assets, increment version, and push t
# Check out latest code from git, build assets, increment version, and push tags
push_new_release() {
# Update to latest code on Github master
git checkout master || exit 1

if git remote get-url github-upstream; then
git fetch --tags github-upstream;
else
git remote add github-upstream [email protected]:box/box-content-preview.git
git fetch --tags github-upstream;
fi;

git reset --hard github-upstream/master || exit 1
git clean -f || exit 1
# Get latest commited code and tags
reset_to_master || return 1

# Run linting and tests
lint_and_test
# Run build script, linting, and tests
build_lint_and_test || return 1

# Bump the version number
increment_version
increment_version || return 1

# Update changelog
update_changelog
update_changelog || return 1

# Update readme
update_readme
update_readme || return 1

# Push to Github
push_to_github
push_to_github || return 1
}


Expand All @@ -152,5 +164,19 @@ if ! push_new_release; then
echo "----------------------------------------------------"
echo "Error while pushing new release!"
echo "----------------------------------------------------"

echo "----------------------------------------------------"
echo "Cleaning workspace by checking out master and removing tags"
echo "----------------------------------------------------"

if ! reset_to_master; then
echo "----------------------------------------------------"
echo "Error while cleaning workspace!"
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Workspace succesfully cleaned!"
echo "----------------------------------------------------"
fi;
exit 1
fi

0 comments on commit c7137a0

Please sign in to comment.