0ce75f0e1d
Adjusted if conditions of jobs
98 lines
3.1 KiB
YAML
98 lines
3.1 KiB
YAML
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
|
|
|
|
on:
|
|
pull_request_target:
|
|
branches:
|
|
- develop
|
|
types:
|
|
- closed
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
|
|
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') ||
|
|
(github.event_name == 'pull_request_target' &&
|
|
github.event.pull_request.merged &&
|
|
contains(github.event.pull_request.labels.*.name, 'release')) ||
|
|
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
|
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') ||
|
|
(github.event_name == 'pull_request_target' &&
|
|
github.event.pull_request.merged &&
|
|
contains(github.event.pull_request.labels.*.name, 'release')) ||
|
|
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))))
|
|
steps:
|
|
- name: Checkout Repository Tags
|
|
uses: actions/checkout@v4
|
|
if: github.ref == 'refs/heads/main'
|
|
with:
|
|
fetch-depth: '0'
|
|
branch: 'main'
|
|
- name: Checkout Repository (Develop)
|
|
uses: actions/checkout@v4
|
|
if: github.ref == 'refs/heads/develop'
|
|
with:
|
|
fetch-depth: '0'
|
|
branch: 'develop'
|
|
- name: Set up Poetry 📦
|
|
uses: JRubics/poetry-publish@v1.16
|
|
with:
|
|
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
|
|
plugins: "poetry-dynamic-versioning"
|
|
repository_name: "scraibe" |