Skip to content

Fix potential wrong versioning with uv build #1

Fix potential wrong versioning with uv build

Fix potential wrong versioning with uv build #1

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- 'v*'
paths:
- '.github/**'
- 'src/lazyslide/**'
- 'tests/**'
- 'pyproject.toml'
pull_request:
paths:
- '.github/**'
- 'src/lazyslide/**'
- 'tests/**'
- 'pyproject.toml'
jobs:
Test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.11', '3.12', '3.13']
runs-on: ${{ matrix.os }}
steps:
# The following step is to ensure secrets can be accessed by forked PRs
# Ref: https://michaelheap.com/access-secrets-from-forks/
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # This is dangerous without human review
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install project
run: uv sync --dev
- name: Login to Hugging Face
run: |
uv run hf auth login --token ${{ secrets.HF_TOKEN }}
- name: Tests
run: |
uv run pytest tests -n auto -m "not large_runner" --cov=src/lazyslide --cov-report=xml --cov-report=html
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Upload_to_pypi:
runs-on: ubuntu-latest
needs: Test
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
python-version: '3.12'
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Publish to test pypi
run: |
uv build
uv publish --publish-url https://test.pypi.org/legacy/ || exit 0
- name: Login to Hugging Face
run: |
uv run hf auth login --token ${{ secrets.HF_TOKEN }}
- name: Tag huggingface dataset
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
run: |
VERSION=${{ github.ref_name }}
echo "Detected version: $VERSION"
uv run scripts/tag_datasets.py create RendeiroLab/LazySlide-data "$VERSION"
- name: Tag LazySlide-tutorials
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.TUTORIAL_RELEASE_TOKEN }}
run: |
TAG=${{ github.ref_name }}
echo "Tagging tutorials repo with $TAG"
gh release create "$TAG" --repo RendeiroLab/LazySlide-tutorials --notes "New release: $TAG"
- name: Publish to pypi
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
run: |
uv build
uv publish