Use hynek/build-and-inspect-python-package

This commit is contained in:
Hugo van Kemenade 2023-06-06 19:20:56 +03:00
parent 5f302e0813
commit 02da99f4b0
4 changed files with 58 additions and 30 deletions

View file

@ -1,2 +1,2 @@
[flake8] [flake8]
max_line_length = 88 max-line-length = 88

View file

@ -2,49 +2,71 @@ name: Deploy
on: on:
push: push:
branches: branches: [main]
- main tags: ["*"]
pull_request:
branches: [main]
release: release:
types: types:
- published - published
workflow_dispatch: workflow_dispatch:
jobs: permissions:
deploy: contents: read
if: github.repository_owner == 'pylast'
runs-on: ubuntu-latest
permissions: jobs:
# IMPORTANT: this permission is mandatory for trusted publishing # Always build & lint package.
id-token: write build-package:
name: Build & verify package
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Python - uses: hynek/build-and-inspect-python-package@v1
uses: actions/setup-python@v4
# 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: with:
python-version: "3.x" name: Packages
cache: pip path: dist
cache-dependency-path: pyproject.toml
- name: Install dependencies - name: Upload package to Test PyPI
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
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1 uses: pypa/gh-action-pypi-publish@release/v1
with: with:
repository-url: https://test.pypi.org/legacy/ 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

View file

@ -2,6 +2,9 @@ name: Lint
on: [push, pull_request, workflow_dispatch] on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -8,6 +8,9 @@ jobs:
label: label:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
issues: write
steps: steps:
- uses: mheap/github-action-required-labels@v4 - uses: mheap/github-action-required-labels@v4
with: with: