Repository navigation
207 lines (193 loc) · 7.17 KB
/
Copy pathrelease.yml
File metadata and controls
207 lines (193 loc) · 7.17 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: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify tag commit is on main
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::Tag $GITHUB_REF_NAME does not point to a commit on main."
exit 1
fi
- name: Verify version matches tag
run: |
tag_version="${GITHUB_REF_NAME#v}"
pkg_version=$(python -c "exec(open('dashscope/version.py').read()); print(__version__)")
if [ "$tag_version" != "$pkg_version" ]; then
echo "::error::Tag $GITHUB_REF_NAME (=$tag_version) != dashscope/version.py (=$pkg_version)"
exit 1
fi
package:
needs: [validate]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: python -m pip install build twine
# dashscope is pure Python, so `python -m build` emits ONE universal
# py3-none-any wheel plus the sdist. pip installs that single wheel on
# every platform (Linux, Windows, macOS, iOS, Android, ...); native
# multi-platform distribution of the CLI is the `build` job below.
- run: python -m build --outdir dist
- run: twine check dist/*
- run: sha256sum dist/* > dist/SHA256SUMS-python
- uses: actions/upload-artifact@v4
with:
name: python-distribution
path: dist/*
build:
needs: [validate]
name: Build CLI binary (${{ matrix.platform }})
# Standalone `dashscope` CLI executables, one per desktop platform, built
# natively on each runner (no cross-compilation). Each OS builds its own
# arch: macos-latest is Apple Silicon, macos-15-intel is x86_64.
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
arch: arm64
platform: macos-arm64
executable: dashscope
- os: macos-15-intel
arch: x86_64
platform: macos-x86_64
executable: dashscope
- os: ubuntu-latest
arch: x86_64
platform: linux-x86_64
executable: dashscope
- os: windows-latest
arch: x86_64
platform: windows-x86_64
executable: dashscope.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# Base CLI scope: the package plus PyInstaller only. The optional
# expert/voice/camera extras (incl. the AgenticX agent) are intentionally
# NOT bundled, so the bare-`dashscope` agent path is unavailable in the
# binary by design; the v2 command tree is what ships.
# cryptography >=49 ships no macOS x86_64 wheel, forcing an sdist build
# on the Intel runner whose dynamically linked OpenSSL then mismatches
# the libssl PyInstaller bundles (missing SSL_get0_group_name). 48.0.1
# is the last universal2 wheel with statically linked OpenSSL.
- run: python -m pip install . "pyinstaller>=6.0" "cryptography==48.0.1"
- name: Build binary
run: |
pyinstaller \
--onefile \
--name ${{ matrix.executable }} \
--collect-all dashscope \
--collect-submodules dashscope.cli.commands \
--clean \
dashscope/cli/__main__.py
shell: bash
# `dashscope version` is the network-free v2 subcommand. There is no
# --version flag, and a bare `dashscope` would route to the (unbundled)
# agent, so the smoke test names the `version` command explicitly.
- name: Smoke test binary
run: ./dist/${{ matrix.executable }} version
shell: bash
- name: Package release asset
run: |
mkdir -p package/dashscope
cp "dist/${{ matrix.executable }}" package/dashscope/
tar -czf "dist/dashscope-cli-${{ matrix.platform }}.tar.gz" \
-C package dashscope
python -c 'import hashlib; from pathlib import Path; asset = Path("dist/dashscope-cli-${{ matrix.platform }}.tar.gz"); print(hashlib.sha256(asset.read_bytes()).hexdigest(), asset.name)' > "dist/SHA256SUMS-${{ matrix.platform }}"
shell: bash
- uses: actions/upload-artifact@v4
with:
name: dashscope-cli-${{ matrix.platform }}
path: |
dist/dashscope-cli-${{ matrix.platform }}.tar.gz
dist/SHA256SUMS-${{ matrix.platform }}
pypi:
needs: [package]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/dashscope
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-distribution
path: dist/
# PyPI accepts only the wheel + sdist; drop the checksum sidecar.
- name: Keep only Python distributions
run: rm dist/SHA256SUMS-python
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
release:
needs: [build, package]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Collect every artifact: the Python distribution (wheel + sdist +
# checksums) and all four CLI binary tarballs, each under artifacts/<name>/.
- uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Render release notes
env:
TAG_NAME: ${{ github.ref_name }}
run: |
git fetch --tags --force
prev_tag=$(git tag --sort=-v:refname | grep -v "^${TAG_NAME}$" | head -1)
if [ -n "$prev_tag" ]; then
changelog_url="https://github.com/${{ github.repository }}/compare/${prev_tag}...${TAG_NAME}"
else
changelog_url="https://github.com/${{ github.repository }}/commits/${TAG_NAME}"
fi
python - "$TAG_NAME" "$changelog_url" <<'PYEOF'
import sys
from string import Template
from pathlib import Path
tag = sys.argv[1]
changelog = sys.argv[2]
version = tag.lstrip("v")
tpl = Template(Path(".github/release-template.md").read_text())
body = tpl.safe_substitute(
TAG_NAME=tag, VERSION=version, FULL_CHANGELOG_URL=changelog,
)
Path("release-body.md").write_text(body)
PYEOF
- name: Detect pre-release
id: prerelease
env:
TAG_NAME: ${{ github.ref_name }}
run: |
if echo "$TAG_NAME" | grep -qE '(a|b|rc|post|dev)[0-9]'; then
echo "flag=true" >> "$GITHUB_OUTPUT"
else
echo "flag=false" >> "$GITHUB_OUTPUT"
fi
- name: Create draft GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: release-body.md
files: artifacts/**/*
draft: true
prerelease: ${{ steps.prerelease.outputs.flag }}