Skip to content

fix: Change entry point name to iowarp-agent-toolkit #71

fix: Change entry point name to iowarp-agent-toolkit

fix: Change entry point name to iowarp-agent-toolkit #71

Workflow file for this run

name: Publish Python Package
on:
push:
branches:
- main # Publish dev versions to TestPyPI on main commits
tags:
- 'v*.*.*' # Publish releases to PyPI on version tags
workflow_dispatch: # Allow manual triggering
permissions:
contents: write # Required for creating releases
id-token: write # Required for PyPI trusted publishing
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
is_release: ${{ steps.version.outputs.is_release }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Determine version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# Release version from tag
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
echo "Building release version: $VERSION"
else
# Dev version from main commit
BASE_VERSION=$(grep -E '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
TIMESTAMP=$(date +%Y%m%d%H%M%S)
SHORT_SHA=${GITHUB_SHA:0:7}
# Use GitHub run number to ensure unique versions
VERSION="${BASE_VERSION}.dev${TIMESTAMP}+${SHORT_SHA}.${GITHUB_RUN_NUMBER}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
echo "Building dev version: $VERSION"
fi
- name: Update version in pyproject.toml
run: |
# Update version for build
sed -i 's/version = ".*"/version = "${{ steps.version.outputs.version }}"/' pyproject.toml
echo "Updated pyproject.toml version to: ${{ steps.version.outputs.version }}"
grep "version =" pyproject.toml
- name: Build package
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-testpypi:
name: Publish to TestPyPI
if: github.ref == 'refs/heads/main' # Only publish dev versions on main
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/iowarp-agent-toolkit
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
continue-on-error: true # Don't fail the workflow if TestPyPI upload fails
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true
attestations: false # Disable attestations for TestPyPI to avoid issues
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') # Only publish on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/iowarp-agent-toolkit
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
github-release:
name: Create GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write # IMPORTANT: mandatory for creating releases
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes "Release ${{ github.ref_name }} of Agent Toolkit"
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}'
dist/**
--repo '${{ github.repository }}'