Skip to content

feat: add explicit TypeError for unsupported << operator on GTag comp… #109

feat: add explicit TypeError for unsupported << operator on GTag comp…

feat: add explicit TypeError for unsupported << operator on GTag comp… #109

Workflow file for this run

name: Build and Release
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check_version.outputs.version }}
is_new_version: ${{ steps.check_version.outputs.is_new }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Install Playwright browsers
run: uv run playwright install --with-deps chromium
- name: Run tests
run: uv run pytest
- name: Check version
id: check_version
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
VERSION=$(grep -m 1 '^version = ' pyproject.toml | cut -d '"' -f 2)
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [ -n "$(git ls-remote --tags origin "refs/tags/v$VERSION")" ]; then
echo "is_new=false" >> $GITHUB_OUTPUT
echo "Version $VERSION already exists (skipping release)"
# Update pyproject.toml to use a +latest local version identifier so it's explicitly different from PyPI
DEV_VERSION="${VERSION}+latest"
sed -i "s/^version = \"$VERSION\"/version = \"$DEV_VERSION\"/" pyproject.toml
echo "Using local version identifier: $DEV_VERSION"
else
echo "is_new=true" >> $GITHUB_OUTPUT
echo "Version $VERSION is new! (triggering release)"
fi
- name: Build package
run: uv build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: htag-dist
path: dist/*
release:
name: GitHub Release
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build.outputs.is_new_version == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: htag-dist
path: dist/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.build.outputs.version }}
name: "Release v${{ needs.build.outputs.version }}"
target_commitish: ${{ github.sha }}
files: dist/*
draft: false
prerelease: false
generate_release_notes: true
rolling-release:
name: Update Latest Build
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: htag-dist
path: dist/
- name: Update Latest Release
uses: softprops/action-gh-release@v2
with:
tag_name: latest
name: "Latest Development Build"
body: "This is the latest build from the main branch. Use at your own risk."
files: dist/*.whl
make_latest: false
prerelease: true
release-pypi:
name: Publish to PyPI
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build.outputs.is_new_version == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/htag
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: htag-dist
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1