Skip to content

fix: Update Cortex cost reduction estimates and correct model name re… #23

fix: Update Cortex cost reduction estimates and correct model name re…

fix: Update Cortex cost reduction estimates and correct model name re… #23

Workflow file for this run

name: Auto Release on Push
on:
push:
branches: [ main, master ]
paths-ignore:
- '**.md'
- '.github/**'
- 'CHANGELOG.md'
jobs:
auto-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.AI_GITHUB_TOKEN }}
ssh-strict: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Install GitHub CLI
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update
sudo apt-get install gh -y
- name: Run tests
run: |
python -m pytest tests/ -v --cov=cost_katana --cov-report=xml
python -m pytest test_basic_functionality.py -v
- name: Run linting
run: |
python -m flake8 cost_katana/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
python -m flake8 cost_katana/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Get current version
id: current_version
run: |
CURRENT_VERSION=$(python setup.py --version)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
- name: Calculate new version
id: new_version
run: |
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
# Split version into components
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
MAJOR="${VERSION_PARTS[0]}"
MINOR="${VERSION_PARTS[1]}"
PATCH="${VERSION_PARTS[2]}"
# Always bump patch version for auto-releases
NEW_MAJOR=$MAJOR
NEW_MINOR=$MINOR
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$NEW_MAJOR.$NEW_MINOR.$NEW_PATCH"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
- name: Update version in setup.py
run: |
sed -i "s/version=\"[^\"]*\"/version=\"${{ steps.new_version.outputs.new_version }}\"/" setup.py
echo "Updated setup.py version to ${{ steps.new_version.outputs.new_version }}"
- name: Verify PyPI token
run: |
if [ -n "${{ secrets.PYPI_TOKEN }}" ]; then
echo "PYPI_TOKEN is available"
echo "[pypi]" > ~/.pypirc
echo "username = __token__" >> ~/.pypirc
echo "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
else
echo "PYPI_TOKEN is not available"
exit 1
fi
- name: Publish to PyPI
run: |
echo "[pypi]" > ~/.pypirc
echo "username = __token__" >> ~/.pypirc
echo "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
python -m twine upload --repository pypi dist/*
echo "Successfully published cost-katana@${{ steps.new_version.outputs.new_version }} to PyPI"
- name: Create and push tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Configure git to use the token for authentication
git remote set-url origin https://x-access-token:${{ secrets.AI_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
# Verify the remote URL is set correctly
echo "Remote URL: $(git remote get-url origin)"
# Add and commit changes
git add setup.py
git commit -m "Auto-release: Bump version to ${{ steps.new_version.outputs.new_version }}"
# Create tag
git tag -a "v${{ steps.new_version.outputs.new_version }}" -m "Auto-release version ${{ steps.new_version.outputs.new_version }}"
# Push with explicit authentication
if ! git push origin HEAD:${{ github.ref }}; then
echo "Git push failed, trying with GitHub CLI..."
gh auth login --with-token <<< "${{ secrets.AI_GITHUB_TOKEN }}"
git push origin HEAD:${{ github.ref }}
fi
if ! git push origin "v${{ steps.new_version.outputs.new_version }}"; then
echo "Tag push failed, trying with GitHub CLI..."
gh auth login --with-token <<< "${{ secrets.AI_GITHUB_TOKEN }}"
git push origin "v${{ steps.new_version.outputs.new_version }}"
fi
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.AI_GITHUB_TOKEN }}
with:
tag_name: v${{ steps.new_version.outputs.new_version }}
release_name: Auto-release v${{ steps.new_version.outputs.new_version }}
body: |
## Auto-release v${{ steps.new_version.outputs.new_version }}
This is an automatic release triggered by changes to the main branch.
### Installation
```bash
pip install cost-katana==${{ steps.new_version.outputs.new_version }}
```
### Changes
- Automatic version bump and release
- Updated dependencies and improvements
- Enhanced Python package structure
- Better error handling
draft: false
prerelease: false