56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
name: "Publish Python Package"
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
tags:
|
|
- "3.*.*"
|
|
|
|
jobs:
|
|
test:
|
|
uses: "./.github/workflows/pr.yml"
|
|
secrets:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
publish-package:
|
|
name: "Build and Publish Python Package"
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
|
|
# set the environment based on what triggered the workflow
|
|
environment:
|
|
name: ${{ github.ref_type == 'tag' && 'pypi' || 'testpypi' }}
|
|
|
|
permissions:
|
|
id-token: write
|
|
|
|
steps:
|
|
- name: "Install uv"
|
|
uses: astral-sh/setup-uv@v5
|
|
|
|
- name: "Checkout code"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: "Build package artifacts"
|
|
run: uv build
|
|
|
|
# Logic for TestPyPI (on main branch push)
|
|
- name: "Publish to TestPyPI"
|
|
if: ${{ github.ref_type == 'branch' }}
|
|
run: uv publish --index test
|
|
|
|
- name: "Verify TestPyPI package installation"
|
|
if: ${{ github.ref_type == 'branch' }}
|
|
run: uv run --index test --with specklepy --no-project -- python -c "import specklepy"
|
|
|
|
# Logic for PyPI (on v3* tag creation)
|
|
- name: "Publish to PyPI"
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
run: uv publish
|
|
|
|
- name: "Verify PyPI package installation"
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
run: uv run --with specklepy --no-project -- python -c "import specklepy"
|