@@ -19,23 +19,44 @@ if [ -n "$STATUS" ]; then
1919 exit 1
2020fi
2121
22- # clean up old poetry artifacts:
22+ # ## clean up old poetry artifacts:
2323rm -rf dist/
24- # clean up old maven artifacts:
25- rm -rf target/
26- # clean up potential leftovers from previous runs of this script:
24+ # ## clean up potential leftovers from previous runs of this script:
2725rm -rf sjlogging/
2826
29- # call maven to perform the "string-filtering" which will substitute the version
30- # placeholder in __init__.py by the (maven-derived) version string:
31- mvn process-resources
32-
33- # move the string-filtered source tree to the project root, so poetry will pick
34- # it up automatically from there (without explicit configuration):
35- mv target/classes/sjlogging/ .
36-
37- # let poetry build the wheel (and tar.gz)
27+ # move the source tree to the project root, so poetry will pick it up
28+ # automatically from there (without explicit configuration):
29+ mv src/main/resources/sjlogging .
30+
31+ # ## parse the version from 'pom.xml':
32+ PACKAGE_VERSION=$( xmlstarlet sel --template -m _:project -v _:version pom.xml)
33+
34+ # ## make sure to have a valid Python package version:
35+ case $PACKAGE_VERSION in
36+ * -SNAPSHOT* )
37+ echo " POM version [$PACKAGE_VERSION ] is a snapshot!"
38+ PACKAGE_VERSION=${PACKAGE_VERSION/ -SNAPSHOT/ }
39+ # ## calculate the distance to the last release tag:
40+ LAST_TAG=$( git tag --list ' jython-scijava-logging-*' | sort | tail -n1)
41+ # echo "Last git tag: '$LAST_TAG'"
42+ COMMITS_SINCE=$( git rev-list " ${LAST_TAG} ..HEAD" | wc -l)
43+ # echo "Nr of commits since last tag: $COMMITS_SINCE"
44+ HEAD_ID=$( git rev-parse --short HEAD)
45+ # echo "HEAD commit hash: $HEAD_ID"
46+ PACKAGE_VERSION=" ${PACKAGE_VERSION} .dev${COMMITS_SINCE} +${HEAD_ID} "
47+ ;;
48+ esac
49+
50+ echo " Using package version: [$PACKAGE_VERSION ]"
51+
52+ # ## put the version into the project file and the package source:
53+ sed -i " s/\$ {project.version}/${PACKAGE_VERSION} /" pyproject.toml
54+ sed -i " s/\$ {project.version}/${PACKAGE_VERSION} /" sjlogging/__init__.py
55+
56+ # ## let poetry build wheel and tar.gz:
3857poetry build -vv
3958
40- # remove the string-filtered source tree:
59+ # ## clean up the moved source tree and restore the previous state :
4160rm -rf sjlogging/
61+ git restore pyproject.toml
62+ git restore src/main/resources/sjlogging/
0 commit comments