Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11", "3.13"]
python-version: ["3.11", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
36 changes: 33 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
name: Publish

# Builds and publishes to PyPI when a GitHub Release is published.
# Uses PyPI Trusted Publishing (OIDC) — no API token stored in the repo.
# Configure the trusted publisher once at:
# Publishes to PyPI when a merge to main changes the version in
# src/cloro/_version.py, then creates the vX.Y.Z tag and GitHub Release.
# A Release published by hand also publishes, as before.
# Uses PyPI Trusted Publishing (OIDC): no API token is stored in the repo.
# The trusted publisher is configured at:
# https://pypi.org/manage/project/cloro/settings/publishing/

on:
push:
branches: [main]
release:
types: [published]
workflow_dispatch:

jobs:
check:
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
new: ${{ steps.v.outputs.new }}
steps:
- uses: actions/checkout@v4
- id: v
run: |
version=$(sed -n 's/^__version__ = "\(.*\)"/\1/p' src/cloro/_version.py)
echo "version=$version" >> "$GITHUB_OUTPUT"
if git ls-remote --exit-code --tags origin "refs/tags/v$version" > /dev/null; then
echo "new=false" >> "$GITHUB_OUTPUT"
else
echo "new=true" >> "$GITHUB_OUTPUT"
fi

build-and-publish:
needs: check
if: always() && (github.event_name != 'push' || needs.check.outputs.new == 'true')
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # required for Trusted Publishing
contents: write # required to create the release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -29,3 +54,8 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
- name: Create the GitHub release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "v${{ needs.check.outputs.version }}" --target "$GITHUB_SHA" --title "v${{ needs.check.outputs.version }}" --generate-notes
Loading