72 lines
1.8 KiB
Bash
Executable File
72 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Admin script to prepare a new release of the cryosparc lanes
|
|
#
|
|
# 1. Update `versions` file
|
|
# 2. Update all cluster_script.sh with new version
|
|
# 3. Commit changes to git
|
|
# 4. Tag with release
|
|
set -euo pipefail
|
|
|
|
# from $(git --exec-path)/git-sh-setup
|
|
require_clean_work_tree () {
|
|
git rev-parse --verify HEAD >/dev/null || exit 1
|
|
git update-index -q --ignore-submodules --refresh
|
|
err=0
|
|
|
|
if ! git diff-files --quiet --ignore-submodules
|
|
then
|
|
echo >&2 "Cannot $1: You have unstaged changes."
|
|
err=1
|
|
fi
|
|
|
|
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
|
|
then
|
|
if [ $err = 0 ]
|
|
then
|
|
echo >&2 "Cannot $1: Your index contains uncommitted changes."
|
|
else
|
|
echo >&2 "Additionally, your index contains uncommitted changes."
|
|
fi
|
|
err=1
|
|
fi
|
|
|
|
if [ $err = 1 ]
|
|
then
|
|
test -n "${2:-}" && echo >&2 "$2"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function main {
|
|
# Should be run from top-level
|
|
[ -f version ] || {
|
|
echo "Error: Please run from the repository root" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Require clean git
|
|
require_clean_work_tree "make release"
|
|
|
|
# Prompt for version
|
|
oldversion="$(cat version)"
|
|
read -p "New version (was $oldversion): " version
|
|
|
|
# 1. Update version
|
|
echo $version > version
|
|
git add version
|
|
|
|
# 2. Update all cluster_script.sh with new version
|
|
git ls-files */cluster_script.sh 2>/dev/null | while read -s script; do
|
|
echo "Updating $script"
|
|
sed -ri "s/^(# Lane:.*) +v([0-9.]+[^ ]*)( \([0-9-]+\))? *$/\1 v${version} ($(date +%Y-%m-%d))/g" "$script"
|
|
git add "$script"
|
|
done
|
|
# 3. Commit changes to git
|
|
git ci -m "Release v$version"
|
|
|
|
# 4. Tag with release
|
|
git tag -a -m "Release v$version" "v$version"
|
|
}
|
|
|
|
main "$@"
|