Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ jobs:
with:
python-version: '3.10'

- name: Get latest test version and calculate next version
- name: Get latest version from PyPI and calculate next version
id: version
run: |
# 获取所有 agentrun-inner-test-v* 的 tags,找到最新版本
LATEST_TAG=$(git tag -l "agentrun-inner-test-v*" | sort -V | tail -n 1)
# 从 PyPI 获取 agentrun-inner-test 的最新版本
PYPI_RESPONSE=$(curl -s https://pypi.org/pypi/agentrun-inner-test/json 2>/dev/null || echo "")

if [ -z "$LATEST_TAG" ]; then
# 如果没有找到任何 tag,从 0.0.0 开始
if [ -z "$PYPI_RESPONSE" ] || echo "$PYPI_RESPONSE" | grep -q "Not Found"; then
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for "Not Found" using grep may not be reliable for detecting PyPI errors. The PyPI API returns a 404 status code with JSON response like {"message": "Not Found"}, but curl with -s flag doesn't expose HTTP status codes. If the API returns other error formats or network issues occur, this check might not catch them.

Consider checking for valid JSON and the presence of the 'info' key instead:

if [ -z "$PYPI_RESPONSE" ] || ! echo "$PYPI_RESPONSE" | python3 -c "import sys, json; exit(0 if 'info' in json.load(sys.stdin) else 1)" 2>/dev/null; then
Suggested change
if [ -z "$PYPI_RESPONSE" ] || echo "$PYPI_RESPONSE" | grep -q "Not Found"; then
if [ -z "$PYPI_RESPONSE" ] || ! echo "$PYPI_RESPONSE" | python3 -c "import sys, json; exit(0 if 'info' in json.load(sys.stdin) else 1)" 2>/dev/null; then

Copilot uses AI. Check for mistakes.
# 如果包不存在,从 0.0.0 开始
CURRENT_VERSION="0.0.0"
echo "No existing test tags found, starting from 0.0.0"
echo "Package not found on PyPI, starting from 0.0.0"
else
# 从 tag 中提取版本号
CURRENT_VERSION="${LATEST_TAG#agentrun-inner-test-v}"
echo "Latest test tag: $LATEST_TAG (version: $CURRENT_VERSION)"
# 从 PyPI 响应中提取最新版本
CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extracted CURRENT_VERSION is not validated before being used in version parsing. If the version from PyPI has an unexpected format (e.g., "1.0.0rc1" or "1.0"), the IFS-based parsing on line 50 may produce incorrect results, leading to invalid version calculations.

Consider adding validation:

CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
# Validate version format
if ! echo "$CURRENT_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
  echo "Invalid version format from PyPI: $CURRENT_VERSION, starting from 0.0.0"
  CURRENT_VERSION="0.0.0"
fi
echo "Latest version on PyPI: $CURRENT_VERSION"
Suggested change
CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
# Validate version format
if ! echo "$CURRENT_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid version format from PyPI: $CURRENT_VERSION, starting from 0.0.0"
CURRENT_VERSION="0.0.0"
fi

Copilot uses AI. Check for mistakes.
echo "Latest version on PyPI: $CURRENT_VERSION"
Comment on lines +45 to +46
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON parsing lacks error handling. If the PyPI response doesn't contain the expected structure (e.g., missing 'info' or 'version' keys), the python command will fail and CURRENT_VERSION will be empty, leading to potential issues in version parsing.

Consider adding error handling:

CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; data = json.load(sys.stdin); print(data.get('info', {}).get('version', ''))" 2>/dev/null)
if [ -z "$CURRENT_VERSION" ]; then
  echo "Failed to parse version from PyPI, starting from 0.0.0"
  CURRENT_VERSION="0.0.0"
fi
Suggested change
CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
echo "Latest version on PyPI: $CURRENT_VERSION"
CURRENT_VERSION=$(echo "$PYPI_RESPONSE" | python3 -c "import sys, json; data = json.load(sys.stdin); print(data.get('info', {}).get('version', ''))" 2>/dev/null)
if [ -z "$CURRENT_VERSION" ]; then
echo "Failed to parse version from PyPI, starting from 0.0.0"
CURRENT_VERSION="0.0.0"
else
echo "Latest version on PyPI: $CURRENT_VERSION"
fi

Copilot uses AI. Check for mistakes.
fi

# 解析版本号
Expand Down