Skip to content
Merged
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
59 changes: 45 additions & 14 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
push:
branches:
- main
- pypi_test
- actions

jobs:
publish_package:
name: Publish package

name: Build and Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -22,26 +22,57 @@ jobs:
run: |
pip install setuptools wheel twine

- name: Build core package
- name: Extract version info
id: version
run: |
VERSION=$(python setup.py --version)
PACKAGE_NAME=$(python setup.py --name)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT

- name: Build package
env:
FLASH_ATTENTION_SKIP_CUDA_BUILD: "TRUE"
run: |
python setup.py sdist --dist-dir=dist
python setup.py sdist bdist_wheel --dist-dir=dist

- name: Check if version exists on PyPI
id: check-version
id: check-pypi
run: |
VERSION=$(python setup.py --version)
PACKAGE_NAME=$(python setup.py --name)
echo "Detected version: $VERSION"
echo "Detected package: $PACKAGE_NAME"
EXISTS=$(curl --silent -f https://pypi.org/pypi/${PACKAGE_NAME}/${VERSION}/json > /dev/null && echo "yes" || echo "no")
VERSION="${{ steps.version.outputs.version }}"
PACKAGE="${{ steps.version.outputs.package_name }}"
EXISTS=$(curl --silent -f https://pypi.org/pypi/${PACKAGE}/${VERSION}/json > /dev/null && echo "yes" || echo "no")
echo "exists=$EXISTS" >> "$GITHUB_OUTPUT"

- name: Deploy to PyPI
if: steps.check-version.outputs.exists == 'no'
- name: Upload to PyPI
if: steps.check-pypi.outputs.exists == 'no'
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m twine upload dist/*
twine upload dist/*

- name: Check if GitHub Release exists
id: check-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ steps.version.outputs.version }}"
EXISTS=$(gh release view "$TAG" > /dev/null 2>&1 && echo "yes" || echo "no")
echo "exists=$EXISTS" >> $GITHUB_OUTPUT

- name: Create GitHub Release
if: steps.check-release.outputs.exists == 'no'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ steps.version.outputs.version }} dist/* \
--title "Release v${{ steps.version.outputs.version }}" \
--notes "Automated release from GitHub Actions"

- name: Debug Info (optional)
run: |
echo "Package: ${{ steps.version.outputs.package_name }}"
echo "Version: ${{ steps.version.outputs.version }}"
echo "PyPI Exists: ${{ steps.check-pypi.outputs.exists }}"
echo "GitHub Release Exists: ${{ steps.check-release.outputs.exists }}"