Skip to content

Commit

Permalink
ops: add the proper publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
kerberizer committed Nov 14, 2024
1 parent f4d9ca6 commit 547e919
Showing 1 changed file with 54 additions and 17 deletions.
71 changes: 54 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,78 @@
---
name: Upload Python Package
name: Publish Python package to PyPI

on: # yamllint disable-line rule:truthy
release:
types: ['published']
types: [published]

permissions:
contents: read

env:
POETRY_VERSION: '1.8.4'
PYTHON_VERSION: '3.12'

jobs:

deploy:
build:

name: Build the package distribution
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyambit
permissions:
id-token: write

steps:

- name: Checkout the repository
uses: actions/[email protected]
with:
ref: ${{ github.ref_name}}

- name: Setup Python
uses: actions/[email protected]
with:
python-version: '3.12'
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/[email protected]
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Perform package installation
run: poetry install --no-interaction

- name: Run tests
run: poetry run pytest

- name: Build the package distributions
run: poetry build --no-interaction

- uses: actions/[email protected]
with:
name: pyambit-dist
path: dist
if-no-files-found: error
retention-days: 1
overwrite: true

publish:

name: Upload release to PyPI
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/p/pyambit
permissions:
id-token: write

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
steps:

- name: Build package
run: python -m build
- name: Retrieve the package distributions
uses: actions/[email protected]
with:
name: pyambit-dist
path: dist

- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.11.0
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.12.2

0 comments on commit 547e919

Please sign in to comment.