Skip to content

CI Publish Package

CI Publish Package #10

Workflow file for this run

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
environment:
name: testpypi
url: https://test.pypi.org/p/comeit
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/