blob: a7ae751a4b19e14a2413c4109d84d8878cba0adc (
plain)
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
|
name: Test, Build, and Publish
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
test-build-publish:
runs-on: ubuntu-latest
name: Test, Build and Publish
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install uv
run: pip install uv
- name: Run typecheck
run: uv run mypy .
- name: Run tests
run: uv run python test.py
- name: Build package
run: uv build
- name: Publish to PyPI
if: github.ref == 'refs/heads/main'
run: |
set +e
# Run uv publish and capture output
OUTPUT=$(uv publish 2>&1)
STATUS=$?
set -eo pipefail
echo "$OUTPUT"
if [ $STATUS -eq 0 ]; then
echo "✅ Publish succeeded."
exit 0
elif echo "$OUTPUT" | grep -q "400 File already exists"; then
echo "⚠️ Package version already exists on PyPI. Skipping publish."
exit 0
else
echo "❌ Publish failed unexpectedly."
exit $STATUS
fi
env:
UV_PUBLISH_TOKEN: ${{ secrets.UV_PYPI_TOKEN }}
|