build-package.yaml
1 name: Build and upload python package 2 3 on: 4 workflow_dispatch: 5 release: 6 types: [created, published] 7 8 jobs: 9 deploy: 10 runs-on: ubuntu-latest 11 12 steps: 13 - uses: actions/checkout@v4 14 - name: Set up Python 15 uses: actions/setup-python@v4 16 with: 17 python-version: '3.9' 18 cache: 'pip' 19 - name: Install dependencies 20 run: | 21 python -m pip install --upgrade pip 22 pip install -r requirements.txt 23 pip install -e. 24 pip install setuptools wheel twine 25 - name: Set package version 26 run: | 27 export VERSION="${GITHUB_REF#refs/tags/v}" 28 sed -i "s/version=.*/version=\"${VERSION}\",/" setup.py 29 - name: Build and publish 30 env: 31 TWINE_USERNAME: __token__ 32 TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} 33 run: | 34 python setup.py bdist_wheel sdist 35 twine upload dist/*