iflow2api-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iflow2api_sdk-0.1.0/.github/workflows/publish.yml +143 -0
- iflow2api_sdk-0.1.0/.gitignore +6 -0
- iflow2api_sdk-0.1.0/EXAMPLES.md +665 -0
- iflow2api_sdk-0.1.0/PKG-INFO +289 -0
- iflow2api_sdk-0.1.0/README.md +254 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/__init__.py +123 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/api/__init__.py +21 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/api/chat.py +434 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/api/models.py +71 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/auth.py +127 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/client.py +319 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/client_async.py +296 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/config.py +104 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/exceptions.py +158 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/models/__init__.py +49 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/models/chat.py +159 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/models/common.py +48 -0
- iflow2api_sdk-0.1.0/iflow2api_sdk/streaming.py +281 -0
- iflow2api_sdk-0.1.0/pyproject.toml +93 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
name: Build and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- '**'
|
|
7
|
+
tags:
|
|
8
|
+
- 'v*'
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
outputs:
|
|
17
|
+
version: ${{ steps.get-version.outputs.version }}
|
|
18
|
+
version-matched: ${{ steps.validate-version.outputs.matched }}
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: '3.11'
|
|
27
|
+
|
|
28
|
+
- name: Get version from pyproject.toml
|
|
29
|
+
id: get-version
|
|
30
|
+
run: |
|
|
31
|
+
VERSION=$(grep -oP '^version\s*=\s*"\K[^"]+' pyproject.toml)
|
|
32
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
33
|
+
echo "Package version: $VERSION"
|
|
34
|
+
|
|
35
|
+
- name: Validate version matches tag
|
|
36
|
+
id: validate-version
|
|
37
|
+
run: |
|
|
38
|
+
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
|
39
|
+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
|
|
40
|
+
PYPROJECT_VERSION="${{ steps.get-version.outputs.version }}"
|
|
41
|
+
if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]; then
|
|
42
|
+
echo "Error: Tag version ($TAG_VERSION) does not match pyproject.toml version ($PYPROJECT_VERSION)"
|
|
43
|
+
echo "matched=false" >> $GITHUB_OUTPUT
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
echo "Version check passed: $TAG_VERSION"
|
|
47
|
+
echo "matched=true" >> $GITHUB_OUTPUT
|
|
48
|
+
else
|
|
49
|
+
echo "Not a tag push, skipping version validation"
|
|
50
|
+
echo "matched=false" >> $GITHUB_OUTPUT
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
- name: Install build tools
|
|
54
|
+
run: |
|
|
55
|
+
python -m pip install --upgrade pip
|
|
56
|
+
pip install build twine
|
|
57
|
+
|
|
58
|
+
- name: Build package
|
|
59
|
+
run: python -m build
|
|
60
|
+
|
|
61
|
+
- name: Check package
|
|
62
|
+
run: python -m twine check dist/*
|
|
63
|
+
|
|
64
|
+
- name: Upload build artifacts
|
|
65
|
+
uses: actions/upload-artifact@v4
|
|
66
|
+
with:
|
|
67
|
+
name: dist-packages
|
|
68
|
+
path: dist/
|
|
69
|
+
retention-days: 1
|
|
70
|
+
|
|
71
|
+
# 每次推送都发布到 TestPyPI 进行测试
|
|
72
|
+
publish-testpypi:
|
|
73
|
+
name: Publish to TestPyPI
|
|
74
|
+
needs: build
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
environment:
|
|
77
|
+
name: pypi
|
|
78
|
+
url: https://test.pypi.org/project/iflow2api-sdk/
|
|
79
|
+
permissions:
|
|
80
|
+
id-token: write
|
|
81
|
+
steps:
|
|
82
|
+
- name: Download build artifacts
|
|
83
|
+
uses: actions/download-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: dist-packages
|
|
86
|
+
path: dist/
|
|
87
|
+
|
|
88
|
+
- name: Publish to TestPyPI
|
|
89
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
90
|
+
with:
|
|
91
|
+
repository-url: https://test.pypi.org/legacy/
|
|
92
|
+
password: ${{ secrets.TEST_PYPI_API_KEY }}
|
|
93
|
+
skip-existing: true
|
|
94
|
+
|
|
95
|
+
# 从 TestPyPI 安装并测试
|
|
96
|
+
test-from-testpypi:
|
|
97
|
+
name: Test from TestPyPI
|
|
98
|
+
needs: [build, publish-testpypi]
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
steps:
|
|
101
|
+
- name: Set up Python
|
|
102
|
+
uses: actions/setup-python@v5
|
|
103
|
+
with:
|
|
104
|
+
python-version: '3.11'
|
|
105
|
+
|
|
106
|
+
- name: Wait for TestPyPI propagation
|
|
107
|
+
run: sleep 30
|
|
108
|
+
|
|
109
|
+
- name: Install from TestPyPI
|
|
110
|
+
run: |
|
|
111
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ iflow2api-sdk==${{ needs.build.outputs.version }}
|
|
112
|
+
|
|
113
|
+
- name: Test import
|
|
114
|
+
run: |
|
|
115
|
+
python -c "import iflow2api_sdk; print('版本:', iflow2api_sdk.__version__); print('导入成功!')"
|
|
116
|
+
|
|
117
|
+
# 只有 tag 与 pyproject.toml 版本匹配且 TestPyPI 测试通过后才发布到正式 PyPI
|
|
118
|
+
publish-pypi:
|
|
119
|
+
name: Publish to PyPI
|
|
120
|
+
needs: [build, test-from-testpypi]
|
|
121
|
+
runs-on: ubuntu-latest
|
|
122
|
+
if: needs.build.outputs.version-matched == 'true'
|
|
123
|
+
environment:
|
|
124
|
+
name: pypi
|
|
125
|
+
url: https://pypi.org/project/iflow2api-sdk/
|
|
126
|
+
permissions:
|
|
127
|
+
id-token: write
|
|
128
|
+
steps:
|
|
129
|
+
- name: Download build artifacts
|
|
130
|
+
uses: actions/download-artifact@v4
|
|
131
|
+
with:
|
|
132
|
+
name: dist-packages
|
|
133
|
+
path: dist/
|
|
134
|
+
|
|
135
|
+
- name: Verify version before publish
|
|
136
|
+
run: |
|
|
137
|
+
echo "Publishing version: ${{ needs.build.outputs.version }}"
|
|
138
|
+
echo "Tag: ${{ github.ref_name }}"
|
|
139
|
+
|
|
140
|
+
- name: Publish to PyPI
|
|
141
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
142
|
+
with:
|
|
143
|
+
password: ${{ secrets.PYPI_API_KEY }}
|