Skip to content

Commit

Permalink
Add workflow to publish to PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite authored and jeromekelleher committed Sep 30, 2024
1 parent d20fd3c commit 05cb6d4
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CD

on:
push:
branches:
- main
tags:
- '*'
release:
types: [published]

jobs:
packaging:
if: github.repository_owner == 'sgkit-dev'
name: Packaging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine validate-pyproject[all]
- name: Check and install package
run: |
validate-pyproject pyproject.toml
python -m build
python -m twine check --strict dist/*
python -m pip install dist/*.whl
- name: Check vcztools CLI
run: |
vcztools --help
# Make sure we don't have ``vcztools`` in the CWD
cd tests
python -m vcztools --help
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
if: github.repository_owner == 'sgkit-dev' && github.event_name == 'release'
needs:
- packaging
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/vcztools
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1


publish-to-testpypi:
if: github.repository_owner == 'sgkit-dev' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs:
- packaging
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/vcztools

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,27 @@ dependencies = [
"pyparsing"
]
requires-python = ">=3.9"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Operating System :: MacOS :: MacOS X",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering"
]
dynamic = ["version"]

[project.urls]
repository = "https://github.com/sgkit-dev/vcztools"

[project.scripts]
vcztools = "vcztools.cli:vcztools_main"

Expand Down

0 comments on commit 05cb6d4

Please sign in to comment.