-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (106 loc) · 3.84 KB
/
Copy pathpublish.yml
File metadata and controls
129 lines (106 loc) · 3.84 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Publish to PyPI
on:
push:
branches: [main]
paths:
- "pyproject.toml"
- "lobes/**"
- "packaging/**"
pull_request:
branches: [main]
paths:
- "pyproject.toml"
- "lobes/**"
- "packaging/**"
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
with:
version: "0.11.29"
enable-cache: true
- 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
with:
version: "0.11.29"
enable-cache: true
- 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 lobes-cli==${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
with:
version: "0.11.29"
enable-cache: true
- 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/
publish-alias:
if: github.event_name == 'push'
needs: [test, publish]
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
with:
version: "0.11.29"
enable-cache: true
- run: uv python install 3.12
- name: Sync alias version to root version
run: |
BASE=$(uv run python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
sed -i "s/^version = .*/version = \"${BASE}\"/" packaging/model-gear/pyproject.toml
sed -i "s/lobes-cli==.*/lobes-cli==${BASE}\"]/" packaging/model-gear/pyproject.toml
- name: Build and publish model-gear alias to PyPI
run: |
cd packaging/model-gear
uv build
uv publish --trusted-publishing always --check-url https://pypi.org/simple/