-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 1.73 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Publish to PyPI
on:
push:
branches: [main]
paths:
- 'pyproject.toml'
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true
type: string
permissions:
contents: read
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/0.5.4/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv pip install --system -e ".[dev]"
- name: Lint
run: make lint-fix
check-version:
needs: build
runs-on: ubuntu-latest
outputs:
should_publish: ${{ steps.check.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: check
run: |
CHANGED=$(git diff HEAD^ HEAD -- pyproject.toml | grep '+version' || true)
echo "changed=${CHANGED:+true}" >> $GITHUB_OUTPUT
public-pypi:
needs: [build, check-version]
if: needs.check-version.outputs.should_publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/0.5.4/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Build package
run: uv build
- name: Publish to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv build --no-sources
uv publish