Skip to content

Update CodeQL workflow to use Node.js 24 and manual build #6

Update CodeQL workflow to use Node.js 24 and manual build

Update CodeQL workflow to use Node.js 24 and manual build #6

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- "v*"
release:
types: [published]
workflow_dispatch:
env:
# Opt into Node.js 24 for all actions to avoid Node.js 20 deprecation warnings.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build_wheels:
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheels
# v2.22.0 ships updated manylinux/musllinux image digests, fixing the
# broken quay.io/pypa/manylinux2014_x86_64:2024.07.02-0 tag used by v2.19.2.
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: "pp* *-musllinux_*"
CIBW_TEST_COMMAND: >-
python -c "import genetic_algorithm_lib as ga; cfg = ga.Config(); print(cfg)"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build sdist
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
publish:
name: Publish
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Inspect distributions
run: |
set -euo pipefail
find dist -type f -print
- name: Install packaging tools
run: |
python -m pip install --upgrade pip build twine
- name: Validate distribution metadata
run: |
set -euo pipefail
mapfile -t ARTIFACTS < <(find dist -type f \( -name "*.whl" -o -name "*.tar.gz" -o -name "*.zip" \) | sort)
if [ ${#ARTIFACTS[@]} -eq 0 ]; then
echo "No distributions found under dist/"
exit 1
fi
python -m twine check "${ARTIFACTS[@]}"
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
set -euo pipefail
mapfile -t ARTIFACTS < <(find dist -type f \( -name "*.whl" -o -name "*.tar.gz" -o -name "*.zip" \) | sort)
python -m twine upload --non-interactive --skip-existing "${ARTIFACTS[@]}"