Skip to content

Create and publish Python package #73

Create and publish Python package

Create and publish Python package #73

Workflow file for this run

name: Create and publish Python package
on:
workflow_call:
inputs:
version:
type: string
description: Version number of the application
required: true
workflow_dispatch:
inputs:
version:
type: string
description: Version number of the application
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install build tool
uses: pypa/hatch@install
- name: Build wheel
working-directory: python
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ inputs.version }}
run: hatch build -t wheel
- uses: actions/upload-artifact@v4
with:
name: wheel
path: python/dist/
publish:
name: Upload release to PyPI
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
pypi_url: ${{ github.ref_type == 'tag' && 'https://pypi.org' || 'https://test.pypi.org' }}
repository_url: https://${{ github.ref_type == 'tag' && 'upload' || 'test' }}.pypi.org/legacy/
environment:
name: ${{ github.ref_type == 'tag' && 'pypi' || 'testpypi' }}
url: "${{ env.pypi_url }}/p/greenbids-tailor"
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
name: wheel
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ env.repository_url }}
packages-dir: dist/greenbids-tailor
attestations: false