Skip to content

Add automated PyPI release workflow #9

@kashifpk

Description

@kashifpk

Summary

Add a GitHub Actions workflow to automatically publish releases to PyPI when a version tag is pushed.

Prerequisites

  • Register forge-anvil package name on PyPI
  • Configure Trusted Publisher on PyPI (recommended) OR generate API token

Setting up Trusted Publishers (Recommended)

  1. Create/login to PyPI account at https://pypi.org
  2. Go to: Account → Publishing → Add a new pending publisher
  3. Configure:
    • PyPI Project Name: forge-anvil
    • Owner: agentic-forge
    • Repository: forge-anvil
    • Workflow name: release.yml
    • Environment: pypi (optional but recommended)

Implementation

Create .github/workflows/release.yml:

name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    name: Build Package
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v4
        with:
          version: "latest"

      - name: Set up Python
        run: uv python install

      - name: Build package
        run: uv build

      - name: Upload build artifacts
        uses: actions/upload-artifact@v4
        with:
          name: dist
          path: dist/

  publish:
    name: Publish to PyPI
    needs: build
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      id-token: write  # Required for trusted publishing
    steps:
      - name: Download build artifacts
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist/

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1

Release Process

Once configured, to release a new version:

# Update version in pyproject.toml
# Commit the change
git tag v0.1.0
git push origin v0.1.0

Acceptance Criteria

  • PyPI account created and package name registered
  • Trusted Publisher configured on PyPI
  • Release workflow triggers on version tags
  • Package successfully publishes to PyPI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions