2024-04-15 16:11:42 +00:00
|
|
|
name: Python Package CI/CD
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
tags:
|
2024-04-15 16:58:44 +00:00
|
|
|
- "*"
|
2024-04-15 16:11:42 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
setup:
|
|
|
|
name: Setup and Test
|
|
|
|
container:
|
2024-04-15 16:53:37 +00:00
|
|
|
image: node:20-bookworm
|
2024-04-15 16:11:42 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2024-04-15 16:53:37 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
apt update
|
|
|
|
apt install -y python3 python3-venv
|
|
|
|
|
2024-04-15 16:11:42 +00:00
|
|
|
- name: Set up Python environment
|
|
|
|
run: |
|
2024-04-15 16:58:44 +00:00
|
|
|
python3 -V
|
|
|
|
python3 -m venv venv
|
2024-04-15 16:11:42 +00:00
|
|
|
source venv/bin/activate
|
|
|
|
pip install -U pip
|
|
|
|
pip install .[all]
|
|
|
|
|
|
|
|
publish:
|
|
|
|
name: Publish to PyPI
|
|
|
|
container:
|
2024-04-15 16:53:37 +00:00
|
|
|
image: node:20-bookworm
|
2024-04-15 16:11:42 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2024-04-15 16:53:37 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
apt update
|
|
|
|
apt install -y python3 python3-venv
|
|
|
|
|
2024-04-15 16:11:42 +00:00
|
|
|
- name: Set up Python environment
|
|
|
|
run: |
|
2024-04-15 16:58:44 +00:00
|
|
|
python3 -m venv venv
|
2024-04-15 16:11:42 +00:00
|
|
|
source venv/bin/activate
|
|
|
|
|
|
|
|
- name: Install publishing tools
|
|
|
|
run: |
|
|
|
|
pip install -U hatchling twine build
|
|
|
|
|
|
|
|
- name: Build the package
|
|
|
|
run: |
|
|
|
|
python -m build .
|
|
|
|
|
|
|
|
- name: Publish the package to PyPI
|
|
|
|
run: |
|
|
|
|
python -m twine upload --username __token__ --password ${PYPI_TOKEN} dist/*
|
|
|
|
env:
|
2024-04-15 16:58:44 +00:00
|
|
|
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|