80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
branches:
|
|
- "develop"
|
|
paths:
|
|
- "scraibe/**"
|
|
- "pyproject.toml"
|
|
|
|
workflow_dispatch:
|
|
inputs:
|
|
test:
|
|
description: "Run tests"
|
|
default: true
|
|
type: boolean
|
|
publish_to_pypi:
|
|
description: "Publish to PyPI"
|
|
default: false
|
|
type: boolean
|
|
|
|
jobs:
|
|
Build-and-publish-to-Test-PyPI:
|
|
if: github.event_name != 'workflow_dispatch' || github.event.inputs.test == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: '0'
|
|
- name: Set up Poetry 📦
|
|
uses: JRubics/poetry-publish@v1.16
|
|
with:
|
|
pypi_token: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
plugins: "poetry-dynamic-versioning"
|
|
repository_name: "scraibe"
|
|
repository_url: "https://test.pypi.org/legacy/"
|
|
|
|
Test-PyPi-install:
|
|
name: Test Installation from TestPyPI
|
|
needs: Build-and-publish-to-Test-PyPI
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: [3.9, 3.11, 3.12]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- name: Install package
|
|
run: |
|
|
pip install -U setuptools
|
|
pip install -r requirements.txt
|
|
python3 -m pip install --no-deps --pre --index-url https://test.pypi.org/simple/ scraibe>=0.1.3
|
|
python3 -c "import scraibe; print(scraibe.__version__)"
|
|
|
|
publish-to-pypi:
|
|
name: Publish to PyPI
|
|
needs: Test-PyPi-install
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
always() &&
|
|
(( needs.Build-and-publish-to-Test-PyPI.result != 'failure' &&
|
|
needs.Test-PyPi-install.result != 'failure' ) ||
|
|
((github.event_name == 'workflow_dispatch' &&
|
|
github.event.inputs.publish_to_pypi == 'true')))
|
|
steps:
|
|
- name: Checkout Repository (Develop)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: '0'
|
|
- name: Set up Poetry 📦
|
|
uses: JRubics/poetry-publish@v1.16
|
|
with:
|
|
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
|
|
plugins: "poetry-dynamic-versioning"
|
|
repository_name: "scraibe" |