Skip to content
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

📦 Publish to TestPyPI and PyPI using GitHub Actions #14

Merged
merged 6 commits into from
Jun 7, 2022
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
71 changes: 71 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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: 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
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 }}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# ☯ *zen3geo* - The 🌏 data science library you've been waiting for
# <center> ☯ *zen3geo* - The 🌏 data science library you've been waiting for <center>

## 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
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]
Expand Down