Skip to content

Commit

Permalink
Use hynek/build-and-inspect-python-package for releasing (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Nov 12, 2023
2 parents 1622d0b + e517909 commit dc7e75b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

76 changes: 51 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,74 @@ 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

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

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: pip
- uses: hynek/build-and-inspect-python-package@v1

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build twine wheel
# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: |
github.repository_owner == 'hugovk'
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

- name: Build package
run: |
python -m build
twine check --strict dist/*
permissions:
id-token: write

- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Publish package to TestPyPI
- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
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.repository_owner == 'hugovk'
&& github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

permissions:
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
3 changes: 3 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Sync labels

permissions:
pull-requests: write

on:
push:
branches:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Lint

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/require-pr-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ jobs:
label:
runs-on: ubuntu-latest

permissions:
issues: write
pull-requests: write

steps:
- uses: mheap/github-action-required-labels@v5
with:
Expand Down

0 comments on commit dc7e75b

Please sign in to comment.