banxiang/scripts/version_check.sh
2026-02-20 00:05:12 +08:00

14 lines
390 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 读取 pubspec.yaml 中的 version 字段
VERSION=$(grep "^version:" pubspec.yaml | sed 's/version: *//' | tr -d ' ')
# 检查 version 格式是否符合 x.x.x+x用正则
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+\+[0-9]+$ ]]; then
echo "错误: version 格式不符合 x.x.x+x"
exit 1
fi
# 输出格式:当前版本: x.x.x+x
echo "当前版本: $VERSION"