Skip to content

0.2.5.1

0.2.5.1 #58

Workflow file for this run

name: Upload Python Package
on:
release:
types: [created]
jobs:
deploy-pypi:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: pip install build twine toml
- name: Build the package
run: python -m build
- name: Check version matches
run: |
import toml
import os
import sys
# Read pyproject.toml
with open('pyproject.toml', 'r') as f:
pyproject = toml.load(f)
# Get version from pyproject.toml
project_version = pyproject['project']['version']
# Get release tag (strip 'v' prefix if present)
github_ref = os.environ['GITHUB_REF']
tag_version = github_ref.split('/')[-1]
if tag_version.startswith('v'):
tag_version = tag_version[1:]
print(f"pyproject.toml version: {project_version}")
print(f"Release tag version: {tag_version}")
# Compare versions
if project_version != tag_version:
print("Version mismatch!")
print(f"pyproject.toml version ({project_version}) does not match")
print(f"release tag version ({tag_version})")
sys.exit(1)
print("Versions match!")
shell: python
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
deploy-homebrew:
needs: deploy-pypi
runs-on: ubuntu-latest
steps:
- name: Extract version
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/}" | sed 's/^\///' >> $GITHUB_OUTPUT
fi
- name: Checkout homebrew-tap
uses: actions/checkout@v3
with:
repository: agentstack-ai/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Create Formula directory
run: mkdir -p Formula
- name: Update Formula
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
# Get SHA256 of PyPI package
PACKAGE_NAME="${{ github.event.repository.name }}"
curl -sL https://pypi.org/pypi/$PACKAGE_NAME/$VERSION/json
SHA256=$(curl -sL https://pypi.org/pypi/$PACKAGE_NAME/$VERSION/json | jq -r '.urls[0].digests.sha256')
# Update formula
cat > Formula/$PACKAGE_NAME.rb << EOF
class Agentstack < Formula
include Language::Python::Virtualenv
desc "$(gh repo view --json description -q .description)"
homepage "https://github.com/${{ github.repository }}"
url "https://files.pythonhosted.org/packages/source/${PACKAGE_NAME:0:1}/$PACKAGE_NAME/$PACKAGE_NAME-$VERSION.tar.gz"
sha256 "$SHA256"
depends_on "[email protected]"
def install
virtualenv_install_with_resources
end
test do
system bin/"$PACKAGE_NAME", "--version"
end
end
EOF
- name: Commit and push changes
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add Formula/*.rb
git commit -m "Update formula to version ${{ steps.get_version.outputs.VERSION }}" || true
git push