-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from vendidero/v2
v2
- Loading branch information
Showing
17 changed files
with
1,126 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/sh | ||
|
||
RELEASER_PATH=$(pwd) | ||
PLUGIN_SLUG="vendidero-helper" | ||
GITHUB_ORG="vendidero" | ||
IS_PRE_RELEASE=false | ||
|
||
# Functions | ||
# Check if string contains substring | ||
is_substring() { | ||
case "$2" in | ||
*$1*) | ||
return 0 | ||
;; | ||
*) | ||
return 1 | ||
;; | ||
esac | ||
} | ||
|
||
# Output colorized strings | ||
# | ||
# Color codes: | ||
# 0 - black | ||
# 1 - red | ||
# 2 - green | ||
# 3 - yellow | ||
# 4 - blue | ||
# 5 - magenta | ||
# 6 - cian | ||
# 7 - white | ||
output() { | ||
echo "$(tput setaf "$1")$2$(tput sgr0)" | ||
} | ||
|
||
if ! [ -x "$(command -v hub)" ]; then | ||
echo 'Error: hub is not installed. Install from https://github.com/github/hub' >&2 | ||
exit 1 | ||
fi | ||
|
||
# Release script | ||
echo | ||
output 5 "Vendidero Helper->GitHub RELEASE SCRIPT" | ||
output 5 "=============================" | ||
echo | ||
printf "This script will build files and create a tag on GitHub based on your local branch." | ||
echo | ||
echo "Before proceeding:" | ||
echo " • Ensure you have checked out the branch you wish to release" | ||
echo " • Ensure you have committed/pushed all local changes" | ||
echo " • Did you remember to update versions, changelogs, and stable tags in the readme and plugin files?" | ||
echo " • If you are running this script directory instead of via '$ npm run deploy', ensure you have installed composer in --no-dev mode." | ||
echo | ||
output 3 "Do you want to continue? [y/N]: " | ||
read -r PROCEED | ||
echo | ||
|
||
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" != "y" ]; then | ||
output 1 "Release cancelled!" | ||
exit 1 | ||
fi | ||
echo | ||
output 3 "Please enter the version number to tag, for example, 1.0.0:" | ||
read -r VERSION | ||
echo | ||
|
||
# Check if is a pre-release. | ||
if is_substring "-" "${VERSION}"; then | ||
IS_PRE_RELEASE=true | ||
output 2 "Detected pre-release version!" | ||
fi | ||
|
||
printf "Ready to proceed? [y/N]: " | ||
read -r PROCEED | ||
echo | ||
|
||
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" != "y" ]; then | ||
output 1 "Release cancelled!" | ||
exit 1 | ||
fi | ||
|
||
output 2 "Starting release to GitHub..." | ||
echo | ||
|
||
CURRENTBRANCH="$(git rev-parse --abbrev-ref HEAD)" | ||
|
||
# Create a release branch. | ||
BRANCH="build/${VERSION}" | ||
git checkout -b $BRANCH | ||
|
||
# Push branch upstream | ||
git push origin $BRANCH | ||
|
||
# Create the new release. | ||
if [ $IS_PRE_RELEASE = true ]; then | ||
hub release create -m $VERSION -m "Release of version $VERSION. See readme.txt for details." -t $BRANCH --prerelease "v${VERSION}" | ||
else | ||
hub release create -m $VERSION -m "Release of version $VERSION. See readme.txt for details." -t $BRANCH "v${VERSION}" | ||
fi | ||
|
||
git checkout $CURRENTBRANCH | ||
git branch -D $BRANCH | ||
git push origin --delete $BRANCH | ||
|
||
output 2 "GitHub release complete." |
Binary file not shown.
Oops, something went wrong.