Created
January 3, 2018 09:07
-
-
Save kuanyui/70867c1230bc76e53adfc234692844ce to your computer and use it in GitHub Desktop.
一旦L14的exit 1存在,什麼東西都印不出來.....
This file contains hidden or 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
| #!/bin/env bash | |
| set -e | |
| CURRENT=$(git describe --tags --abbrev=0) | |
| uncommitted_non_dist_files=$(git status --porcelain | grep -v '^ . dist/') | |
| if [[ ! -z $uncommitted_non_dist_files ]]; then | |
| echo $(tput setaf 1)$(tput bold)"Found some uncommitted files:"$(tput sgr0) | |
| echo $uncommitted_non_dist_files | while read -r file; do | |
| echo $(tput setaf 1) " ${file}"$(tput sgr0) | |
| done | |
| echo $(tput setaf 3)"Please committed all files "$(tput bold)"(except for dist/) to comtinue. Abort." $(tput sgr0) | |
| exit 1 | |
| else | |
| echo "Check passed! Files are ready." | |
| fi | |
| echo $(tput setaf 2)$(tput bold)"Following files in dist/ will be released:"$(tput sgr0) | |
| git status --porcelain | grep '^ . dist/' | while read -r file; do | |
| echo " ${file}" | |
| done | |
| echo $(tput setaf 6)"Enter release version: "$(tput sgr0) | |
| read -p "[current version = $CURRENT] -> v" VERSION | |
| if [[ $VERSION =~ ^([0-9]+\.){2}(\*|[0-9]+)$ ]] | |
| then | |
| VERSION="v$VERSION" | |
| read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r | |
| echo # (optional) move to a new line | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| echo "Releasing $VERSION ..." | |
| perl -p -i -e "s/v\d+\.\d+\.\d+/$VERSION/" package.json | |
| npm run build | |
| git add package.json dist | |
| git commit -m "[Release] $VERSION" | |
| git tag $VERSION | |
| git push | |
| git push origin $VERSION | |
| fi | |
| else | |
| echo "version must be 3 digit numbers and no need to type the 'v' " | |
| echo "please try again!" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment