Skip to content

Commit

Permalink
Use hynek/build-and-inspect-python-package
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jun 11, 2023
1 parent c84e43c commit 03c1fb7
Showing 1 changed file with 50 additions and 29 deletions.
79 changes: 50 additions & 29 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,71 @@ name: Deploy

on:
push:
branches:
- main
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
release:
types:
- published
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
if: github.repository_owner == 'hugovk'
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build twine wheel
- name: Build package
run: |
python -m build
twine check --strict dist/*
- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1
- uses: hynek/build-and-inspect-python-package@v1

# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

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

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
user: __token__
password: ${{ secrets.pypi_password }}
name: Packages
path: dist

- name: Publish package to TestPyPI
- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository-url: https://test.pypi.org/legacy/

# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
if: github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

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

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit 03c1fb7

Please sign in to comment.