Skip to content

Build, Publish, and Upload Release Assets #2

Build, Publish, and Upload Release Assets

Build, Publish, and Upload Release Assets #2

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