Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 80 additions & 115 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -1,156 +1,121 @@
name: Build and Publish
# based on official doc
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

on:
push:
tags:
- 'v*'
tags: ["v*"]
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-22.04
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false

steps:
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pypa/build
run: python3 -m pip install build --user
- name: Install build backend
run: python -m pip install --upgrade pip hatchling hatch-vcs

- name: Build a binary wheel and a source tarball (agentlab)
run: python3 -m build . --outdir dist/
- name: Build wheel and sdist
run: python -m pip install hatch && hatch build dist/

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish to PyPI
needs:
- build
runs-on: ubuntu-22.04
environment: pypi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Extract tag name
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Validate tag format
id: validate_tag
run: |
if [[ "${{ env.TAG_NAME }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$ ]]; then
echo "valid=true" >> $GITHUB_ENV
else
echo "valid=false" >> $GITHUB_ENV
fi

- name: Exit if invalid tag
if: env.valid == 'false'
run: |
echo "The tag ${{ env.TAG_NAME }} is not a valid semantic version. Exiting."
exit 1

- name: Download all the distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

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

github-release:
name: Sign packages with Sigstore and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-22.04

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
publish-to-pypi:
name: Publish to PyPI
# Only run for “clean / stable” tags (no dev/rc/alpha/beta)
if: ${{ !(contains(github.ref_name, 'dev') || contains(github.ref_name, 'rc') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta')) }}
needs: [build]
runs-on: ubuntu-22.04
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true

publish-to-testpypi:
name: Publish to TestPyPI (dev / rc / alpha / beta)
needs: [build]
runs-on: ubuntu-22.04
environment: testpypi
permissions:
id-token: write
contents: read
if: ${{ contains(github.ref_name, 'dev') || contains(github.ref_name, 'rc') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }}
steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

github-release:
name: Sign & Create GitHub Release
needs: [publish-to-pypi]
if: needs.publish-to-pypi.result == 'success'
runs-on: ubuntu-22.04
permissions:
contents: write
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Set up Python for Sigstore
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install Sigstore and cryptography dependencies
- name: Install Sigstore dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install cryptography==43.0.3
python -m pip install --upgrade pip
python -m pip install cryptography==43.0.3

- name: Sign the dists with Sigstore
- name: Sign dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.1
with:
inputs: >-
inputs: |
./dist/*.tar.gz
./dist/*.whl

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""

- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'

- name: Set GitHub Release as pre-release
if: contains(github.ref, '.dev') # only set tags vA.B.C.devD as pre-release
run: |
TAG_NAME="${{ github.ref_name }}"
gh release create "$TAG_NAME" \
--repo "${{ github.repository }}" \
--title "AgentLab $TAG_NAME" \
--generate-notes \
--fail-on-no-commits

- name: Upload artifacts to Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release edit
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--prerelease

# publish-to-testpypi:
# name: Publish to TestPyPI
# needs:
# - build
# runs-on: ubuntu-latest
# environment: testpypi
# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing

# steps:
# - name: Download all the distribution packages
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# path: dist/

# - name: Publish distribution packages to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
run: |
gh release upload "${{ github.ref_name }}" dist/** --repo "${{ github.repository }}"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,7 @@ OSWorld/


# working files
experiments/*
experiments/*

# setuptools_scm generated version file
src/agentlab/_version.py
25 changes: 16 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "agentlab"
Expand All @@ -17,7 +17,7 @@ authors = [
{name = "Aman Jaiswal", email = "aman.jaiswal@servicenow.com"},
]
readme = "README.md"
requires-python = ">3.10"
requires-python = ">=3.11,<3.13"
license = {text = "Apache-2.0"}
classifiers = [
"Development Status :: 2 - Pre-Alpha",
Expand Down Expand Up @@ -66,15 +66,19 @@ dev = [
"pytest-xdist",
"pytest-playwright",
]
# tapeagents = [
# "tapeagents[converters]",
# ]

[project.urls]
"Homepage" = "https://github.com/ServiceNow/AgentLab"
Homepage = "https://github.com/ServiceNow/AgentLab"

[tool.setuptools.dynamic]
version = {attr = "agentlab.__version__"}
[tool.hatch.version]
source = "vcs" # use version from git tags
fallback-version = "0.0.0"
[tool.hatch.build.targets.wheel]
packages = ["src/agentlab"]
[tool.hatch.build.hooks.vcs]
version-file = "src/agentlab/_version.py"
[tool.hatch.version.raw-options]
version_scheme = "guess-next-dev"

[tool.black]
line-length = 100
Expand All @@ -94,6 +98,9 @@ exclude = '''
| dist
)/
'''
force-exclude = '''
src/agentlab/_version\.py$
'''

[dependency-groups]
dev = [
Expand Down
6 changes: 5 additions & 1 deletion src/agentlab/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
__version__ = "v0.4.0"
try:
from ._version import __version__
except ImportError:
# Fallback for development without installed package
__version__ = "unknown"
Loading
Loading