Skip to content

Publish libeCalc package to PyPI #14

Publish libeCalc package to PyPI

Publish libeCalc package to PyPI #14

Workflow file for this run

name: Publish libeCalc package to PyPI
on:
workflow_run:
workflows: [trigger-publish]
types:
- completed
# Note! We cannot trigger on published event, since that can only be triggered when done manually.
# Therefore we trigger this workflow independently, after the trigger-publish workflow has run, in
# order for this workflow to be the owner of the PyPI publishing job, and can be verified. This limits
# us to only allow this workflow to be allowed to publish to PyPI trustedly.
workflow_dispatch: # Trigger manually, if needed
# NOTE!: When using Trusted Publishing to PyPI, we cannot do that from within a reusable workflow, therefore
# we make it independent, and trigger it with published event from release-please workflow, instead of calling explicitly.
jobs:
publish:
environment:
name: pypi
url: https://pypi.org/project/libecalc/
#name: testpypi
#url: https://test.pypi.org/p/libecalc # NOTE: If/when we need to test publishing etc to PyPI, we can use Test PyPI
permissions:
id-token: write # Required for Trusted Publishing to PyPI, the pypa action uses this
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# NOTE: Make sure we publish from main branch, not the triggering ref
ref: ${{ github.event.repository.default_branch }}
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
- name: Build the libecalc package (wheel and sdist by default)
run: |
poetry build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# repository-url: https://test.pypi.org/legacy/ # NOTE: Only needed to specify for Test PyPI
packages-dir: dist/