diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000000..8c261a4a2d --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,43 @@ +name: nightly + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + build-and-publish-nightly: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install build + - name: Build the sdist + run: python -m build --sdist . + env: + BUILD_PYMC_NIGHTLY: true + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN_PYMC_NIGHTLY }} + test-install-job: + needs: build-and-publish-nightly + runs-on: ubuntu-latest + steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Give PyPI a chance to update the index + run: sleep 240 + - name: Install from PyPI + run: | + pip install pymc-nightly==${GITHUB_REF:11}.dev$(date +"%Y%m%d") diff --git a/setup.py b/setup.py index 563eb94acb..43a4a68eb6 100755 --- a/setup.py +++ b/setup.py @@ -12,19 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import re from codecs import open +from datetime import datetime, timezone from os.path import dirname, join, realpath from setuptools import find_packages, setup -DISTNAME = "pymc" DESCRIPTION = "Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara" AUTHOR = "PyMC Developers" AUTHOR_EMAIL = "pymc.devs@gmail.com" URL = "http://github.com/pymc-devs/pymc" LICENSE = "Apache License, Version 2.0" +NIGHLTY = "BUILD_PYMC_NIGHTLY" in os.environ classifiers = [ "Development Status :: 5 - Production/Stable", @@ -54,21 +56,36 @@ test_reqs = ["pytest", "pytest-cov"] -def get_version(): - VERSIONFILE = join("pymc", "__init__.py") - lines = open(VERSIONFILE).readlines() +def get_distname(nightly_build=False): + distname = "pymc" + if nightly_build: + distname = f"{distname}-nightly" + + return distname + + +def get_version(nightly_build=False): + version_file = join("pymc", "__init__.py") + lines = open(version_file).readlines() version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]" for line in lines: mo = re.search(version_regex, line, re.M) if mo: - return mo.group(1) - raise RuntimeError(f"Unable to find version in {VERSIONFILE}.") + version = mo.group(1) + + if nightly_build: + suffix = datetime.now(timezone.utc).strftime(r".dev%Y%m%d") + version = f"{version}{suffix}" + + return version + + raise RuntimeError(f"Unable to find version in {version_file}.") if __name__ == "__main__": setup( - name=DISTNAME, - version=get_version(), + name=get_distname(NIGHLTY), + version=get_version(NIGHLTY), maintainer=AUTHOR, maintainer_email=AUTHOR_EMAIL, description=DESCRIPTION,