.gitlab-ci.yml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. workflow:
  2. rules:
  3. - if: '$CI_COMMIT_TAG =~ /^python-v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$/'
  4. - when: never
  5. stages:
  6. - build
  7. - publish
  8. variables:
  9. GIT_DEPTH: "0"
  10. PIP_DISABLE_PIP_VERSION_CHECK: "1"
  11. .python-tools:
  12. before_script:
  13. - python3 -m venv .ci-python
  14. - . .ci-python/bin/activate
  15. - export DSH_VERSION="$(python -c 'import json; print(json.load(open("package.json"))["version"])')"
  16. - export DSH_WHEEL_VERSION="$(python -c 'import runpy; release = runpy.run_path("scripts/build-python-release.py"); print(release["pep440_version"](release["repository_version"]()))')"
  17. - test "$CI_COMMIT_TAG" = "python-v$DSH_VERSION" || { echo "Tag $CI_COMMIT_TAG does not match package.json version $DSH_VERSION"; exit 1; }
  18. - python -m pip install uv==0.11.23
  19. sdk-wheel:
  20. extends: .python-tools
  21. stage: build
  22. tags: [linux-x64]
  23. script:
  24. - python scripts/build-python-release.py --package sdk --tag "$CI_COMMIT_TAG" --output-dir release/sdk
  25. artifacts:
  26. paths: [release/sdk/*.whl]
  27. expire_in: 1 week
  28. .runtime-wheel:
  29. extends: .python-tools
  30. stage: build
  31. script:
  32. - corepack enable
  33. - pnpm install --frozen-lockfile
  34. - pnpm run verify-runtime-closure
  35. - pnpm exec tsx scripts/build-exe-for-python-sdk.ts --targets="$PKG_TARGET"
  36. - EXE="$PWD/dist-exe/deepseek-harness-sdk-runtime-$PLATFORM"
  37. - test -x "$EXE"
  38. - uv run --python 3.10 --group test --project python/sdk python scripts/smoke-python-runtime.py --scenario all --exe "$EXE"
  39. - python scripts/build-python-release.py --package runtime --tag "$CI_COMMIT_TAG" --platform "$PLATFORM" --runtime-exe "$EXE" --output-dir "release/$PLATFORM"
  40. - python -m venv .wheel-smoke
  41. - .wheel-smoke/bin/python -m pip install --find-links "release/$PLATFORM" --find-links release/sdk deepseek-harness-sdk=="$DSH_WHEEL_VERSION"
  42. - .wheel-smoke/bin/python scripts/smoke-python-runtime.py --scenario sdk-default
  43. - .wheel-smoke/bin/python scripts/smoke-python-runtime.py --scenario sdk-mcp
  44. - |
  45. if [ "${PLATFORM#linux-}" != "$PLATFORM" ]; then
  46. readelf --version-info "$EXE" > glibc-versions.txt
  47. maximum="$(sed -n 's/.*Name: GLIBC_\([0-9.]*\).*/\1/p' glibc-versions.txt | sort -V | tail -1)"
  48. test -n "$maximum"
  49. dpkg --compare-versions "$maximum" le 2.28
  50. case "$PLATFORM" in
  51. linux-x64) image=quay.io/pypa/manylinux_2_28_x86_64 ;;
  52. linux-arm64) image=quay.io/pypa/manylinux_2_28_aarch64 ;;
  53. *) echo "Unsupported Linux platform $PLATFORM"; exit 1 ;;
  54. esac
  55. docker run --rm -v "$PWD:/work" -w /work "$image" bash -euxo pipefail -c "/opt/python/cp310-cp310/bin/python -m venv /tmp/dsh-sdk && /tmp/dsh-sdk/bin/python -m pip install --find-links /work/release/$PLATFORM --find-links /work/release/sdk deepseek-harness-sdk==$DSH_WHEEL_VERSION && /tmp/dsh-sdk/bin/python /work/scripts/smoke-python-runtime.py --scenario sdk-default && /tmp/dsh-sdk/bin/python /work/scripts/smoke-python-runtime.py --scenario sdk-mcp"
  56. fi
  57. - |
  58. if [ "${PLATFORM#macos-}" != "$PLATFORM" ]; then
  59. case "$PLATFORM" in
  60. macos-arm64) macho_arch=arm64 ;;
  61. macos-x64) macho_arch=x86_64 ;;
  62. *) echo "Unsupported macOS platform $PLATFORM"; exit 1 ;;
  63. esac
  64. for payload in "$EXE" "$EXE-rg" "$EXE-spawn-helper"; do
  65. lipo "$payload" -verify_arch "$macho_arch"
  66. done
  67. python3 scripts/check-macos-deployment-target.py --platform "$PLATFORM" "$EXE" "$EXE-rg" "$EXE-spawn-helper"
  68. fi
  69. artifacts:
  70. paths: [release/$PLATFORM/*.whl]
  71. expire_in: 1 week
  72. runtime-linux-x64:
  73. extends: .runtime-wheel
  74. tags: [linux-x64]
  75. variables:
  76. PKG_TARGET: node24-linux-x64
  77. PLATFORM: linux-x64
  78. needs:
  79. - job: sdk-wheel
  80. artifacts: true
  81. runtime-linux-arm64:
  82. extends: .runtime-wheel
  83. tags: [linux-arm64]
  84. variables:
  85. PKG_TARGET: node24-linux-arm64
  86. PLATFORM: linux-arm64
  87. needs:
  88. - job: sdk-wheel
  89. artifacts: true
  90. runtime-macos-arm64:
  91. extends: .runtime-wheel
  92. tags: [macos-arm64]
  93. variables:
  94. PKG_TARGET: node24-macos-arm64
  95. PLATFORM: macos-arm64
  96. needs:
  97. - job: sdk-wheel
  98. artifacts: true
  99. runtime-macos-x64:
  100. extends: .runtime-wheel
  101. tags: [macos-x64]
  102. variables:
  103. PKG_TARGET: node24-macos-x64
  104. PLATFORM: macos-x64
  105. needs:
  106. - job: sdk-wheel
  107. artifacts: true
  108. runtime-windows-x64:
  109. stage: build
  110. tags: [windows-x64]
  111. variables:
  112. PKG_TARGET: node24-win-x64
  113. PLATFORM: win-x64
  114. needs:
  115. - job: sdk-wheel
  116. artifacts: true
  117. before_script:
  118. - python -m venv .ci-python
  119. - $env:DSH_VERSION = (& .ci-python\Scripts\python.exe -c 'import json; print(json.load(open("package.json"))["version"])')
  120. - $env:DSH_WHEEL_VERSION = (& .ci-python\Scripts\python.exe -c 'import runpy; release = runpy.run_path("scripts/build-python-release.py"); print(release["pep440_version"](release["repository_version"]()))')
  121. - if ($env:CI_COMMIT_TAG -ne "python-v$env:DSH_VERSION") { throw "Tag $env:CI_COMMIT_TAG does not match package.json version $env:DSH_VERSION" }
  122. - .ci-python\Scripts\python.exe -m pip install uv==0.11.23
  123. - $env:Path = (Join-Path $PWD ".ci-python\Scripts") + [IO.Path]::PathSeparator + $env:Path
  124. script:
  125. - corepack enable
  126. - pnpm install --frozen-lockfile
  127. - pnpm run verify-runtime-closure
  128. - pnpm exec tsx scripts/build-exe-for-python-sdk.ts --targets=$env:PKG_TARGET
  129. - $exe = Join-Path $PWD "dist-exe\deepseek-harness-sdk-runtime-win-x64.exe"
  130. - if (-not (Test-Path -LiteralPath $exe -PathType Leaf)) { throw "Runtime executable is missing at $exe" }
  131. - uv run --python 3.10 --group test --project python/sdk python scripts/smoke-python-runtime.py --scenario all --exe $exe
  132. - .ci-python\Scripts\python.exe scripts/build-python-release.py --package runtime --tag $env:CI_COMMIT_TAG --platform $env:PLATFORM --runtime-exe $exe --output-dir "release/$env:PLATFORM"
  133. - python -m venv .wheel-smoke
  134. - .wheel-smoke\Scripts\python.exe -m pip install "release/sdk/deepseek_harness_sdk-$env:DSH_WHEEL_VERSION-py3-none-any.whl" "release/win-x64/deepseek_harness_runtime_bin-$env:DSH_WHEEL_VERSION-py3-none-win_amd64.whl"
  135. - Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
  136. - Remove-Item Env:DSH_RUNTIME_MODE -ErrorAction SilentlyContinue
  137. - $blackbox = Join-Path $env:TEMP "dsh-sdk-blackbox-$([guid]::NewGuid())"
  138. - New-Item -ItemType Directory -Path $blackbox | Out-Null
  139. - Push-Location $blackbox
  140. - try { & "$env:CI_PROJECT_DIR\.wheel-smoke\Scripts\python.exe" "$env:CI_PROJECT_DIR\scripts\smoke-python-runtime.py" --scenario all --installed-wheel } finally { Pop-Location }
  141. artifacts:
  142. paths: [release/win-x64/*.whl]
  143. expire_in: 1 week
  144. publish-python:
  145. stage: publish
  146. tags: [linux-x64]
  147. resource_group: python-release
  148. needs:
  149. - job: sdk-wheel
  150. artifacts: true
  151. - job: runtime-linux-x64
  152. artifacts: true
  153. - job: runtime-linux-arm64
  154. artifacts: true
  155. - job: runtime-macos-arm64
  156. artifacts: true
  157. - job: runtime-macos-x64
  158. artifacts: true
  159. - job: runtime-windows-x64
  160. artifacts: true
  161. before_script:
  162. - python3 -m venv .ci-python
  163. - . .ci-python/bin/activate
  164. - export DSH_VERSION="$(python -c 'import json; print(json.load(open("package.json"))["version"])')"
  165. - export DSH_WHEEL_VERSION="$(python -c 'import runpy; release = runpy.run_path("scripts/build-python-release.py"); print(release["pep440_version"](release["repository_version"]()))')"
  166. - test "$CI_COMMIT_TAG" = "python-v$DSH_VERSION" || { echo "Tag $CI_COMMIT_TAG does not match package.json version $DSH_VERSION"; exit 1; }
  167. - python -m pip install twine==6.2.0
  168. script:
  169. - test "$(find release -name '*.whl' | wc -l | tr -d ' ')" = 6
  170. - test -f "release/sdk/deepseek_harness_sdk-${DSH_WHEEL_VERSION}-py3-none-any.whl"
  171. - test -f "release/linux-x64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-manylinux_2_28_x86_64.whl"
  172. - test -f "release/linux-arm64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-manylinux_2_28_aarch64.whl"
  173. - test -f "release/macos-arm64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-macosx_14_0_arm64.whl"
  174. - test -f "release/macos-x64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-macosx_14_0_x86_64.whl"
  175. - test -f "release/win-x64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-win_amd64.whl"
  176. - python -m twine check release/*/*.whl
  177. - export TWINE_USERNAME=gitlab-ci-token
  178. - export TWINE_PASSWORD="$CI_JOB_TOKEN"
  179. - export TWINE_REPOSITORY_URL="$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/pypi"
  180. - python -m twine upload --non-interactive release/*/*.whl || { echo 'Publish failed. GitLab does not overwrite an existing version; create a new python-v<repository-version> tag.'; exit 1; }