Test, Publish and Release #15
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, Publish and Release | |
on: | |
push: | |
branches: | |
- testing | |
tags: | |
- 'v*-test' | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
id-token: write | |
pull-requests: read | |
jobs: | |
test: | |
name: Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
python-version: ['3.11', '3.12', '3.13'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv and set Python version. | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run tests - ${{ matrix.python-version }} - ${{ matrix.os }} | |
run: | | |
uv run --all-extras pytest | |
publish: | |
name: Build & Publish | |
needs: test | |
if: | | |
github.ref_type == 'tag' && | |
startsWith(github.ref, 'refs/tags/v') && | |
!endsWith(github.ref, '-test') && | |
success() | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/project/busylight_core | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv and set Python version. | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: 3.8 | |
- name: Build package. | |
run: | | |
uv build | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
github-release: | |
name: Create GitHub Release | |
needs: publish | |
if: | | |
github.ref_type == 'tag' && | |
startsWith(github.ref, 'refs/tags/v') && | |
!endsWith(github.ref, '-test') && | |
success() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: 3.8 | |
- name: Build package | |
run: | | |
uv build | |
- name: Generate release notes | |
id: release_notes | |
run: | | |
# Get the tag name | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
# Get the previous tag | |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${TAG_NAME}^ 2>/dev/null || echo "") | |
# Generate changelog | |
if [[ -n "$PREVIOUS_TAG" ]]; then | |
echo "## Changes since $PREVIOUS_TAG" >> release_notes.md | |
echo "" >> release_notes.md | |
git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..${TAG_NAME} >> release_notes.md | |
else | |
echo "## Initial Release" >> release_notes.md | |
echo "" >> release_notes.md | |
echo "- Initial release of busylight_core" >> release_notes.md | |
fi | |
# Check if there's a CHANGELOG.md file | |
if [[ -f "CHANGELOG.md" ]]; then | |
echo "" >> release_notes.md | |
echo "## Full Changelog" >> release_notes.md | |
echo "" >> release_notes.md | |
echo "See [CHANGELOG.md](CHANGELOG.md) for complete release notes." >> release_notes.md | |
fi | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "dist/*" | |
bodyFile: "release_notes.md" | |
draft: false | |
prerelease: false | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |