-
Notifications
You must be signed in to change notification settings - Fork 22
207 lines (195 loc) · 6.79 KB
/
publish.yml
File metadata and controls
207 lines (195 loc) · 6.79 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Publish
on:
push:
tags: ["v*"]
permissions:
contents: write
id-token: write
jobs:
validate-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.tag_version }}
steps:
- uses: actions/checkout@v4
- id: extract-version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
- id: read-version
run: |
python3 << EOF
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
version = data['project']['version']
print(f"pyproject_version={version}", file=open('$GITHUB_OUTPUT', 'a'))
EOF
- run: |
TAG_VERSION="${{ steps.extract-version.outputs.tag_version }}"
PYPROJECT_VERSION="${{ steps.read-version.outputs.pyproject_version }}"
if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]; then
echo "Version mismatch: tag=$TAG_VERSION, pyproject=$PYPROJECT_VERSION"
exit 1
fi
run-ci:
needs: validate-release
uses: ./.github/workflows/ci.yml
secrets: inherit
collect-integration-tests:
needs: [validate-release, run-ci]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.collect.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: collect
run: |
echo "matrix=$(find tests/integration_tests -name 'test_*.py' -not -path '*/__pycache__/*' | sort | jq -R -s -c 'split("\n") | map(select(length > 0))')" >> $GITHUB_OUTPUT
integration-tests:
needs: [validate-release, run-ci, collect-integration-tests]
runs-on: ubuntu-latest
timeout-minutes: 30
environment:
name: integration-tests
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.collect-integration-tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: ./.github/actions/setup-python-uv
- run: uv sync --extra gcp
- name: Run ${{ matrix.test }}
env:
TEST_FILE: ${{ matrix.test }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BFL_API_KEY: ${{ secrets.BFL_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
BYTEPLUS_API_KEY: ${{ secrets.BYTEPLUS_API_KEY }}
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
GRADIUM_API_KEY: ${{ secrets.GRADIUM_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
MOONSHOT_API_KEY: ${{ secrets.MOONSHOT_API_KEY }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
uv run pytest "$TEST_FILE" \
-m integration -v \
--reruns 2 --reruns-delay 10 \
"--deselect=tests/integration_tests/text/test_generate.py::test_vertex_generate[anthropic-claude-haiku-4-5-us-east5]" \
"--deselect=tests/integration_tests/text/test_stream_generate.py::test_vertex_stream_generate[anthropic-claude-haiku-4-5-us-east5]" \
"--deselect=tests/integration_tests/audio/test_speak.py::test_speak[google-gemini-2.5-flash-tts]" \
"--deselect=tests/integration_tests/audio/test_speak.py::test_speak[google-gemini-2.5-pro-tts]"
build:
needs: [validate-release, run-ci, collect-integration-tests, integration-tests]
if: |
always() &&
needs.validate-release.result == 'success' &&
needs.run-ci.result == 'success' &&
needs.collect-integration-tests.result == 'success' &&
(needs.integration-tests.result == 'success' || needs.integration-tests.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: ./.github/actions/setup-python-uv
- run: uv build
- run: |
uv pip install twine
uv run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish-testpypi:
needs: [build]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/project/celeste-ai/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
print-hash: true
publish-pypi:
needs: [publish-testpypi]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/celeste-ai/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
print-hash: true
github-release:
needs: [publish-pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- id: extract-version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
- id: changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG=$(git log --pretty=format:'- %s' --reverse || echo "Initial release")
else
CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:'- %s' || echo "No changes")
fi
{
echo 'changelog<<EOF'
echo "$CHANGELOG"
echo 'EOF'
} >> $GITHUB_OUTPUT
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release v${{ steps.extract-version.outputs.version }}
body: |
## Release v${{ steps.extract-version.outputs.version }}
### Changes
${{ steps.changelog.outputs.changelog }}
### Installation
```bash
uv add "celeste-ai==${{ steps.extract-version.outputs.version }}"
```
files: dist/*
draft: false
prerelease: false