From eb730ab41c36bc9ed1e816c15d47d50c53aba805 Mon Sep 17 00:00:00 2001 From: ElliottKasoar Date: Mon, 8 Apr 2024 16:47:03 +0100 Subject: [PATCH] Test version check --- .github/scripts/check_version.py | 5 +++ .github/workflows/publish-on-pypi.yml | 59 ++++++++++++++++++--------- janus_core/__init__.py | 2 +- pyproject.toml | 2 +- 4 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 .github/scripts/check_version.py diff --git a/.github/scripts/check_version.py b/.github/scripts/check_version.py new file mode 100644 index 00000000..c898bf3a --- /dev/null +++ b/.github/scripts/check_version.py @@ -0,0 +1,5 @@ +"""Print current version of janus_core.""" + +from janus_core import __version__ + +print(__version__) diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index d312c222..18f0e513 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -2,14 +2,14 @@ name: Publish on PyPI on: push: - tags: - # After vMajor.Minor.Patch _anything_ is allowed (without "/") ! - - v[0-9]+.[0-9]+.[0-9]+* +# tags: +# # After vMajor.Minor.Patch _anything_ is allowed (without "/") ! +# - v[0-9]+.[0-9]+.[0-9]+* jobs: publish: runs-on: ubuntu-latest - if: github.repository == 'stfc/janus-core' && startsWith(github.ref, 'refs/tags/v') + #if: github.repository == 'stfc/janus-core' && startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout repository @@ -28,21 +28,42 @@ jobs: poetry env use 3.11 poetry build - - name: Check Version - id: check-version + - name: Check prerelease + id: check-prerelease run: | [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT - - name: Create Release - uses: ncipollo/release-action@v1 - with: - artifacts: "dist/*" - token: ${{ secrets.GITHUB_TOKEN }} - draft: false - prerelease: steps.check-version.outputs.prerelease == 'true' - skipIfReleaseExists: true - - - name: Publish to PyPI - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} - run: poetry publish + - name: Get versions from __init__ and pyproject.toml + run: | + export PYTHONPATH=$(pwd) + echo "VERSION=$(python .github/scripts/check_version.py)" >> $GITHUB_ENV + echo "POETRYVERSION=$(poetry version --short)" >> $GITHUB_ENV + + - name: Check __init__ matches pyproject.toml + if: ${{ env.VERSION != env.POETRYVERSION }} + run: | + echo "Version in __init__.py and pyproject.toml do not match" + exit 1 + + - name: Check versions match tag + if: ${{ ! contains(github.ref, env.VERSION) }} + run: | + echo "Git tag does not match version in __init__.py" + exit 1 + + - name: Continue + run: echo "Success!" + +# - name: Create Release +# uses: ncipollo/release-action@v1 +# with: +# artifacts: "dist/*" +# token: ${{ secrets.GITHUB_TOKEN }} +# draft: false +# prerelease: steps.check-prerelease.outputs.prerelease == 'true' +# skipIfReleaseExists: true +# +# - name: Publish to PyPI +# env: +# POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} +# run: poetry publish diff --git a/janus_core/__init__.py b/janus_core/__init__.py index 9649c186..1d4ee06a 100644 --- a/janus_core/__init__.py +++ b/janus_core/__init__.py @@ -1,3 +1,3 @@ """Tools for machine learnt interatomic potentials.""" -__version__ = "0.2.0b2" +__version__ = "0.2.0b3" diff --git a/pyproject.toml b/pyproject.toml index b444d463..39a20323 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "janus-core" -version = "0.2.0b2" +version = "0.2.0b3" description = "Tools for machine learnt interatomic potentials" authors = [ "Elliott Kasoar",