Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload Python Package to both Github releases and PyPI when a Release is Published | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-package: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- 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 setuptools wheel | |
- name: Build package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ./dist | |
upload-release: | |
needs: ['build-package'] | |
environment: 'publish' | |
name: Upload release to Github | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
- name: Upload to Github | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
shell: bash | |
run: | | |
gh release upload ${{github.event.release.tag_name}} artifact/* | |
pypi-publish: | |
needs: ['build-package'] | |
environment: 'publish' | |
name: Upload release to PyPI | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages_dir: artifact/ |