diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7a51ef7..5466032 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,11 +24,10 @@ jobs: docs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: fetch-depth: 0 - - uses: prefix-dev/setup-pixi@v0.6.0 + - uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1 with: environments: docs - name: Setup project @@ -37,7 +36,7 @@ jobs: - name: Build docs run: pixi run docs - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: 'docs/_build/dirhtml' @@ -59,4 +58,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..ae2c417 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,59 @@ +name: Publish to PyPI + +on: + pull_request: + push: + branches: + - main + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + fetch-tags: true + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.x" + + - name: Install build tools + run: python -m pip install --upgrade pip wheel setuptools build twine + + - name: Build wheels + run: python -m build --sdist --wheel . --outdir dist + + - name: Check wheels + working-directory: dist + run: | + ls -alh + python -m pip install *.whl + python -m twine check * + + - name: Upload release distributions + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: release-dists + path: dist/ + + publish: + runs-on: ubuntu-latest + if: github.event_name == 'release' + needs: [build] + permissions: + id-token: write + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + with: + name: release-dists + path: dist/ + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 837c17a..753c1b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,11 +39,10 @@ jobs: env: PIXI_ENV_NAME: test-py${{ matrix.python-version }} steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: fetch-depth: 0 - - uses: prefix-dev/setup-pixi@v0.6.0 + - uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1 with: environments: ${{ env.PIXI_ENV_NAME }} - name: Setup project @@ -56,3 +55,4 @@ jobs: - name: Build recipe (${{ env.PIXI_ENV_NAME }}) if: matrix.python-version == '3.10' run: pixi run build + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 83793bb..d2a910d 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,6 @@ dmypy.json # Used in debugging explicit.txt + +# hatch-vcs +conda_pypi/_version.py diff --git a/conda_pypi/__init__.py b/conda_pypi/__init__.py index b2d8e7f..0b854ce 100644 --- a/conda_pypi/__init__.py +++ b/conda_pypi/__init__.py @@ -2,4 +2,16 @@ conda-pypi """ -__version__ = "0.1.0" +try: + from ._version import __version__ +except ImportError: + # _version.py is only created after running `pip install` + try: + from setuptools_scm import get_version + + __version__ = get_version(root="..", relative_to=__file__) + except (ImportError, OSError, LookupError): + # ImportError: setuptools_scm isn't installed + # OSError: git isn't installed + # LookupError: setuptools_scm unable to detect version + __version__ = "0.0.0.dev0+placeholder" diff --git a/pyproject.toml b/pyproject.toml index e9ae4c4..832a8fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "conda >=23.7.3", + # "conda >=23.9.0", "pip", "grayskull", "importlib_resources", @@ -106,5 +106,8 @@ test-py311 = ["test", "py311"] [tool.hatch.version] source = "vcs" +[tool.hatch.build.hooks.vcs] +version-file = "conda_pypi/_version.py" + [tool.ruff] line-length = 99