Merge gem-build & bump tool

Drop the yard doc
This commit is contained in:
Cotes Chung 2021-01-28 22:32:54 +08:00
parent 5c04d4e45b
commit c9765e6923
2 changed files with 44 additions and 37 deletions

View file

@ -1,13 +1,17 @@
#!/usr/bin/env bash
#
# Bump latest version to
# 1. Bump latest version number to files:
# - _sass/jekyll-theme-chirpy.scss
# - assets/js/.copyright.js
# - assets/js/dist/*.js
# - assets/js/dist/*.js (will be built by gulp later)
# - jekyll-theme-chirpy.gemspec
# - package.json
#
# Required: gulp
# 2. Create a git-tag
#
# 3. Build a rubygem package
#
# Requires: gulp, rubygem
set -eu
@ -20,7 +24,28 @@ GEM_SPEC="jekyll-theme-chirpy.gemspec"
NODE_META="package.json"
bump_assets() {
_check_src() {
if [[ ! -f $1 && ! -d $1 ]]; then
echo -e "Error: missing file \"$1\"!\n"
exit -1
fi
}
check() {
if [[ -n $(git status . -s) ]]; then
echo "Warning: commit unstaged files first, and then run this tool againt."
exit -1
fi
for i in "${!ASSETS[@]}"; do
_check_src "${ASSETS[$i]}"
done
_check_src "$NODE_META"
_check_src "$GEM_SPEC"
}
_bump_assets() {
_version="$1"
for i in "${!ASSETS[@]}"; do
sed -i "s/v[[:digit:]]\.[[:digit:]]\.[[:digit:]]/v$_version/" "${ASSETS[$i]}"
@ -29,20 +54,20 @@ bump_assets() {
gulp
}
bump_gemspec() {
_bump_gemspec() {
sed -i "s/[[:digit:]]\.[[:digit:]]\.[[:digit:]]/$1/" "$GEM_SPEC"
}
bump_node() {
_bump_node() {
sed -i \
"s,[\"]version[\"]: [\"][[:digit:]]\.[[:digit:]]\.[[:digit:]][\"],\"version\": \"$1\"," \
$NODE_META
}
bump() {
bump_assets "$1"
bump_gemspec "$1"
bump_node "$1"
_bump_assets "$1"
_bump_gemspec "$1"
_bump_node "$1"
if [[ -n $(git status . -s) ]]; then
git add .
@ -50,11 +75,12 @@ bump() {
fi
}
build_gem() {
gem build "$GEM_SPEC"
}
main() {
if [[ -n $(git status . -s) ]]; then
echo "Warning: commit unstaged files first, and then run this tool againt."
exit -1
fi
check
_latest_tag="$(git describe --tags --abbrev=0)"
@ -69,15 +95,18 @@ main() {
exit -1
fi
echo "Bump version to $_version"
echo -e "Bump version to $_version\n"
bump "$_version"
echo "Create tag v$_version"
echo -e "Create tag v$_version\n"
git tag "v$_version"
build_gem
else
echo "Error: Illegal version number: '$_version'"
fi
}

View file

@ -1,22 +0,0 @@
#!/usr/bin/env bash
#
# Create a ruby-gem pakcage with doc
#
# Required: rubygem, yard
set -eu
GEM_CONFIG="./jekyll-theme-chirpy.gemspec"
if [[ ! -f $GEM_CONFIG ]]; then
echo "Error: .gemspec file not found!"
exit -1
fi
if [[ -d doc ]]; then
rm -rf doc
fi
yard doc
gem build "$GEM_CONFIG"