Skip to content

support version number changes through the github action #1

support version number changes through the github action

support version number changes through the github action #1

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- 'v*' # triggers on tags like v4.0.7, v1.2.3, etc.
jobs:
build-and-publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
# Required for PyPI Trusted Publishing (OIDC) — no API token needed
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}" # strips leading 'v', e.g. v4.0.7 → 4.0.7
echo "VERSION=$VERSION" >> $GITHUB_ENV
sed -i "s/^version = .*/version = \"$VERSION\"/" Software/Python/pyproject.toml
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" Software/Python/brickpi3/__init__.py
sed -i "s/version = \"[0-9.]\+\"/version = \"$VERSION\"/" Software/Python/README.md
sed -i "s/brickpi3-[0-9.]\+/brickpi3-$VERSION/g" Software/Python/README.md
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build tools
run: pip install --upgrade build twine
- name: Build distribution
working-directory: Software/Python
run: python -m build
- name: Check distribution
working-directory: Software/Python
run: twine check dist/*
- name: Publish to PyPI (Trusted Publishing)
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: Software/Python/dist/