Skip to content

Upload Python Package #17

Upload Python Package

Upload Python Package #17

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build sdist
run: |
pip install build
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
build_wheels_windows:
name: Build wheel on windows-latest/${{matrix.arch}}/${{matrix.python_tag}}
needs: [build_sdist]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: [auto32, auto64, ARM64]
python_tag: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*", "pp38-*", "pp39-*"]
exclude:
# PyPy only supports x86_64 on Windows
- arch: auto32
python_tag: "pp38-*"
- arch: auto32
python_tag: "pp39-*"
# ARM64 only supported only supported on cpython >= 3.9
- arch: ARM64
python_tag: "pp38-*"
- arch: ARM64
python_tag: "pp39-*"
- arch: ARM64
python_tag: "cp38-*"
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: actions/setup-python@v4
- name: Copy wheel
run: cp dist/*.tar.gz multi_bible_search.tar.gz
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: multi_bible_search.tar.gz
output-dir: wheelhouse
- id: randomized
name: Generate randomness for artifact
run: |
$num = Get-Random
Write-Host "num=$num"
$num | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.arch }}-${{ steps.randomized.num }}
path: ./wheelhouse/*.whl
deploy:
needs: [build_wheels_windows, build_sdist]
name: deploy wheels to pypi
runs-on: ubuntu-latest
environment: pypi-release
permissions:
id-token: write
steps:
- uses: actions/upload-artifact/merge@v4
name: Merge Artifacts
with:
name: dist
pattern: dist-*
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}