From 1e9f1a7b05416d9e651d378ae152f31bf7e2aaba Mon Sep 17 00:00:00 2001 From: Don Cross Date: Sun, 5 Jun 2022 14:07:32 -0400 Subject: [PATCH] Automatically patch version number. Added a new file generate/version.txt that contains the current Astronomy Engine version number. Now when I run the build/test process, the version number is patched in all the places it needs to be changed to keep all the packages and documentation up to date. This means when I want to change the Astronomy Engine version number, I just need to edit version.txt, then execute the generate/run script. --- generate/makedoc | 13 +++++++++++-- generate/version.txt | 1 + source/python/setup.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 generate/version.txt diff --git a/generate/makedoc b/generate/makedoc index b4880bbc..dd8ec80e 100755 --- a/generate/makedoc +++ b/generate/makedoc @@ -5,6 +5,15 @@ Fail() exit 1 } +VERSION=$(cat version.txt) || Fail "Could not set VERSION environment variable." +[[ -z "${VERSION}" ]] && Fail "VERSION is blank." +echo "Patching version numbers to: ${VERSION}" +sed -i 's/2b-v[^\-]*-blue/2b-v'${VERSION}'-blue/' ../README.md || Fail "Cannot patch version in README.md" +sed -i 's/"version": "[^"]*"/"version": "'${VERSION}'"/' ../source/js/package.json || Fail "Cannot patch version in package.json" +sed -i 's+[^<]*+'${VERSION}'+' ../source/csharp/astronomy.csproj || Fail "Cannot patch version in astronomy.csproj" +sed -i 's/version="[^"]*"/version="'${VERSION}'"/' ../source/python/setup.py || Fail "Cannot patch version in setup.py" +sed -i 's/version = "[^"]*"/version = "'${VERSION}'"/' ../source/kotlin/build.gradle.kts || Fail "Cannot patch version in build.gradle.kts" + echo "Trimming trailing whitespace in source code." for file in template/astronomy.{c,cs,ts,py} ../source/c/astronomy.h; do node trimspace.js ${file} || Fail "Cannot trim whitespace from template file: ${file}" @@ -115,8 +124,8 @@ python3 pydown/pydown.py pydown/py_prefix.md ../source/python/astronomy/astronom ./check_internal_links.py ../source/python/README.md || exit 1 echo "Making redundant copies of source in demo folders." -cp -v ../source/js/astronomy.browser.js ../demo/browser/ || exit $? -cp -v ../source/js/astronomy.js ../demo/nodejs/ || exit $? +cp -v ../source/js/astronomy.browser.js ../demo/browser/ || exit $? +cp -v ../source/js/astronomy.js ../demo/nodejs/ || exit $? cp -v ../source/python/astronomy/astronomy.py ../demo/python/ || exit $? exit 0 diff --git a/generate/version.txt b/generate/version.txt new file mode 100644 index 00000000..eca07e4c --- /dev/null +++ b/generate/version.txt @@ -0,0 +1 @@ +2.1.2 diff --git a/source/python/setup.py b/source/python/setup.py index baa09abb..707f85ae 100644 --- a/source/python/setup.py +++ b/source/python/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='astronomy-engine', - version='2.1.2', + version="2.1.2", description='Astronomy calculation for Sun, Moon, and planets.', long_description=open('README.md').read(), long_description_content_type='text/markdown',