Skip to content

Commit

Permalink
Support uv, enable trusted publishing (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyreese authored Sep 2, 2024
1 parent be22eea commit 851f7e5
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 67 deletions.
57 changes: 0 additions & 57 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

build:
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 EXTRAS=dev install
- name: Build
run: python -m build
- name: Upload
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist

publish:
needs: build
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
21 changes: 13 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ else
ACTIVATE:=.venv/bin/activate
endif

UV:=$(shell uv --version)
ifdef UV
VENV:=uv venv
PIP:=uv pip
else
VENV:=python -m venv
PIP:=python -m pip
endif

.venv:
python -m venv .venv
source $(ACTIVATE) && make install
echo 'run `source $(ACTIVATE)` to use virtualenv'
$(VENV) .venv

venv: .venv
source $(ACTIVATE) && make install
echo 'run `source $(ACTIVATE)` to use virtualenv'

install:
python -m pip install -U pip
python -m pip install -Ue .[$(EXTRAS)]

release: lint test clean
flit publish
$(PIP) install -Ue .[$(EXTRAS)]

format:
python -m ufmt format $(SRCS)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ ruff = [
dev = [
"attribution==1.8.0",
"black==24.8.0",
"coverage==7.6.1",
"flit==3.9.0",
"build>=1.2",
"coverage>=7",
"flake8==7.1.1",
"mypy==1.11.2",
"pygls==1.3.1",
Expand Down

0 comments on commit 851f7e5

Please sign in to comment.