Skip to content

feat: add pre-publish validation job to release pipeline #21

feat: add pre-publish validation job to release pipeline

feat: add pre-publish validation job to release pipeline #21

Workflow file for this run

name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build tools
run: pip install build
- name: Build sdist and wheel
run: python -m build
- name: Verify distributions
run: |
ls -lh dist/
pip install twine
twine check dist/*
- uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
validate:
name: Validate packages
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
strategy:
fail-fast: true
matrix:
artifact: [wheel, sdist]
steps:
- uses: actions/checkout@v6
with:
sparse-checkout: tests
sparse-checkout-cone-mode: false
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- name: Install system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq \
build-essential cmake pkg-config \
libdbus-1-dev libglib2.0-dev libudev-dev libbluetooth-dev
- name: Install package from ${{ matrix.artifact }}
run: |
if [ "${{ matrix.artifact }}" = "wheel" ]; then
pip install dist/*.whl
else
pip install dist/*.tar.gz
fi
- name: Install test dependencies
run: |
pip install \
"pytest~=8.4" \
"pytest-asyncio>=0.23.0,<0.24" \
"pytest-cov>=6.2,<8" \
"nest-asyncio>=1.5.0" \
"pytest-xdist~=3.0" \
"pytest-benchmark~=5.1" \
"requests>=2.32.0" \
"beautifulsoup4>=4.12.0" \
"lxml>=4.9.0"
- name: Verify package metadata
run: |
python -c "
import bluetooth_sig
v = getattr(bluetooth_sig, '__version__', None)
print(f'Version: {v}')
assert v, 'Missing __version__'
"
- name: Run test suite against installed ${{ matrix.artifact }}
run: |
python -m pytest tests/ \
-n auto \
--override-ini="pythonpath=" \
--ignore=tests/benchmarks \
--ignore=tests/docs \
-m "not benchmark and not built_docs and not playwright" \
--cov=bluetooth_sig \
--cov-report=term-missing \
--cov-fail-under=85 \
-v
publish-pypi:
name: Publish to PyPI
needs: validate
runs-on: ubuntu-latest
timeout-minutes: 10
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: Create GitHub Release
needs: publish-pypi
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--repo "${{ github.repository }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
dist/*