Skip to content

Release refs/heads/main #93

Release refs/heads/main

Release refs/heads/main #93

Workflow file for this run

name: Release CI
on:
# to publish from main branch.
push:
branches: [main]
tags: ['**']
# to verify distributions before merging a PR
pull_request:
branches: [main]
# to manually trigger dry-runs on non-default branches
workflow_dispatch:
env:
ARTIFACT_NAME_PREFIX: 'pyRF24_wheels'
run-name: >-
Release
${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || (github.ref_name != 'main' && '(dry-run)' || github.ref) }}
permissions: {}
jobs:
# sdist for non-supported platforms will serve as a stub lib install
sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout Current Repo
uses: actions/checkout@v6
with:
submodules: true
# non-shallow checkout needed for setuptools_scm
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: build
run: pipx run build -s
- name: Save distributable wheels as artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ env.ARTIFACT_NAME_PREFIX }}_sdist
path: dist
linux:
runs-on: ${{ (matrix.arch == 'aarch64' || matrix.arch == 'armv7l') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
# the intention here is that each wheel is built in a separate job
arch: [x86_64, aarch64, armv7l]
python: [cp39, cp310, cp311, cp312, cp313, cp314, cp314t]
tag: [manylinux, musllinux]
include:
- arch: aarch64
python: pp310
tag: manylinux
- arch: aarch64
python: pp311
tag: manylinux
- arch: x86_64
python: pp310
tag: manylinux
- arch: x86_64
python: pp311
tag: manylinux
steps:
- name: Checkout Current Repo
uses: actions/checkout@v6
with:
submodules: true
# non-shallow checkout needed for setuptools_scm
fetch-depth: 0
persist-credentials: false
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.0
with:
output-dir: dist
# see options at https://cibuildwheel.pypa.io/en/stable/options/
env:
# for transparent logs
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: '${{ matrix.python }}-${{ matrix.tag }}_*'
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
- name: Save distributable wheels as artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ env.ARTIFACT_NAME_PREFIX }}_${{ matrix.arch }}_${{ matrix.python }}_${{ matrix.tag }}
path: dist
deploy:
name: >-
Deploy to
${{ startsWith(github.ref, 'refs/tags/') && 'pypi' || 'test-pypi' }}
${{ github.ref_name != 'main' && '(dry run)' || '' }}
needs: [sdist, linux]
permissions:
# needed permission for PyPI "trusted publishing"
id-token: write
runs-on: ubuntu-latest
env:
# to avoid typos, set this here for easy repetition
DEFAULT_BRANCH: 'refs/heads/main'
steps:
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
pattern: ${{ env.ARTIFACT_NAME_PREFIX }}_*
path: dist
merge-multiple: true
# if doing a dry-run (not a tag and not on main branch)
- name: Set up Python
if: github.ref != env.DEFAULT_BRANCH
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Validate distributions
if: github.ref != env.DEFAULT_BRANCH
run: pipx run twine check dist/*
- name: Publish package
# only deploy from the main branch or when a tag is pushed
if: github.ref == env.DEFAULT_BRANCH || startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
# Only upload distributions to PyPI when triggered by a pushed tag.
# Otherwise, upload to test-PyPI for nightly builds on main branch.
repository-url: https://${{ startsWith(github.ref, 'refs/tags/') && 'upload' || 'test' }}.pypi.org/legacy/