diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e9fb3af9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Publish to PyPI + +on: + push: + tags: + - 'v*' + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Verify tag matches pyproject.toml version + run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" + PROJECT_VERSION=$(grep -m1 '^version = ' pyproject.toml | sed -E 's/version = "(.*)"/\1/') + if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then + echo "Tag v$TAG_VERSION does not match pyproject.toml version $PROJECT_VERSION" + exit 1 + fi + echo "Version check passed: $PROJECT_VERSION" + + - name: Build sdist and wheel + run: uv build + + - name: Upload distribution artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish: + name: Publish to PyPI + needs: build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/orca_core + permissions: + id-token: write + steps: + - name: Download distribution artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1