代码拉取完成,页面将自动刷新
#!/bin/bash
echo "start publish..."
# 加载配置
if [ -f "publish.config" ]; then
source publish.config
else
echo "错误: 找不到配置文件 publish.config"
exit 1
fi
echo "开始发布流程..."
# 检查har包是否存在
echo "检查har包..."
if ls ${HAR_FILE} 1> /dev/null 2>&1; then
echo "找到har包文件"
else
echo "错误: 未找到har包文件,请确认libs目录下存在har文件"
exit 1
fi
git config --global credential.helper store
# 发布har包
echo "开始发布har包..."
echo "ohpm版本: $(ohpm -v)"
PUBLISH_SUCCESS=false
for har_file in ${HAR_FILE}; do
if [ -f "$har_file" ]; then
echo "发布文件: $har_file"
# 使用 here-document 方式传递密码
ohpm publish "$har_file" << EOF
${OHPM_PASSWORD}
EOF
# 获取命令的退出状态码
ohpm_exit_code=$?
# 判断执行是否成功
if [ $ohpm_exit_code -eq 0 ]; then
PUBLISH_SUCCESS=true
echo "发布成功: $har_file"
else
echo "发布失败: $har_file (退出码: $ohpm_exit_code)"
# 退出脚本
exit 1
fi
fi
done
# 推送代码和tag
if [ "$ENABLE_GIT_OPERATIONS" = true ] && [ "$PUBLISH_SUCCESS" = true ]; then
# echo "提交代码..."
# git add .
# git commit -m "${COMMIT_MESSAGE}"
# 设置tag版本
echo "设置tag版本: ${TAG_VERSION}"
git tag -a "${TAG_VERSION}" -m "${COMMIT_MESSAGE}"
echo "推送代码和tag..."
git push origin main
git push origin "${TAG_NAME}"
git push github master
git push github "${TAG_NAME}"
else
echo "Git操作已禁用,跳过git提交和tag操作"
fi
echo "发布流程完成!"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。