From 918fed51a130cddd684a8ee68e1a1cffb42f7016 Mon Sep 17 00:00:00 2001 From: shimataro Date: Thu, 23 Jan 2020 23:20:07 +0900 Subject: [PATCH] Feature/scripts (#87) * * refactor create-release-branch.sh * * refactor rebuild.sh * * refactor update-dependencies.sh --- scripts/create-release-branch.sh | 22 ++++++++++------------ scripts/rebuild.sh | 2 ++ scripts/update-dependencies.sh | 20 +++++++++++--------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/scripts/create-release-branch.sh b/scripts/create-release-branch.sh index 210c5fc..a736165 100755 --- a/scripts/create-release-branch.sh +++ b/scripts/create-release-branch.sh @@ -3,6 +3,8 @@ # - git; I believe it's already installed. # - sed; GNU sed is preferred. POSIX sed may not work. +set -e + BASE_BRANCH="develop" PACKAGE_NAME="ssh-key-action" @@ -36,14 +38,14 @@ function main() { check_version_format ${VERSION} check_current_branch - run create_branch ${BRANCH} - run update_changelog ${VERSION} - run update_package_version ${VERSION} - run update_dependencies_version - run regenerate_package_lock - run build_package - run commit_changes ${VERSION} - run finish ${VERSION} ${BRANCH} ${TAG} + create_branch ${BRANCH} + update_changelog ${VERSION} + update_package_version ${VERSION} + update_dependencies_version + regenerate_package_lock + build_package + commit_changes ${VERSION} + finish ${VERSION} ${BRANCH} ${TAG} } function usage() { @@ -91,10 +93,6 @@ function check_current_branch() { exit 2 } -function run() { - "$@" || exit 1 -} - function create_branch() { local BRANCH=$1 diff --git a/scripts/rebuild.sh b/scripts/rebuild.sh index fbc39c2..8301938 100755 --- a/scripts/rebuild.sh +++ b/scripts/rebuild.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + rm -rf node_modules package-lock.json npm i npm run build diff --git a/scripts/update-dependencies.sh b/scripts/update-dependencies.sh index b859641..7ae8bb8 100755 --- a/scripts/update-dependencies.sh +++ b/scripts/update-dependencies.sh @@ -1,30 +1,32 @@ #!/bin/bash # update dependencies +set -e + DATE=$(date +"%Y%m%d") BRANCH=feature/update-dependencies-${DATE} COLOR_SUCCESS="\e[1;32m" COLOR_RESET="\e[m" # create branch -git checkout develop || exit 1 -git checkout -b ${BRANCH} || exit 1 +git checkout develop +git checkout -b ${BRANCH} # check updates npm ci -npm run check-updates -- -u || exit 1 +npm run check-updates -- -u # re-install packages -rm -rf package-lock.json node_modules || exit 1 -npm i || exit 1 +rm -rf package-lock.json node_modules +npm i # build check -npm run build || exit 1 +npm run build # commit -npm ci --only=production || exit 1 -git add package.json package-lock.json node_modules || exit 1 -git commit -m "update dependencies" || exit 1 +npm ci --only=production +git add package.json package-lock.json node_modules +git commit -m "update dependencies" # finished! echo -e "