Skip to content

Publish to Test PyPI #3

Publish to Test PyPI

Publish to Test PyPI #3

################################################################################
# #
# GITHUB ACTIONS β€” PUBLISH PYTHON PACKAGES TO TEST PYPI #
# #
################################################################################
#
# Builds and publishes the aam-cli Python package to Test PyPI (test.pypi.org).
# Package is named "aam-cli" on PyPI (since "aam" is already taken).
#
# Triggers:
# - Push to `test` branch (when Python package files change)
# - Manual dispatch (workflow_dispatch)
#
# Required secret:
# TEST_PYPI_API_TOKEN β€” API token from https://test.pypi.org/manage/account/token/
#
################################################################################
name: Publish to Test PyPI
on:
push:
branches:
- test
paths:
- "apps/aam-cli/**"
- ".github/workflows/publish-pypi-test.yml"
workflow_dispatch:
jobs:
# ==========================================================================
# TEST β€” Run lint and tests before publishing
# ==========================================================================
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install npm dependencies
run: npm ci
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: apps/aam-cli/pyproject.toml
- name: Install aam-cli with dev dependencies
run: pip install -e ".[dev]"
working-directory: apps/aam-cli
- name: Lint and test aam-cli
run: npx nx run-many -t lint,test -p aam-cli
# ==========================================================================
# BUILD & PUBLISH β€” Build wheels/sdists and upload to Test PyPI
# ==========================================================================
publish:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# -----
# Step 1: Checkout repository
# -----
- name: Checkout repository
uses: actions/checkout@v4
# -----
# Step 2: Set up Python
# -----
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
# -----
# Step 3: Install build tools
# -----
- name: Install build tools
run: pip install build twine
# -----
# Step 4: Build aam-cli
# -----
- name: Build aam-cli
run: python -m build
working-directory: apps/aam-cli
# -----
# Step 5: Publish aam-cli to Test PyPI
# -----
- name: Publish aam-cli to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: apps/aam-cli/dist/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip-existing: true