Skip to content

PyPi trusted publishers #1

PyPi trusted publishers

PyPi trusted publishers #1

Workflow file for this run

# This workflow will upload a Python Package to PyPI when a release is published
# For more information see:
# - https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# - https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# - https://docs.pypi.org/trusted-publishers/using-a-publisher/
name: Upload Python Package
on:
push:
tags: ["v*.*.*"]
release:
types: [published]
jobs:
build:
name: Build package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install pypa/build
run: |
python -m pip install --upgrade pip
pip install --upgrade build
- name: Build package
run: |
python -m build
- name: Upload dist files
uses: actions/upload-artifact@v2
with:
name: dist-files
path: dist/
if-no-files-found: error
publish-test:
name: Publish to Test PyPI
if: github.event_name == 'push'
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download dist files
uses: actions/download-artifact@v2
with:
name: dist-files
path: dist/
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
publish:
name: Publish to PyPI
if: github.event_name == 'release'
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download dist files
uses: actions/download-artifact@v2
with:
name: dist-files
path: dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1