Skip to content

Publish: PyPi

Publish: PyPi #75

Workflow file for this run

name: "Publish: PyPi"
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish_target:
description: 'Choose publish target: test or real'
required: true
default: 'test'
type: choice
options:
- test
- real
permissions:
contents: read
env:
PYPI_REPOSITORY_URL: ${{ github.event.inputs.publish_target == 'test' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
PYPI_API_TOKEN: ${{ github.event.inputs.publish_target == 'test' && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN_2022 }}
jobs:
deploy_linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
env:
working-directory: ./src/python/
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel setuptools twine
make python
ls src/python
echo "-------"
ls src/python/code/gnoll/
- name: Build package
working-directory: ./src/python/
run: |
python setup.py bdist_wheel --plat-name=manylinux_2_17_x86_64
- name: Publish package
working-directory: ./src/python/
run: |
python -m twine upload --non-interactive -u __token__ -p $PYPI_API_TOKEN --repository-url $PYPI_REPOSITORY_URL dist/* --verbose
deploy_wsl:
runs-on: windows-2022
env:
PYPI_REPOSITORY_URL: ${{ github.event.inputs.publish_target == 'test' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
PYPI_API_TOKEN: ${{ github.event.inputs.publish_target == 'test' && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN_2022 }}
steps:
- uses: Vampire/setup-wsl@v1
with:
distribution: Ubuntu-22.04
update: 'true'
additional-packages:
python3-dev
bison
flex
python3-pip
build-essential
libssl-dev
libffi-dev
python3.10-venv
- uses: actions/checkout@v3
with:
submodules: true
- name: test
shell: wsl-bash {0}
run: |
export PATH="/root/.local/bin:$PATH"
python3 -m pip install --upgrade pip
python3 -m pip install wheel twine setuptools
make python
ls src/python
echo "-------"
ls src/python/code/gnoll/
- name: Build and Publish package
shell: wsl-bash {0}
working-directory: ./src/python/
run: |
python3 setup.py bdist_wheel --plat-name=manylinux1_x86_64
PYPI_API_TOKEN="${PYPI_API_TOKEN}" PYPI_REPOSITORY_URL="${PYPI_REPOSITORY_URL}" \
python3 -m twine upload dist/* --non-interactive -u __token__ -p $PYPI_API_TOKEN --repository-url $PYPI_REPOSITORY_URL
deploy_mac:
runs-on: macos-12
env:
working-directory: ./src/python/
steps:
- uses: actions/checkout@v3
with:
submodules: true
- 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 wheel twine setuptools
make python
ls src/python
echo "-------"
ls src/python/code/gnoll/
- name: Build and Publish package
working-directory: ./src/python/
run: |
touch ~/.pypirc
python setup.py bdist_wheel
twine upload --non-interactive -u __token__ -p $PYPI_API_TOKEN --repository-url $PYPI_REPOSITORY_URL dist/*