-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (70 loc) · 2.56 KB
/
Copy pathpublish.yml
File metadata and controls
88 lines (70 loc) · 2.56 KB
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
79
80
81
82
83
84
85
86
87
88
name: Publish to PyPI
on:
push:
branches: [main]
paths:
- "pyproject.toml"
- "lepenseur/**"
pull_request:
branches: [main]
paths:
- "pyproject.toml"
- "lepenseur/**"
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- run: uv run pytest -n auto -v
test-publish:
# Skip on fork PRs — no OIDC/environment context is available there, so the
# publish step would fail and block external contributor CI.
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
needs: test
runs-on: ubuntu-latest
environment: testpypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- name: Set dev version
run: |
BASE=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
DEV_VERSION="${BASE}.dev${{ github.run_number }}"
sed -i "s/^version = .*/version = \"${DEV_VERSION}\"/" pyproject.toml
echo "DEV_VERSION=${DEV_VERSION}" >> "$GITHUB_ENV"
echo "Publishing ${DEV_VERSION} to TestPyPI"
- name: Build and publish to TestPyPI
run: |
uv build
uv publish --publish-url https://test.pypi.org/legacy/ --trusted-publishing always --check-url https://test.pypi.org/simple/
- name: Print install commands
if: always()
run: |
echo "::notice::Test with: uv tool install --index-url https://test.pypi.org/simple/ --index-strategy unsafe-best-match lepenseur==${DEV_VERSION}"
publish:
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- name: Build and publish to PyPI
run: |
uv build
uv publish --trusted-publishing always --check-url https://pypi.org/simple/