Skip to content

Commit

Permalink
Easier version access
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Jan 8, 2024
1 parent 79c9d9d commit 8baeed9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ jobs:
if [[ ! "$COMMIT_MESSAGE" == *"Update version to"* ]]
then
cd CPAC
VERSION=$(poetry run python -c "from CPAC.info import __version__; print(('.'.join(('.'.join(__version__[::-1].split('-')[1].split('.')[1:])[::-1], __version__.split('-')[1])) if '-' in __version__ else __version__).split('+', 1)[0])")
VERSION=$(poetry run cpac-dev-print-version)
cd ..
echo "v${VERSION}" > version
find ./CPAC/resources/configs -name "*.yml" -exec sed -i -r "s/^(# [Vv]ersion ).*$/# Version ${VERSION}/g" {} \;
git add version
VERSIONS=($(git diff origin/${GITHUB_BRANCH} -- version | tail -n 2))
export PATTERN="(declare|typeset) -a"
if [[ "$(declare -p VERSIONS)" =~ $PATTERN ]]
Expand Down
8 changes: 8 additions & 0 deletions CPAC/utils/print_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Print C-PAC version for CI."""

import importlib.metadata


def print_cpac_version():
"""Print the version of CPAC"""
print(importlib.metadata.version('CPAC'))
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ torchvision = "==0.14.1"
[tool.poetry.scripts]
cpac = "CPAC.__main__:main"
cpac-dev-update-preconfigs = "CPAC.utils.configuration.yaml_template:update_all_preconfigs"
cpac-dev-print-version = "CPAC.utils.print_version:print_cpac_version"

0 comments on commit 8baeed9

Please sign in to comment.