69 lines
1.9 KiB
YAML
69 lines
1.9 KiB
YAML
name: Publish
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
jobs:
|
|
build:
|
|
name: Build package
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.12
|
|
- name: Install Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
virtualenvs-create: false
|
|
version: 1.8.3
|
|
- name: Build package distribution
|
|
run: poetry build
|
|
- name: Upload package artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: distribution
|
|
path: dist
|
|
test-release:
|
|
name: Publish release to Test PyPI
|
|
if: github.event_name == 'workflow_dispatch'
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
environment:
|
|
name: test
|
|
url: https://test.pypi.org/p/openapi-pydantic
|
|
permissions:
|
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
steps:
|
|
- name: Download package distribution
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: distribution
|
|
path: dist
|
|
- name: Publish package distribution to Test PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
repository-url: https://test.pypi.org/legacy/
|
|
release:
|
|
name: Publish release to PyPI
|
|
if: github.event_name == 'release'
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
environment:
|
|
name: production
|
|
url: https://pypi.org/p/openapi-pydantic
|
|
permissions:
|
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
steps:
|
|
- name: Download package distribution
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: distribution
|
|
path: dist
|
|
- name: Publish package distribution to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|