Skip to content

Publish package

Publish package #30

Workflow file for this run

name: Publish package
on:
push:
tags:
- "v**"
workflow_dispatch:
inputs:
environment:
description: 'Environment to publish to'
type: choice
required: true
default: 'pypi'
options:
- pypi
- testpypi
dry_run:
description: 'Dry run (no actual publish)'
type: boolean
required: true
default: false
jobs:
# Publish a package to private PyPI
publish-package:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout git repository
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install PDM
run: pip install pdm
- name: Install dependencies
run: pdm install -G:all
- name: Build the distribution
run: pdm build
- name: Show version to be published
run: pdm show --version
- name: Publish to PyPI
if: ${{ !inputs.dry_run }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ github.event.inputs.environment == 'testpypi' && 'https://test.pypi.org/legacy/' || '' }}
- name: Dry run output
if: ${{ inputs.dry_run }}
run: |
echo "DRY RUN - Would have published to: ${{ github.event.inputs.environment == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://pypi.org' }}"
echo "Distribution files that would have been published:"
ls dist/