Bitrise 和 CI 的全新版本。我的目标是当我在存储库中标记构建时触发构建并发布到 App Store Connect。我的触发按预期工作。我想知道是否可以从 BITRISE_GIT_TAG 环境变量中提取版本和内部版本号。 我想使用 DEV v1.0.3-22 标记 GH 上的提交,然后使用“设置 Xcode 项目内部版本号”步骤运行工作流程,其中我将内部版本号设置为 22,将版本号设置为 1.0.3。这反映了我们后端的 CI/CD 流程。
我怎样才能做到这一点?
我最终处理这个问题的方法是使用下面的代码添加自定义脚本步骤。看起来有点老套,但一直工作可靠。
#!/usr/bin/env bash
# fail if any commands fails
set -e
# make pipelines' return status equal the last command to exit with a non-zero status, or zero if all commands exit successfully
set -o pipefail
# debug log
set -x
# write your script here
tag="$BITRISE_GIT_TAG"
app_version="0.0.0"
build_number="1"
if [ ! -z "$tag" ] ; then
echo $tag
pattern='[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
if [[ $tag =~ $pattern ]]; then
app_version=${BASH_REMATCH[0]}
else echo 'App Version not found';
fi
build_number=${tag##*-}
envman add --key app_build_number --value "$build_number"
envman add --key app_version --value "$app_version"
fi