.gitlab-ci.yml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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-arm64 ]; then
  59. python3 scripts/check-macos-deployment-target.py "$EXE" "$EXE-spawn-helper"
  60. fi
  61. artifacts:
  62. paths: [release/$PLATFORM/*.whl]
  63. expire_in: 1 week
  64. runtime-linux-x64:
  65. extends: .runtime-wheel
  66. tags: [linux-x64]
  67. variables:
  68. PKG_TARGET: node24-linux-x64
  69. PLATFORM: linux-x64
  70. needs:
  71. - job: sdk-wheel
  72. artifacts: true
  73. runtime-linux-arm64:
  74. extends: .runtime-wheel
  75. tags: [linux-arm64]
  76. variables:
  77. PKG_TARGET: node24-linux-arm64
  78. PLATFORM: linux-arm64
  79. needs:
  80. - job: sdk-wheel
  81. artifacts: true
  82. runtime-macos-arm64:
  83. extends: .runtime-wheel
  84. tags: [macos-arm64]
  85. variables:
  86. PKG_TARGET: node24-macos-arm64
  87. PLATFORM: macos-arm64
  88. needs:
  89. - job: sdk-wheel
  90. artifacts: true
  91. runtime-windows-x64:
  92. stage: build
  93. tags: [windows-x64]
  94. variables:
  95. PKG_TARGET: node24-win-x64
  96. PLATFORM: win-x64
  97. needs:
  98. - job: sdk-wheel
  99. artifacts: true
  100. before_script:
  101. - python -m venv .ci-python
  102. - $env:DSH_VERSION = (& .ci-python\Scripts\python.exe -c 'import json; print(json.load(open("package.json"))["version"])')
  103. - $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"]()))')
  104. - 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" }
  105. - .ci-python\Scripts\python.exe -m pip install uv==0.11.23
  106. - $env:Path = (Join-Path $PWD ".ci-python\Scripts") + [IO.Path]::PathSeparator + $env:Path
  107. script:
  108. - corepack enable
  109. - pnpm install --frozen-lockfile
  110. - pnpm run verify-runtime-closure
  111. - pnpm exec tsx scripts/build-exe-for-python-sdk.ts --targets=$env:PKG_TARGET
  112. - $exe = Join-Path $PWD "dist-exe\deepseek-harness-sdk-runtime-win-x64.exe"
  113. - if (-not (Test-Path -LiteralPath $exe -PathType Leaf)) { throw "Runtime executable is missing at $exe" }
  114. - uv run --python 3.10 --group test --project python/sdk python scripts/smoke-python-runtime.py --scenario all --exe $exe
  115. - .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"
  116. - python -m venv .wheel-smoke
  117. - .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"
  118. - Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
  119. - Remove-Item Env:DSH_RUNTIME_MODE -ErrorAction SilentlyContinue
  120. - $blackbox = Join-Path $env:TEMP "dsh-sdk-blackbox-$([guid]::NewGuid())"
  121. - New-Item -ItemType Directory -Path $blackbox | Out-Null
  122. - Push-Location $blackbox
  123. - 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 }
  124. artifacts:
  125. paths: [release/win-x64/*.whl]
  126. expire_in: 1 week
  127. publish-python:
  128. stage: publish
  129. tags: [linux-x64]
  130. resource_group: python-release
  131. needs:
  132. - job: sdk-wheel
  133. artifacts: true
  134. - job: runtime-linux-x64
  135. artifacts: true
  136. - job: runtime-linux-arm64
  137. artifacts: true
  138. - job: runtime-macos-arm64
  139. artifacts: true
  140. - job: runtime-windows-x64
  141. artifacts: true
  142. before_script:
  143. - python3 -m venv .ci-python
  144. - . .ci-python/bin/activate
  145. - export DSH_VERSION="$(python -c 'import json; print(json.load(open("package.json"))["version"])')"
  146. - export DSH_WHEEL_VERSION="$(python -c 'import runpy; release = runpy.run_path("scripts/build-python-release.py"); print(release["pep440_version"](release["repository_version"]()))')"
  147. - test "$CI_COMMIT_TAG" = "python-v$DSH_VERSION" || { echo "Tag $CI_COMMIT_TAG does not match package.json version $DSH_VERSION"; exit 1; }
  148. - python -m pip install twine==6.2.0
  149. script:
  150. - test "$(find release -name '*.whl' | wc -l | tr -d ' ')" = 5
  151. - test -f "release/sdk/deepseek_harness_sdk-${DSH_WHEEL_VERSION}-py3-none-any.whl"
  152. - test -f "release/linux-x64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-manylinux_2_28_x86_64.whl"
  153. - test -f "release/linux-arm64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-manylinux_2_28_aarch64.whl"
  154. - test -f "release/macos-arm64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-macosx_14_0_arm64.whl"
  155. - test -f "release/win-x64/deepseek_harness_runtime_bin-${DSH_WHEEL_VERSION}-py3-none-win_amd64.whl"
  156. - python -m twine check release/*/*.whl
  157. - export TWINE_USERNAME=gitlab-ci-token
  158. - export TWINE_PASSWORD="$CI_JOB_TOKEN"
  159. - export TWINE_REPOSITORY_URL="$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/pypi"
  160. - 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; }