Skip to content

Publish to PyPI

Publish to PyPI #52

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish to PyPI
on:
release:
types: [created]
workflow_dispatch:
inputs:
version:
description: 'Versione'
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set env
if: github.event_name != 'workflow_dispatch'
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set env
if: github.event_name == 'workflow_dispatch'
run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/project/animeworld/
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1