改用共享目录传递Salon生产发布包

This commit is contained in:
2026-09-01 16:08:10 +08:00
parent 317e482534
commit f62fb02ef0
3 changed files with 49 additions and 41 deletions
+10 -33
View File
@@ -42,45 +42,22 @@ jobs:
java -version 2>&1 | grep -q '17\.'
node --version | grep -q '^v20\.'
pwsh --version
- name: 下载已审核发布包
- name: 读取已审核发布包
shell: bash
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PREPARE_RUN_ID: ${{ inputs.prepare_run_id }}
ARTIFACT_NAME: salon-prod-${{ inputs.release_sha }}
RELEASE_SHA: ${{ inputs.release_sha }}
run: |
set -euo pipefail
test -n "$GITEA_TOKEN"
test -n "$PREPARE_RUN_ID"
test -n "$ARTIFACT_NAME"
api_base="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$PREPARE_RUN_ID/artifacts?api-version=6.0-preview"
response_file="$RUNNER_TEMP/salon-prod-artifacts.json"
curl --fail-with-body --silent --show-error --retry 3 --retry-all-errors \
-H "Authorization: Bearer $GITEA_TOKEN" "$api_base" > "$response_file"
artifact_id=$(node -e 'const fs=require("fs"); const name=process.argv[1]; const data=JSON.parse(fs.readFileSync(process.argv[2],"utf8")); const item=(data.value||[]).find(v=>v.name===name); if(!item||!item.fileContainerResourceUrl) process.exit(2); const m=item.fileContainerResourceUrl.match(/\\/(\\d+)\\/path$/); if(!m) process.exit(3); process.stdout.write(m[1]);' "$ARTIFACT_NAME" "$response_file")
path_url="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$PREPARE_RUN_ID/artifacts/$artifact_id/path?api-version=6.0-preview"
curl --fail-with-body --silent --show-error --retry 3 --retry-all-errors \
-H "Authorization: Bearer $GITEA_TOKEN" "$path_url" > "$RUNNER_TEMP/salon-prod-artifact-path.json"
test -n "$RELEASE_SHA"
shared_dir="/salon-release/$RELEASE_SHA"
test -d "$shared_dir"
test -f "$shared_dir/.manifest.sha256"
(cd "$shared_dir" && sha256sum -c .manifest.sha256)
mkdir -p artifacts/release
node - "$RUNNER_TEMP/salon-prod-artifact-path.json" "$GITHUB_SERVER_URL" "$PREPARE_RUN_ID" "$artifact_id" "$GITEA_TOKEN" <<'NODE'
const fs = require('fs');
const { execFileSync } = require('child_process');
const [pathFile, server, runId, artifactId, token] = process.argv.slice(2);
const data = JSON.parse(fs.readFileSync(pathFile, 'utf8'));
const files = data.value || [];
if (files.length === 0) throw new Error('Artifact 未返回任何文件');
for (const file of files) {
if (!file.contentLocation || !file.path) throw new Error('Artifact 文件项缺少下载地址或路径');
const relativePath = file.path.split('/').slice(1).join('/');
if (!relativePath || relativePath.includes('..')) throw new Error(`非法 Artifact 路径: ${file.path}`);
const output = `artifacts/release/${relativePath}`;
fs.mkdirSync(require('path').dirname(output), { recursive: true });
execFileSync('curl', ['--fail-with-body', '--silent', '--show-error', '--retry', '3', '--retry-all-errors', '-H', `Authorization: Bearer ${token}`, `${server}${file.contentLocation}?itemPath=${encodeURIComponent(file.path)}`, '-o', output], { stdio: 'inherit' });
}
NODE
cp -a "$shared_dir/." artifacts/release/
test -f artifacts/release/manifest.json
test -f artifacts/release/backend/JC-Salon-Core.jar || find artifacts/release -name 'JC-Salon-Core.jar' -exec cp {} artifacts/release/backend/JC-Salon-Core.jar \;
test -f artifacts/release/backend/JC-Salon-Gateway.jar || find artifacts/release -name 'JC-Salon-Gateway.jar' -exec cp {} artifacts/release/backend/JC-Salon-Gateway.jar \;
test -f artifacts/release/backend/JC-Salon-Core.jar
test -f artifacts/release/backend/JC-Salon-Gateway.jar
- name: 发布并校验 Salon 生产 Nacos
shell: bash
env: