.gitlab-ci.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. workflow:
  2. rules:
  3. - if: '$CI_COMMIT_TAG =~ /^python-v\d+\.\d+\.\d+$/'
  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. - test "$CI_COMMIT_TAG" = "python-v$DSH_VERSION" || { echo "Tag $CI_COMMIT_TAG does not match package.json version $DSH_VERSION"; exit 1; }
  17. - python -m pip install uv==0.11.23
  18. sdk-wheel:
  19. extends: .python-tools
  20. stage: build
  21. tags: [linux-x64]
  22. script:
  23. - python scripts/build-python-release.py --package sdk --tag "$CI_COMMIT_TAG" --output-dir release/sdk
  24. artifacts:
  25. paths: [release/sdk/*.whl]
  26. expire_in: 1 week
  27. .runtime-wheel:
  28. extends: .python-tools
  29. stage: build
  30. script:
  31. - corepack enable
  32. - pnpm install --frozen-lockfile
  33. - pnpm run verify-runtime-closure
  34. - pnpm exec tsx scripts/build-exe-for-python-sdk.ts --targets="$PKG_TARGET"
  35. - EXE="$PWD/dist-exe/dsh-jsonrpc-agent-pkg-$PLATFORM"
  36. - test -x "$EXE"
  37. - uv run --python 3.10 --group test --project python/sdk python scripts/smoke-python-runtime.py --scenario all --exe "$EXE"
  38. - python scripts/build-python-release.py --package runtime --tag "$CI_COMMIT_TAG" --platform "$PLATFORM" --runtime-exe "$EXE" --output-dir "release/$PLATFORM"
  39. - python -m venv .wheel-smoke
  40. - .wheel-smoke/bin/python -m pip install --find-links "release/$PLATFORM" --find-links release/sdk deepseek-harness=="$DSH_VERSION"
  41. - .wheel-smoke/bin/python scripts/smoke-python-runtime.py --scenario sdk-default
  42. - |
  43. if [ "${PLATFORM#linux-}" != "$PLATFORM" ]; then
  44. readelf --version-info "$EXE" > glibc-versions.txt
  45. maximum="$(sed -n 's/.*Name: GLIBC_\([0-9.]*\).*/\1/p' glibc-versions.txt | sort -V | tail -1)"
  46. test -n "$maximum"
  47. dpkg --compare-versions "$maximum" le 2.28
  48. case "$PLATFORM" in
  49. linux-x64) image=quay.io/pypa/manylinux_2_28_x86_64 ;;
  50. linux-arm64) image=quay.io/pypa/manylinux_2_28_aarch64 ;;
  51. *) echo "Unsupported Linux platform $PLATFORM"; exit 1 ;;
  52. esac
  53. 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==$DSH_VERSION && /tmp/dsh-sdk/bin/python /work/scripts/smoke-python-runtime.py --scenario sdk-default"
  54. fi
  55. artifacts:
  56. paths: [release/$PLATFORM/*.whl]
  57. expire_in: 1 week
  58. runtime-linux-x64:
  59. extends: .runtime-wheel
  60. tags: [linux-x64]
  61. variables:
  62. PKG_TARGET: node24-linux-x64
  63. PLATFORM: linux-x64
  64. needs:
  65. - job: sdk-wheel
  66. artifacts: true
  67. runtime-linux-arm64:
  68. extends: .runtime-wheel
  69. tags: [linux-arm64]
  70. variables:
  71. PKG_TARGET: node24-linux-arm64
  72. PLATFORM: linux-arm64
  73. needs:
  74. - job: sdk-wheel
  75. artifacts: true
  76. runtime-macos-arm64:
  77. extends: .runtime-wheel
  78. tags: [macos-arm64]
  79. variables:
  80. PKG_TARGET: node24-macos-arm64
  81. PLATFORM: macos-arm64
  82. needs:
  83. - job: sdk-wheel
  84. artifacts: true
  85. publish-python:
  86. stage: publish
  87. tags: [linux-x64]
  88. resource_group: python-release
  89. needs:
  90. - job: sdk-wheel
  91. artifacts: true
  92. - job: runtime-linux-x64
  93. artifacts: true
  94. - job: runtime-linux-arm64
  95. artifacts: true
  96. - job: runtime-macos-arm64
  97. artifacts: true
  98. before_script:
  99. - python3 -m venv .ci-python
  100. - . .ci-python/bin/activate
  101. - export DSH_VERSION="$(python -c 'import json; print(json.load(open("package.json"))["version"])')"
  102. - test "$CI_COMMIT_TAG" = "python-v$DSH_VERSION" || { echo "Tag $CI_COMMIT_TAG does not match package.json version $DSH_VERSION"; exit 1; }
  103. - python -m pip install twine==6.2.0
  104. script:
  105. - test "$(find release -name '*.whl' | wc -l | tr -d ' ')" = 4
  106. - test -f "release/sdk/deepseek_harness-${DSH_VERSION}-py3-none-any.whl"
  107. - test -f "release/linux-x64/deepseek_harness_runtime_bin-${DSH_VERSION}-py3-none-manylinux_2_28_x86_64.whl"
  108. - test -f "release/linux-arm64/deepseek_harness_runtime_bin-${DSH_VERSION}-py3-none-manylinux_2_28_aarch64.whl"
  109. - test -f "release/macos-arm64/deepseek_harness_runtime_bin-${DSH_VERSION}-py3-none-macosx_11_0_arm64.whl"
  110. - python -m twine check release/*/*.whl
  111. - export TWINE_USERNAME=gitlab-ci-token
  112. - export TWINE_PASSWORD="$CI_JOB_TOKEN"
  113. - export TWINE_REPOSITORY_URL="$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/pypi"
  114. - python -m twine upload --non-interactive release/*/*.whl || { echo 'Publish failed. GitLab does not overwrite an existing version; create a new python-vX.Y.Z tag.'; exit 1; }