Skip to content

Upload Python Package #22

Upload Python Package

Upload Python Package #22

Workflow file for this run

# This workflow will upload a Python Package to PyPI
# 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:
release-build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build source distribution
run: |
python -m ensurepip --upgrade
python -m pip install setuptools numpy cython
python setup.py sdist
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist
release-build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Build binary distribution
uses: pypa/cibuildwheel@v3.0.0
with:
output-dir: dist
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: dist/*.whl
# pypi-publish:
# runs-on: ubuntu-latest
# needs:
# - release-build-sdist
# - release-build-wheels
# permissions:
# # IMPORTANT: this permission is mandatory for trusted publishing
# id-token: write
#
# # Dedicated environments with protections for publishing are strongly recommended.
# # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
# environment:
# name: pypi
# url: https://pypi.org/p/compiled-knowledge
#
# steps:
# - name: Retrieve release distributions
# uses: actions/download-artifact@v4
# with:
# name: release-dists
# path: dist/
#
# - name: Publish release distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages-dir: dist/
testpypi-publish:
runs-on: ubuntu-latest
needs:
- release-build-sdist
- release-build-wheels
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment:
name: testpypi
url: https://test.pypi.org/p/compiled-knowledge
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/