Skip to content

Automate pypi release #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pymc_experimental/_version.py export-subst
86 changes: 86 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: PyPI
on:
pull_request:
branches: [main]
push:
branches: [main]
release:
types: [published]

jobs:
build:
name: build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Build the sdist and the wheel
run: |
pip install build
python3 -m build
- name: Check the sdist installs and imports
run: |
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/pymc-experimental*.tar.gz
echo "Checking import and version number (on release)"
venv-sdist/bin/python -c "import pymc_experimental as pmx; assert pmx.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else pmx.__version__; print(pmx.__version__)"
cd ..
- name: Check the bdist installs and imports
run: |
mkdir -p test-bdist
cd test-bdist
python -m venv venv-bdist
venv-bdist/bin/python -m pip install ../dist/pymc_experimental*.whl
echo "Checking import and version number (on release)"
venv-bdist/bin/python -c "import pymc_experimental as pmx; assert pmx.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else pmx.__version__; print(pmx.__version__)"
cd ..
- uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*
test:
name: upload to test PyPI
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Test pip install from test.pypi
run: |
python -m venv venv-test-pypi
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pymc-experimental
echo "Checking import and version number"
venv-test-pypi/bin/python -c "import pymc_experimental; assert pymc_experimental.__version__ == '${{ github.ref_name }}'"

publish:
name: upload release to PyPI
needs: [build, test]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
48 changes: 0 additions & 48 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ repos:
rev: v2.14.5
hooks:
- id: pylint
exclude: versioneer.py
args: [--rcfile=.pylintrc]
files: ^pymc_experimental/
- repo: https://github.com/MarcoGorelli/madforhooks
rev: 0.3.0
hooks:
- id: no-print-statements
exclude: _version.py
files: ^pymc_experimental/
- repo: local
hooks:
- id: no-relative-imports
exclude: versioneer.py
name: No relative imports
entry: from \.[\.\w]* import
types: [python]
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include requirements*.txt
include *.md *.rst
include LICENSE
include versioneer.py
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import os
import sys

from pymc_experimental import __version__
import pymc_experimental # isort:skip

sys.path.insert(0, os.path.abspath("../"))

Expand All @@ -40,9 +40,9 @@
author = "pymc-devs"

# The short X.Y version
version = __version__
version = pymc_experimental.__version__
# The full version, including alpha/beta/rc tags
release = __version__
release = version


# -- General configuration ---------------------------------------------------
Expand Down
9 changes: 3 additions & 6 deletions pymc_experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


__version__ = "0.0.2"

import logging

_log = logging.getLogger("pmx")
Expand All @@ -25,7 +21,8 @@
handler = logging.StreamHandler()
_log.addHandler(handler)


from pymc_experimental import distributions, gp, utils
from pymc_experimental import _version, distributions, gp, utils
from pymc_experimental.inference.fit import fit
from pymc_experimental.marginal_model import MarginalModel

__version__ = _version.get_versions()["version"]
Loading