CI Publish Package #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python Package Dispatch | |
on: | |
workflow_dispatch: # Allows manual triggering of the workflow | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
env: | |
POETRY_HOME: /opt/poetry | |
VENV_PATH: venv | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Cache Poetry and virtual environment | |
id: cache-poetry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/opt/poetry | |
~/.cache/pypoetry | |
.venv | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }} | |
# Install Poetry manually if not cached | |
- name: Install Poetry | |
if: steps.cache-poetry.outputs.cache-hit != 'true' | |
run: | | |
export POETRY_HOME=/opt/poetry | |
python3 -m venv $POETRY_HOME | |
$POETRY_HOME/bin/pip install poetry==1.8.2 | |
$POETRY_HOME/bin/poetry --version | |
# Add Poetry to PATH | |
- name: Add Poetry to PATH | |
run: echo "/opt/poetry/bin" >> $GITHUB_PATH | |
# Install dependencies | |
- name: Install comeit | |
run: poetry install --no-interaction --no-ansi | |
- name: Build comeit | |
run: poetry build | |
- name: Publish Python 🐍 distribution 📦 to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |