Skip to content

Commit

Permalink
add workflow for publishing to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
mcflugen committed Jan 29, 2024
1 parent 4c45fff commit 3ef3c22
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: PyPI

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- '!v[0-9]+.[0-9]+.[0-9]+[ab][0-9]+'


jobs:

build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
name: pypi-artifacts
path: dist/*.tar.gz

show-artifacts:
needs: ["build-sdist"]
name: "Show artifacts"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist

- shell: bash
run: |
ls -l ${{ github.workspace }}/dist
publish-to-test-pypi:
needs: ["build-sdist"]
name: "Publish to PyPI"
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/download-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
print_hash: true
verify_metadata: false
12 changes: 12 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ def publish_testpypi(session):
)


@nox.session(name="publish-pypi")
def publish_pypi(session):
"""Publish wheelhouse/* to PyPI."""
session.run("twine", "check", "build/wheelhouse/*")
session.run(
"twine",
"upload",
"--skip-existing",
"build/wheelhouse/*.tar.gz",
)


@nox.session(python=False)
def clean(session):
"""Remove all .venv's, build files and caches in the directory."""
Expand Down

0 comments on commit 3ef3c22

Please sign in to comment.