Files
starRiverProperty/artifacts/backup-config-probe-20260429-235551/release-cw-elevator-application.sh.bak
T
反编译工作区 8b15445328 feat: add service config templates and extraction script
Former-commit-id: 1de24b7eb79676d1aba9d799a58c5a753290cf52
2026-05-01 19:38:01 +08:00

152 lines
6.1 KiB
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.
#!/usr/bin/env bash
# 构建 cw-elevator-application 指定版本发布包,并输出到 maven 模块下 releases/<version>/。
# 用法:在仓库根执行 ./scripts/release-cw-elevator-application.sh [版本号]
# 默认版本与根 POM 中 elevator.release.finalName 后缀一致(当前 2.0.0)。
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
MAVEN_ROOT="${ROOT}/maven-cw-elevator-application"
REL_VER="${1:-2.0.0}"
JAR_NAME="cw-elevator-application-${REL_VER}.jar"
OUT_DIR="${MAVEN_ROOT}/releases/v${REL_VER}"
DOC_FALLBACK_VER="${DOC_FALLBACK_VER:-2.0.0}"
JAVA_HOME="${JAVA_HOME:-/usr/lib/jvm/java-8-openjdk-amd64}"
export JAVA_HOME
export PATH="${JAVA_HOME}/bin:${PATH}"
if ! java -version 2>&1 | grep -q 'version "1\.8\.'; then
echo "ERROR: 需要 JDK 8JAVA_HOME=${JAVA_HOME})。当前:" >&2
java -version >&2 || true
exit 1
fi
rm -rf "${OUT_DIR}"
mkdir -p "${OUT_DIR}"
require_file() {
local file_path="$1"
local hint="$2"
if [[ ! -f "${file_path}" ]]; then
echo "ERROR: 缺少必需文件: ${file_path} (${hint})" >&2
exit 1
fi
}
echo "==> Set reactor version to ${REL_VER}"
(cd "${MAVEN_ROOT}" && mvn -q org.codehaus.mojo:versions-maven-plugin:2.16.2:set \
-DnewVersion="${REL_VER}" -DprocessAllModules=true -DgenerateBackupPoms=false)
echo "==> Package starter (fat jar)"
(cd "${MAVEN_ROOT}" && mvn -q -pl cw-elevator-application-starter -am package -DskipTests)
SRC_JAR="${MAVEN_ROOT}/cw-elevator-application-starter/target/${JAR_NAME}"
if [[ ! -f "${SRC_JAR}" ]]; then
for candidate in $(ls -1t "${MAVEN_ROOT}/cw-elevator-application-starter/target"/cw-elevator-application-*.jar 2>/dev/null || true); do
if [[ "${candidate}" == *.jar.original ]]; then
continue
fi
SRC_JAR="${candidate}"
break
done
fi
if [[ -z "${SRC_JAR}" || ! -f "${SRC_JAR}" ]]; then
echo "ERROR: 未找到可用 starter 制品(期望 ${JAR_NAME}" >&2
exit 1
fi
echo "==> Copy artifacts to ${OUT_DIR}"
install -m0644 "${SRC_JAR}" "${OUT_DIR}/${JAR_NAME}"
DDL_SRC="${ROOT}/docs/sql/tenant_visitor_floor_policy.sql"
DDL_DIR="${OUT_DIR}/ddl"
mkdir -p "${DDL_DIR}"
require_file "${DDL_SRC}" "DDL"
install -m0644 "${DDL_SRC}" "${DDL_DIR}/tenant_visitor_floor_policy.sql"
DDL_INIT_SRC="${ROOT}/docs/sql/tenant_visitor_floor_policy_init_guangfa_fund.sql"
require_file "${DDL_INIT_SRC}" "初始化 SQL"
install -m0644 "${DDL_INIT_SRC}" "${DDL_DIR}/tenant_visitor_floor_policy_init_guangfa_fund.sql"
UPGRADE_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-版本升级说明书.md"
if [[ ! -f "${UPGRADE_SRC}" ]]; then
UPGRADE_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-版本升级说明书.md"
fi
require_file "${UPGRADE_SRC}" "版本升级说明书"
install -m0644 "${UPGRADE_SRC}" "${OUT_DIR}/版本升级说明书.md"
INDEX_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-发布说明.md"
if [[ ! -f "${INDEX_SRC}" ]]; then
INDEX_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-发布说明.md"
fi
require_file "${INDEX_SRC}" "发布说明"
install -m0644 "${INDEX_SRC}" "${OUT_DIR}/发布说明.md"
CLIENT_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-甲方版本升级说明.md"
if [[ ! -f "${CLIENT_SRC}" ]]; then
CLIENT_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-甲方版本升级说明.md"
fi
require_file "${CLIENT_SRC}" "甲方版本升级说明"
install -m0644 "${CLIENT_SRC}" "${OUT_DIR}/甲方版本升级说明.md"
PLAN_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-升级计划.md"
if [[ ! -f "${PLAN_SRC}" ]]; then
PLAN_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-升级计划.md"
fi
require_file "${PLAN_SRC}" "升级计划"
install -m0644 "${PLAN_SRC}" "${OUT_DIR}/升级计划.md"
CONF_DIR="${OUT_DIR}/config"
mkdir -p "${CONF_DIR}"
for conf_name in bootstrap.properties application.properties application-access-control.properties; do
CONF_SRC="${MAVEN_ROOT}/deploy/v2-maven/${conf_name}"
require_file "${CONF_SRC}" "配置文件 ${conf_name}"
install -m0644 "${CONF_SRC}" "${CONF_DIR}/${conf_name}"
done
RUNNER_DIR="${OUT_DIR}/bin"
mkdir -p "${RUNNER_DIR}"
RUNNER_SRC="${MAVEN_ROOT}/deploy/v2-maven/run.sh"
require_file "${RUNNER_SRC}" "启动脚本 run.sh"
install -m0755 "${RUNNER_SRC}" "${RUNNER_DIR}/run.sh"
DELIVERY_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-实施交付清单.md"
if [[ ! -f "${DELIVERY_SRC}" ]]; then
DELIVERY_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-实施交付清单.md"
fi
require_file "${DELIVERY_SRC}" "实施交付清单"
install -m0644 "${DELIVERY_SRC}" "${OUT_DIR}/实施交付清单.md"
ACCEPTANCE_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-实施验收记录模板.md"
if [[ ! -f "${ACCEPTANCE_SRC}" ]]; then
ACCEPTANCE_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-实施验收记录模板.md"
fi
require_file "${ACCEPTANCE_SRC}" "实施验收记录模板"
install -m0644 "${ACCEPTANCE_SRC}" "${OUT_DIR}/实施验收记录模板.md"
AUDIT_SRC="${ROOT}/docs/build/cw-elevator-application-v${REL_VER}-SQL与代码一致性审核记录.md"
if [[ ! -f "${AUDIT_SRC}" ]]; then
AUDIT_SRC="${ROOT}/docs/build/cw-elevator-application-v${DOC_FALLBACK_VER}-SQL与代码一致性审核记录.md"
fi
require_file "${AUDIT_SRC}" "SQL与代码一致性审核记录"
install -m0644 "${AUDIT_SRC}" "${OUT_DIR}/SQL与代码一致性审核记录.md"
{
echo "artifact=${JAR_NAME}"
echo "directory=${OUT_DIR}"
echo "built_at=$(date -Iseconds 2>/dev/null || date)"
echo "java_home=${JAVA_HOME}"
java -version 2>&1 | sed 's/^/java_version_line=/' || true
echo -n "git_rev="
(cd "${ROOT}" && git rev-parse HEAD 2>/dev/null) || echo "unknown"
echo -n "git_branch="
(cd "${ROOT}" && git rev-parse --abbrev-ref HEAD 2>/dev/null) || echo "unknown"
} > "${OUT_DIR}/BUILD_MANIFEST.txt"
echo "==> Restore reactor version to 2.0-SNAPSHOT"
(cd "${MAVEN_ROOT}" && mvn -q org.codehaus.mojo:versions-maven-plugin:2.16.2:set \
-DnewVersion=2.0-SNAPSHOT -DprocessAllModules=true -DgenerateBackupPoms=false)
echo "==> Done."
ls -la "${OUT_DIR}"