106 lines
3.0 KiB
YAML
106 lines
3.0 KiB
YAML
name: Main
|
|
|
|
on:
|
|
create: # is used for publishing to PyPI and TestPyPI
|
|
tags: # any tag regardless of its name, no branches
|
|
push: # only publishes pushes to the main branch to TestPyPI
|
|
branches: # any maintenance branch but not tag
|
|
# avoid generic ** as it duplicates builds from temporary branches
|
|
- "master"
|
|
- "stable/**"
|
|
tags-ignore:
|
|
- >-
|
|
**
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build_docs:
|
|
name: Build Docs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.10'
|
|
- name: Install tox
|
|
run: python -m pip install --upgrade tox
|
|
- name: Build docs with tox
|
|
run: tox -e docs
|
|
|
|
tests:
|
|
uses: ./.github/workflows/tests.yml
|
|
|
|
publish:
|
|
if: github.repository_owner == 'pytest-dev'
|
|
name: Publish to PyPI registry
|
|
needs:
|
|
- tests
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PY_COLORS: 1
|
|
steps:
|
|
- name: Set up python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Check out src from Git
|
|
uses: actions/checkout@v3
|
|
with:
|
|
# Get shallow Git history (default) for tag creation events
|
|
# but have a complete clone for any other workflows.
|
|
# Both options fetch tags but since we're going to remove
|
|
# one from HEAD in non-create-tag workflows, we need full
|
|
# history for them.
|
|
fetch-depth: >-
|
|
${{
|
|
(
|
|
github.event_name == 'create' &&
|
|
github.event.ref_type == 'tag'
|
|
) &&
|
|
1 || 0
|
|
}}
|
|
|
|
- name: Drop Git tags from HEAD for non-tag-create events
|
|
if: >-
|
|
github.event_name != 'create' ||
|
|
github.event.ref_type != 'tag'
|
|
run: git tag --points-at HEAD | xargs git tag --delete
|
|
|
|
- name: Build and Check Package
|
|
uses: hynek/build-and-inspect-python-package@v1
|
|
|
|
- name: Download Package
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: Packages
|
|
path: dist
|
|
|
|
- name: Publish to test.pypi.org
|
|
if: >-
|
|
(
|
|
github.event_name == 'push' &&
|
|
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
|
) ||
|
|
(
|
|
github.event_name == 'create' &&
|
|
github.event.ref_type == 'tag'
|
|
)
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
password: ${{ secrets.testpypi_password }}
|
|
repository_url: https://test.pypi.org/legacy/
|
|
|
|
- name: Publish to pypi.org
|
|
if: >- # "create" workflows run separately from "push" & "pull_request"
|
|
github.event_name == 'create' &&
|
|
github.event.ref_type == 'tag'
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
password: ${{ secrets.pypi_password }}
|