Skip to content

Publish

Publish #1

Workflow file for this run

name: Sync Version & Publish
on:
# push:
# tags:
# - "v*.*.*"
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. 0.6.0)"
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
# Update version in code from tag
- name: Update version from tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
python scripts/set_version.py $TAG_NAME
git config user.name "github-actions"
git config user.email "actions@github.com"
git commit -am "chore: set version from $TAG_NAME" || echo "No changes to commit"
git push origin main
# Build and publish to PyPI/TestPyPI (same as before)
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Verify install from TestPyPI
run: |
python -m pip install --upgrade pip
pip install --index-url https://test.pypi.org/simple/ --no-deps mypackage
# - name: Publish to PyPI
# if: success()
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}