Upload Python Package to test PyPI #15
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 test PyPI | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Validate exts version matching | |
run: | | |
python -m pip install tomli | |
python hooks/version_check.py | |
- name: Install dependencies | |
run: | | |
python -m pip install build cibuildwheel twine | |
- name: Build pure python package | |
run: python -m build | |
- name: Build binary python package | |
run: | | |
cd ./py_ballisticcalc.exts | |
python -m build --sdist --outdir ../dist | |
cibuildwheel --output-dir ../dist | |
cd .. | |
- name: List ./dist | |
run: ls ./dist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-${{ matrix.os }} | |
path: ./dist | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts (Ubuntu) | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-ubuntu-latest | |
path: ./dist-ubuntu | |
- name: Download artifacts (Windows) | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-windows-latest | |
path: ./dist-windows | |
- name: Download artifacts (macOS 13) | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-macos-13 | |
path: ./dist-macos-13 | |
- name: Download artifacts (macOS 14) | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-macos-14 | |
path: ./dist-macos-14 | |
- name: Combine artifacts | |
run: | | |
mkdir -p dist | |
cp ./dist-ubuntu/* dist/ || true | |
cp ./dist-windows/* dist/ || true | |
cp ./dist-macos-13/* dist/ || true | |
cp ./dist-macos-14/* dist/ || true | |
- name: List ./dist | |
run: ls ./dist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: ./dist | |
- name: Publish package distributions to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
repository-url: https://test.pypi.org/legacy/ |