Skip to content

Commit

Permalink
Update makefile/gha workflow for uv and pypi trusted publisher (#118)
Browse files Browse the repository at this point in the history
* Update makefile/gha workflow for uv and pypi trusted publisher

* Add dev dep on build
  • Loading branch information
amyreese authored Oct 26, 2024
1 parent 9dfcae8 commit f2450e0
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 37 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/build.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
cache-suffix: ${{ matrix.python-version }}
- 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.13'
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
- name: Install
run: make EXTRAS=dev install
- name: Build
run: python -m build
- name: Upload
uses: actions/upload-artifact@v4
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@v4
with:
name: sdist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 20 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
EXTRAS:=dev,docs
SRCS:=stdlibs
EXTRAS:=dev,docs

ifeq ($(OS),Windows_NT)
ACTIVATE:=.venv/Scripts/activate
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 .venv/bin/activate && make install
echo 'run `source .venv/bin/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)]
$(PIP) install -Ue .[$(EXTRAS)]

release: lint test clean
flit publish
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies = []
[project.optional-dependencies]
dev = [
"attribution==1.8.0",
"build>=1",
"black==24.4.2",
"coverage==7.6.1",
"fissix==24.4.24",
Expand Down

0 comments on commit f2450e0

Please sign in to comment.