starfish_data_ai / .github /workflows /publish_pypi.yaml
John-Jiang's picture
init commit
5301c48
name: Publish to PyPI
on:
push:
tags:
- 'v*'
# branches:
# - 'main'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Verify tag is on main branch
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
COMMIT=$(git rev-parse $TAG_NAME)
if ! git branch --contains $COMMIT | grep -qw main; then
echo "::error::Tag $TAG_NAME must be created from main branch"
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*