From e1838f35489d984e04dcbed95dc1d3f430972613 Mon Sep 17 00:00:00 2001 From: Michael Kofler Date: Fri, 10 Jul 2026 11:09:35 +0200 Subject: [PATCH] added pypi publish workflow --- .github/workflows/publish.yml | 56 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 5 +++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..c8c48004 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,56 @@ +name: Publish to PyPI + +on: + push: + tags: + - "v*" + +jobs: + test: + uses: ./.github/workflows/test.yml + secrets: inherit + + publish: + needs: test + + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + + - name: Verify tag format + run: | + [[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] + + - name: Verify package version + shell: bash + run: | + TAG="${GITHUB_REF_NAME#v}" + + VERSION=$(uv version --short) + + echo "Tag: $TAG" + echo "Version: $VERSION" + + if [ "$TAG" != "$VERSION" ]; then + echo "::error::Git tag ($TAG) does not match package version ($VERSION)" + exit 1 + fi + + - run: uv sync + + - run: uv build + + - run: uv publish \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 91d6944a..9036c247 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_call: jobs: test: @@ -37,11 +38,13 @@ jobs: enable-cache: true - name: Cache huggingface + id: hf-cache uses: actions/cache@v4 with: path: ${{ github.workspace }}/.cache/huggingface key: huggingface-${{ hashFiles('pyproject.toml') }} - restore-keys: huggingface- + restore-keys: | + huggingface- - name: Ensure Hugging Face cache directories exist run: |