Build, Publish, and Upload Release Assets #2
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: Build, Publish, and Upload Release Assets | |
on: | |
release: | |
types: [published] | |
permissions: | |
contents: read | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
- name: Build package | |
run: python -m build | |
- name: Publish to PyPI | |
env: | |
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
run: twine upload dist/* --skip-existing -u __token__ -p $PYPI_API_TOKEN | |
- name: Upload Release Assets | |
run: | | |
for file in dist/*; do | |
echo "Uploading ${file}" | |
curl \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: $(file -b --mime-type $file)" \ | |
--data-binary @$file \ | |
${{ github.event.release.upload_url }}?name=$(basename $file) | |
done |