Skip to content

Commit d209ad2

Browse files
authored
Nightly release (#41)
1 parent 1c42c5b commit d209ad2

File tree

5 files changed

+207
-2
lines changed

5 files changed

+207
-2
lines changed

.github/workflows/pypi-nightly.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: PyPI Nightly Build
2+
3+
on:
4+
schedule:
5+
# Run daily at 6:00 AM UTC
6+
- cron: '0 6 * * *'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
jobs:
10+
publish-test-pypi:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14+
contents: read
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install build dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -e .[dev]
29+
30+
- name: Get current version
31+
id: get_version
32+
run: |
33+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
echo "Current version: $VERSION"
36+
37+
- name: Create development version
38+
run: |
39+
# Create a dev version with timestamp
40+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
41+
DEV_VERSION="${{ steps.get_version.outputs.version }}.dev$TIMESTAMP"
42+
echo "Creating dev version: $DEV_VERSION"
43+
./scripts/bump_version.sh "$DEV_VERSION"
44+
45+
- name: Build package
46+
run: |
47+
hatch build
48+
49+
- name: Publish to Test PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
with:
52+
repository-url: https://test.pypi.org/legacy/
53+
54+
- name: Test installation from Test PyPI
55+
run: |
56+
# Wait a bit for the package to be available
57+
sleep 30
58+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentlightning
59+
python -c "import agentlightning; print('Package installed successfully')"

.github/workflows/pypi-release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: PyPI Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0, v1.2.3, etc.
7+
workflow_dispatch: # Allow manual trigger
8+
9+
jobs:
10+
check-version:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
outputs:
15+
version: ${{ steps.get_version.outputs.version }}
16+
tag_version: ${{ steps.get_tag.outputs.tag_version }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Get version from pyproject.toml
22+
id: get_version
23+
run: |
24+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
echo "Package version: $VERSION"
27+
28+
- name: Get tag version
29+
id: get_tag
30+
run: |
31+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
32+
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
33+
echo "Tag version: $TAG_VERSION"
34+
35+
- name: Verify version matches tag
36+
run: |
37+
if [ "${{ steps.get_version.outputs.version }}" != "${{ steps.get_tag.outputs.tag_version }}" ]; then
38+
echo "Error: Version in pyproject.toml (${{ steps.get_version.outputs.version }}) does not match tag (${{ steps.get_tag.outputs.tag_version }})"
39+
exit 1
40+
fi
41+
echo "Version check passed!"
42+
43+
publish-pypi:
44+
needs: check-version
45+
runs-on: ubuntu-latest
46+
permissions:
47+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
48+
contents: read
49+
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: '3.12'
58+
59+
- name: Install build dependencies
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install -e .[dev]
63+
64+
- name: Build package
65+
run: |
66+
hatch build
67+
68+
- name: Verify package contents
69+
run: |
70+
python -m tarfile -l dist/*.tar.gz
71+
python -m zipfile -l dist/*.whl
72+
73+
- name: Publish to PyPI
74+
uses: pypa/gh-action-pypi-publish@release/v1
75+
76+
- name: Test installation from PyPI
77+
run: |
78+
# Wait a bit for the package to be available
79+
sleep 30
80+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentlightning
81+
python -c "import agentlightning; print('Package installed successfully')"

agentlightning/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.1"
1+
__version__ = "0.1.2"
22

33
from .client import AgentLightningClient, DevTaskLoader
44
from .config import lightning_cli

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "agentlightning"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "Agent Lightning is the absolute trainer to light up AI agents."
55
readme = "README.md"
66
requires-python = ">=3.10"

scripts/bump_version.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# Script to bump version in pyproject.toml
4+
# Usage: ./bump_version.sh <new_version>
5+
6+
set -e
7+
8+
# Check if version argument is provided
9+
if [ $# -eq 0 ]; then
10+
echo "Error: No version specified"
11+
echo "Usage: $0 <new_version>"
12+
echo "Examples: $0 1.2.3, $0 1.2.3a1, $0 1.2.3b2, $0 1.2.3rc1, $0 1.2.3.post1, $0 1.2.3.dev1"
13+
exit 1
14+
fi
15+
16+
NEW_VERSION="$1"
17+
18+
# Validate version format (Python PEP 440 compliant)
19+
if ! echo "$NEW_VERSION" | grep -E '^[0-9]+(\.[0-9]+)*((a|b|rc)[0-9]+)?(\.post[0-9]+)?(\.dev[0-9]+)?$' > /dev/null; then
20+
echo "Error: Invalid version format"
21+
echo "Version should follow PEP 440 (e.g., 1.2.3, 1.2.3a1, 1.2.3b2, 1.2.3rc1, 1.2.3.post1, 1.2.3.dev1)"
22+
exit 1
23+
fi
24+
25+
# Get the directory where the script is located
26+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
27+
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
28+
PYPROJECT_FILE="$PROJECT_ROOT/pyproject.toml"
29+
30+
# Check if pyproject.toml exists
31+
if [ ! -f "$PYPROJECT_FILE" ]; then
32+
echo "Error: pyproject.toml not found at $PYPROJECT_FILE"
33+
exit 1
34+
fi
35+
36+
# Get current version
37+
CURRENT_VERSION=$(grep '^version = ' "$PYPROJECT_FILE" | sed 's/version = "\(.*\)"/\1/')
38+
39+
if [ -z "$CURRENT_VERSION" ]; then
40+
echo "Error: Could not find current version in pyproject.toml"
41+
exit 1
42+
fi
43+
44+
echo "Current version: $CURRENT_VERSION"
45+
echo "New version: $NEW_VERSION"
46+
47+
# Update version in pyproject.toml
48+
sed -i.bak "s/^version = \".*\"/version = \"$NEW_VERSION\"/" "$PYPROJECT_FILE"
49+
50+
# Remove backup file
51+
rm -f "$PYPROJECT_FILE.bak"
52+
53+
echo "Successfully bumped version from $CURRENT_VERSION to $NEW_VERSION"
54+
55+
# Update __init__.py if it exists with version
56+
INIT_FILE="$PROJECT_ROOT/agentlightning/__init__.py"
57+
if [ -f "$INIT_FILE" ]; then
58+
if grep -q "__version__" "$INIT_FILE"; then
59+
sed -i.bak "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" "$INIT_FILE"
60+
rm -f "$INIT_FILE.bak"
61+
echo "Updated version in $INIT_FILE"
62+
fi
63+
fi
64+
65+
echo "Version bump complete!"

0 commit comments

Comments
 (0)