Skip to content

Build and Publish Manualy #2

Build and Publish Manualy

Build and Publish Manualy #2

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build and Publish Manualy
on:
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'testpypi'
type: choice
options:
- testpypi
- pypi
permissions:
contents: read
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Build package
run: poetry build
- name: Configure TestPyPI
if: github.event.inputs.environment == 'testpypi' || github.event_name == 'release'
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Publish to TestPyPI
if: github.event.inputs.environment == 'testpypi' || github.event_name == 'release'
run: poetry publish -r testpypi
- name: Configure PyPI
if: github.event.inputs.environment == 'pypi' || github.event_name == 'release'
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- name: Publish to PyPI
if: github.event.inputs.environment == 'pypi' || github.event_name == 'release'
run: poetry publish