From f90000d9cca91300e5acd5dcffecb50a9061da47 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Mon, 10 Apr 2023 06:43:23 -0600 Subject: [PATCH] New build version scheme (#305) * Use separate build tag file * Implement new versioning scheme * Update workflow file Former-commit-id: 80bbbafeb6016441ec0420ccdcb480fd4afa844d --- .gitea/workflows/publish.yml | 10 +++------- app/version.py | 2 +- scripts/build_shiv_package.sh | 2 +- scripts/create_build_tag_file.sh | 8 ++++++++ scripts/update_version_file.sh | 7 ------- 5 files changed, 13 insertions(+), 16 deletions(-) create mode 100755 scripts/create_build_tag_file.sh delete mode 100755 scripts/update_version_file.sh diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 1d16c3a9..21976df7 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -13,15 +13,11 @@ jobs: steps: - name: "Clone project repository" uses: actions/checkout@v3 - - name: "Get build info" # TODO: put this in a library + - name: "Get build info" id: build-info run: | - build_time=$(date +'%Y%m%d%H%M') - product_version=$( cat app/data/version.txt ) - short_sha=$(git rev-parse --short HEAD) - build_tag=$(echo "v${product_version}-${short_sha}-${build_time}") - echo "build-time=${build_time}" >> $GITHUB_OUTPUT - echo "short-sha=${short_sha}" >> $GITHUB_OUTPUT + ./scripts/create_build_tag_file.sh + build_tag=$(cat ./app/data/build_tag.txt) echo "build-tag=${build_tag}" >> $GITHUB_OUTPUT - name: "Install Python" uses: cerc-io/setup-python@v4 diff --git a/app/version.py b/app/version.py index 70280cd4..4194f24a 100644 --- a/app/version.py +++ b/app/version.py @@ -23,7 +23,7 @@ def command(ctx): # See: https://stackoverflow.com/a/20885799/1701505 from . import data - with importlib.resources.open_text(data, "version.txt") as version_file: + with importlib.resources.open_text(data, "build_tag.txt") as version_file: # TODO: code better version that skips comment lines version_string = version_file.read().splitlines()[1] diff --git a/scripts/build_shiv_package.sh b/scripts/build_shiv_package.sh index a51ae9e2..3d0c12ff 100755 --- a/scripts/build_shiv_package.sh +++ b/scripts/build_shiv_package.sh @@ -1,4 +1,4 @@ # Builds the shiv "package" for distribution mkdir -p ./package -version_string=$( ./scripts/update_version_file.sh) +version_string=$( ./app/data/version.txt ) shiv -c laconic-so -o package/laconic-so-${version_string} . diff --git a/scripts/create_build_tag_file.sh b/scripts/create_build_tag_file.sh new file mode 100755 index 00000000..c814a420 --- /dev/null +++ b/scripts/create_build_tag_file.sh @@ -0,0 +1,8 @@ +build_tag_file_name=./app/data/build_tag.txt +echo "# This file should be re-generated running: scripts/create_build_tag_file.sh script" > $build_tag_file_name +product_version_string=$( tail -1 ./app/data/version.txt ) +commit_string=$( git rev-parse --short HEAD ) +timestamp_string=$(date +'%Y%m%d%H%M') +build_tag_string=${product_version_string}-${commit_string}-${timestamp_string} +echo ${build_tag_string} >> $build_tag_file_name +echo ${build_tag_string} diff --git a/scripts/update_version_file.sh b/scripts/update_version_file.sh deleted file mode 100755 index 9880b21b..00000000 --- a/scripts/update_version_file.sh +++ /dev/null @@ -1,7 +0,0 @@ -version_file_name=./app/data/version.txt -echo "# This file should be re-generated running: scripts/update-version-file.sh script" > $version_file_name -tag_string=$( git describe --tags --abbrev=0 ) -commit_string=$( git rev-parse --short HEAD ) -version_string=${tag_string}-${commit_string} -echo ${version_string} >> $version_file_name -echo ${version_string}