diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml deleted file mode 100644 index b2f7b5f33..000000000 --- a/.github/workflows/pre-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Python package - -on: - #schedule: - # - cron: '* 8 * * *' - workflow_dispatch: - - -jobs: - build: - runs-on: ubuntu-latest - name: Pre Release - steps: - - uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v4 - with: - cache: 'pip' - python-version: "3.10" - - name: Install tox-gh - run: pip install tox-gh - - name: Setup test environment - run: tox run --notest - - name: Test with PyTest - run: tox run - - name: Test building package - run: tox run -e build \ No newline at end of file diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 285220503..17ab103e2 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,8 +1,9 @@ name: Python package on: + # Run tests every night, to catch potentially breaking changes in dependencies. schedule: - - cron: '* 8 * * *' + - cron: '0 0 * * *' push: branches: - main diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml new file mode 100644 index 000000000..5adb38a59 --- /dev/null +++ b/.github/workflows/snapshot-release.yml @@ -0,0 +1,45 @@ +name: Python package + +on: + # Publish snapshot release every night. + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + inputs: + index: + type: choice + description: Index to publish snapshot release to + options: + - https://test.pypi.org/simple/ + - https://pypi.org/simple/ + default: https://test.pypi.org/simple/ + + + +jobs: + build: + runs-on: ubuntu-latest + name: Pre Release + steps: + - uses: actions/checkout@v3 + - name: Setup python + uses: actions/setup-python@v4 + with: + cache: 'pip' + python-version: "3.10" + - name: Install tox-gh + run: pip install tox-gh + - name: Setup test environment + run: tox run --notest + - name: Test with PyTest + run: tox run + - name: Test building package + run: tox run -e build + - name: Publish package + uses: pypa/gh-action-pypi-publish/v1 + env: + SNAPSHOT_RELEASE: 1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + repository-url: ${{ github.event.inputs.index }} \ No newline at end of file diff --git a/quantus/__init__.py b/quantus/__init__.py index 6c84d1beb..a8b84f765 100644 --- a/quantus/__init__.py +++ b/quantus/__init__.py @@ -4,11 +4,20 @@ # You should have received a copy of the GNU Lesser General Public License along with Quantus. If not, see . # Quantus project URL: . import subprocess +import os -commit_sha = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('utf-8') -version = subprocess.check_output(['git', 'describe', '--tags', '--always', '--dirty=-pre', commit_sha]).strip().decode('utf-8') - -__version__ = version +if "SNAPSHOT_RELEASE" in os.environ: + commit_sha = ( + subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("utf-8") + ) + version = ( + subprocess.check_output(["git", "describe", "--tags", "--always", commit_sha]) + .strip() + .decode("utf-8") + ) + __version__ = version +else: + __version__ = "0.4.1" # Expose quantus.evaluate to the user. from quantus.evaluation import evaluate diff --git a/tox.ini b/tox.ini index 51882be30..462251b7f 100644 --- a/tox.ini +++ b/tox.ini @@ -32,6 +32,8 @@ deps = . build twine +pass_env = + SNAPSHOT_RELEASE commands = python3 -m build . python3 -m twine check ./dist/* --strict