Skip to content

Commit

Permalink
Set up trusted publishing from GHA (#193)
Browse files Browse the repository at this point in the history
* Set up trusted publishing from GHA

- Add build to dev deps
- Add sdist job to build sdist
- Add publish job to publish tagged releases

* Move UV env to workflow level
  • Loading branch information
amyreese authored Sep 2, 2024
1 parent 651ef06 commit e853bb1
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 40 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/build.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI
on:
push:
branches:
- main
tags:
- v*
pull_request:

permissions:
contents: read

env:
UV_SYSTEM_PYTHON: 1

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [macOS-latest, ubuntu-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: hynek/setup-cached-uv@v2
with:
cache-dependency-path: pyproject.toml
- name: Install
run: make EXTRAS=dev install
- name: Test
run: make test
- name: Lint
run: make lint

sdist:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: hynek/setup-cached-uv@v2
with:
cache-dependency-path: pyproject.toml
- name: Install
run: make install
- name: Build
run: python -m build --sdist
- name: Upload
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist

publish:
needs: sdist
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: sdist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PKG:=aioitertools
EXTRAS:=dev,docs

UV_VERSION:=$(shell uv --version)
ifdef UV_VERSION
UV:=$(shell uv --version)
ifdef UV
VENV:=uv venv
PIP:=uv pip
else
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies = ["typing_extensions>=4.0; python_version < '3.10'"]
dev = [
"attribution==1.8.0",
"black==24.8.0",
"build>=1.2",
"coverage==7.6.1",
"flake8==7.1.1",
"flit==3.9.0",
Expand Down Expand Up @@ -60,4 +61,4 @@ skip_covered = true

[tool.mypy]
# strict = true
ignore_missing_imports = true
ignore_missing_imports = true

0 comments on commit e853bb1

Please sign in to comment.