From 6f2d3d3fb01e217fb2d20059c51e7ba0f55d4da1 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 7 Jun 2022 15:15:40 -0400 Subject: [PATCH 1/6] :package: Publish to TestPyPI and PyPI using GitHub Actions Automating the binary wheel and source tarball publishing to TestPyPI and PyPI. Based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows but using `poetry` to do the build. --- .github/workflows/publish-to-pypi.yml | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..c546f11 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,63 @@ +# Publish archives to PyPI and TestPyPI using GitHub Actions +# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ + +name: Publish to PyPI + +# Only run for pushes to the main branch and releases. +on: + push: + branches: + - main + release: + types: + - published + # Runs for pull requests should be disabled other than for testing purposes + #pull_request: + # branches: + # - main + +permissions: + contents: read + +jobs: + publish-pypi: + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + runs-on: ubuntu-22.04 + if: github.repository == 'weiji14/zen3geo' + + steps: + - name: Checkout + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + # fetch all history so that poetry-dynamic-versioning works + fetch-depth: 0 + + - name: Set up Python 3.9 + uses: actions/setup-python@98f2ad02fd48d057ee3b4d4f66525b231c3e52b6 + with: + python-version: '3.9' + + - name: Install Poetry and dynamic-versioning plugin + run: | + pip install poetry==1.2.0b1 + poetry plugin add poetry-dynamic-versioning-plugin + poetry show + + - name: Build a binary wheel and a source tarball + run: | + poetry build -vvv + echo "" + echo "Generated files:" + ls -lh dist/ + + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@0fc90bca7acbb84292e0cff399f8579284fcfc7d + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@0fc90bca7acbb84292e0cff399f8579284fcfc7d + with: + password: ${{ secrets.PYPI_API_TOKEN }} From c59a79a365befe4e4333e30255563f1179f48350 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 7 Jun 2022 15:16:45 -0400 Subject: [PATCH 2/6] Temporarily trigger publish-to-pypi action --- .github/workflows/publish-to-pypi.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index c546f11..ab5e4c6 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -12,9 +12,9 @@ on: types: - published # Runs for pull requests should be disabled other than for testing purposes - #pull_request: - # branches: - # - main + pull_request: + branches: + - main permissions: contents: read From db7513a5e699d5bf6873bfbce88e539000c267e1 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 7 Jun 2022 15:59:32 -0400 Subject: [PATCH 3/6] :green_heart: Fix version string to be PEP440 compliant for TestPyPI Change from semver to PEP440 and remove the git hash part of the version string when uploading to TestPyPI. Based on https://github.com/mtkennerly/poetry-dynamic-versioning/issues/78#issuecomment-1131775192. Prevents errors like `'0.0.0.post15+f899e49' is an invalid value for Version. Error: Can't use PEP 440 local versions. See https://packaging.python.org/specifications/core-metadata for more information`. --- .github/workflows/publish-to-pypi.yml | 8 ++++++++ pyproject.toml | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index ab5e4c6..f63eb78 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -43,6 +43,14 @@ jobs: poetry plugin add poetry-dynamic-versioning-plugin poetry show + - name: Fix up version string for TestPyPI + if: ${{ !startsWith(github.ref, 'refs/tags') }} + run: | + # Change poetry-dynamic-versioning to use metadata=false so that the + # local part of the version isn't included, making the version string + # compatible with PyPI. + sed --in-place "s/metadata = true/metadata = false/g" pyproject.toml + - name: Build a binary wheel and a source tarball run: | poetry build -vvv diff --git a/pyproject.toml b/pyproject.toml index f766a0e..a42ef99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,8 +38,10 @@ docs = [ ] [tool.poetry-dynamic-versioning] +bump = true enable = true -style = "semver" +metadata = true +style = "pep440" [build-system] requires = ["poetry>=1.2.0b1", "poetry-dynamic-versioning"] From 598b2dccbddb2a700d6326904b4d44871b147749 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 7 Jun 2022 15:16:45 -0400 Subject: [PATCH 4/6] Revert "Temporarily trigger publish-to-pypi action" This reverts commit c59a79a365befe4e4333e30255563f1179f48350. --- .github/workflows/publish-to-pypi.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index f63eb78..2cab66f 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -12,9 +12,9 @@ on: types: - published # Runs for pull requests should be disabled other than for testing purposes - pull_request: - branches: - - main + #pull_request: + # branches: + # - main permissions: contents: read From e8eab25680aab99e688b932e86741865245eeb3e Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:44:20 -0400 Subject: [PATCH 5/6] :speech_balloon: Include TestPyPI installation instructions So that people can get the latest development package from https://test.pypi.org/project/zen3geo. Also centering the title on the webpage. --- README.md | 6 +++++- docs/index.md | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 02a44f2..6ab382e 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ Look out, sense within, and now you must know ## Installation -For now, install from source using +To install the development version from GitHub, do: pip install git+https://github.com/weiji14/zen3geo.git + +Or from [TestPyPI](https://test.pypi.org/project/zen3geo): + + pip install --pre --extra-index-url https://test.pypi.org/simple/ zen3geo diff --git a/docs/index.md b/docs/index.md index 555f8c5..619eadc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,11 @@ -# ☯ *zen3geo* - The 🌏 data science library you've been waiting for +#
☯ *zen3geo* - The 🌏 data science library you've been waiting for
## Installation -For now, install from source using +To install the development version from GitHub, do: pip install git+https://github.com/weiji14/zen3geo.git + +Or from [TestPyPI](https://test.pypi.org/project/zen3geo): + + pip install --pre --extra-index-url https://test.pypi.org/simple/ zen3geo From 536c31cf692344a74b6b7b003db06886d0108057 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:48:06 -0400 Subject: [PATCH 6/6] :speech_balloon: Update dev status from 1 planning to 3 alpha Jumping two steps ahead, why drive when you can fly? --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a42ef99..fb45b68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Wei Ji <23487320+weiji14@users.noreply.github.com>"] license = "LGPL-3.0-or-later" readme = "README.md" classifiers = [ - "Development Status :: 1 - Planning", + "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", "Topic :: Scientific/Engineering",