2021-02-19 23:33:19 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# https://xaoxuu.com/wiki/stellar
|
|
|
|
#
|
|
|
|
# 只有 rc 阶段的测试版本和正式版本发布到 npm
|
|
|
|
#
|
|
|
|
# 1. 输入要发布的版本号
|
|
|
|
# 2. 修改主题 _config.yml 中的 stellar.version
|
|
|
|
# 3. 修改主题 package.json 中的 version
|
|
|
|
# 4. 提交 commit
|
|
|
|
|
|
|
|
# 版本号 例如 1.0.0-rc.1
|
|
|
|
VERSION=$1
|
|
|
|
|
|
|
|
# 替换版本号
|
|
|
|
function prepare() {
|
2021-02-21 20:53:49 +08:00
|
|
|
text="'"${VERSION}"'"
|
2021-02-19 23:33:19 +08:00
|
|
|
sed -i "" "s/^ version:\([^\"]\{1,\}\)/ version: ${text}/g" '_config.yml'
|
|
|
|
sed -i "" "s/^ \"version\":\([^,]\{1,\}\)/ \"version\": \"${VERSION}\"/g" 'package.json'
|
2021-02-21 20:53:49 +08:00
|
|
|
main=${VERSION%%.*}
|
|
|
|
sub=${VERSION#*.}
|
|
|
|
sub=${sub%%.*}
|
|
|
|
jsdelivr=$main'.'$sub
|
2022-12-20 00:09:34 +08:00
|
|
|
sed -i "" "s/\(gcore.jsdelivr.net\/npm\/hexo-theme-stellar@[^/]\{1,\}\)/gcore.jsdelivr.net\/npm\/hexo-theme-stellar@${jsdelivr}/g" '_config.yml'
|
2021-02-19 23:33:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# 提交
|
|
|
|
function commit() {
|
|
|
|
msg="release: ${VERSION}"
|
|
|
|
|
|
|
|
printf "\n\n> \033[32m%s\033[0m" 'git add --all'
|
|
|
|
printf "\n"
|
|
|
|
git add --all
|
|
|
|
|
|
|
|
printf "\n\n> \033[32m%s\033[0m" 'git commit -m'
|
|
|
|
printf " \033[35m%s\033[0m" ${msg}
|
|
|
|
printf "\n"
|
|
|
|
git commit -m "${msg}"
|
|
|
|
|
2021-02-21 21:31:43 +08:00
|
|
|
git checkout npm
|
|
|
|
git rebase main
|
|
|
|
|
2021-02-19 23:33:19 +08:00
|
|
|
printf "\n\n> \033[32m%s\033[0m" 'git push origin'
|
2022-12-20 00:55:54 +08:00
|
|
|
# printf "\n"
|
2021-02-21 21:31:43 +08:00
|
|
|
git push origin main
|
|
|
|
git push origin npm
|
2021-02-25 13:14:01 +08:00
|
|
|
|
2022-12-20 00:45:27 +08:00
|
|
|
# npm publish
|
2021-02-25 13:14:01 +08:00
|
|
|
|
2022-12-20 00:55:54 +08:00
|
|
|
# git tag ${VERSION}
|
|
|
|
# git push --tags
|
2021-02-28 18:23:29 +08:00
|
|
|
|
2021-02-21 23:21:27 +08:00
|
|
|
git checkout main
|
2021-02-19 23:33:19 +08:00
|
|
|
# done
|
|
|
|
printf "\n\n> \033[32m%s\033[0m\n" 'Congratulations!'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
case $VERSION in
|
|
|
|
'')
|
|
|
|
read -p "请输入要发布的版本号: " VERSION
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-02-21 21:31:43 +08:00
|
|
|
prepare && commit
|