From c079b8a4fc867ddd2b5f474b095aa06e230dab79 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 7 Sep 2025 16:12:43 -0400 Subject: [PATCH 1/2] Add workflow for publishing to PyPI --- .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6c867d0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Release + +on: + push: + tags: + - "v*" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: read + +jobs: + build: + name: Build dists + runs-on: ubuntu-latest + 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@v6 + with: + version: "0.8.4" + enable-cache: true + + - name: Verify tag matches project version + run: | + VER=$(uv version --short) + TAG=${GITHUB_REF_NAME#v} + test "$VER" = "$TAG" || { echo "Tag $TAG != version $VER"; exit 1; } + + - name: Build sdist and wheel with uv + run: uv build --no-sources + + - name: Upload dist 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/PubChemPy + permissions: + id-token: write + contents: read + steps: + - name: Download dist artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From ecd6faa049e3ee04e99b0abcb420f9ca2d479561 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 7 Sep 2025 16:35:13 -0400 Subject: [PATCH 2/2] Add generation of GitHub release draft --- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c867d0..07fc6a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,3 +65,35 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + release: + name: Create GitHub Release + needs: publish + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Download dist artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist + + - name: Create GitHub Release (draft) + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} + run: | + args=( + "${TAG}" dist/* + --title "PubChemPy ${TAG#v}" + --generate-notes + --draft + ) + if gh release view "${TAG}" >/dev/null 2>&1; then + echo "Release ${TAG} already exists; skipping create." + else + gh release create "${args[@]}" + fi