File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #! /bin/sh
1+ #! /usr/ bin/env bash
22set -e
33
44REPO_PATH=" $( dirname " $( cd " $( dirname " $0 " ) " ; pwd -P ) " ) "
55
6- if [ -z " $1 " ]; then
7- echo " Usage: script/release [patch | minor | major]"
8- exit 1
9- fi
10-
116if [ " $( git rev-parse --abbrev-ref HEAD) " != " dev" ]; then
127 echo " Refusing to publish a release from a branch other than dev"
138 exit 1
@@ -18,23 +13,34 @@ if [ -z "$(command -v poetry)" ]; then
1813 exit 1
1914fi
2015
21- # Make sure the latest dev is pulled:
22- git pull origin dev
16+ function generate_version {
17+ latest_tag=" $( git tag --sort=committerdate | tail -1) "
18+ month=" $( date +' %Y.%m' ) "
19+
20+ if [[ " $latest_tag " =~ " $month " .* ]]; then
21+ patch=" $( echo " $latest_tag " | cut -d . -f 3) "
22+ (( patch= patch+ 1 ))
23+ echo " $month .$patch "
24+ else
25+ echo " $month .0"
26+ fi
27+ }
2328
2429# Temporarily uninstall pre-commit hooks so that we can push to dev and master:
2530pre-commit uninstall
2631
27- old_version=" $( poetry version | awk -F' ' ' { print $2 }' ) "
32+ # Pull the latest dev:
33+ git pull origin dev
2834
29- poetry version " $1 "
35+ # Generate the next version (in the format YEAR.MONTH.RELEASE_NUMER):
36+ new_version=$( generate_version)
3037
3138# Update the PyPI package version:
32- new_version= " $( poetry version | awk -F ' ' ' { print $2 } ' ) "
39+ sed -i " " " s/^ version = \" .* \" /version = \" $new_version \" /g " " $REPO_PATH /pyproject.toml "
3340git add pyproject.toml
3441
3542# Update the docs version:
36- sphinx_conf=$( sed " s/$old_version /$new_version /g" " $REPO_PATH /docs/conf.py" )
37- echo " $sphinx_conf " > " $REPO_PATH /docs/conf.py"
43+ sed -i " " " s/^release = \" .*\" /release = \" $new_version \" /g" " $REPO_PATH /docs/conf.py"
3844git add docs/conf.py
3945
4046# Commit, tag, and push:
You can’t perform that action at this time.
0 commit comments