fix(package): 统一全平台发布包均包含deploy部署运维目录并同步测试与回执断言
Some checks are pending
Build and Release / build (amd64, darwin) (push) Blocked by required conditions
Build and Release / build (amd64, linux) (push) Blocked by required conditions
Build and Release / build (amd64, windows) (push) Blocked by required conditions
Build and Release / build (arm64, darwin) (push) Blocked by required conditions
Build and Release / build (arm64, linux) (push) Blocked by required conditions
Build and Release / build (arm64, windows) (push) Blocked by required conditions
Build and Release / security (push) Waiting to run
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-10-18 17:32:17 +08:00
parent 79c6cfc4dd
commit 0ef8d30007
2 changed files with 17 additions and 6 deletions

View File

@ -9,13 +9,12 @@ import { buildPlan, root, targets } from './build-plugins.mjs'
const execute = promisify(execFile) const execute = promisify(execFile)
const runtimeDirectories = ['config', 'data', 'ssl', 'log'] const runtimeDirectories = ['config', 'data', 'ssl', 'log']
async function copyDeployFiles(stagingSmailDir, target, workspace) { async function copyDeployFiles(stagingSmailDir, target, workspace, files) {
if (!target.startsWith('linux_')) return
const deployDir = path.join(stagingSmailDir, 'deploy') const deployDir = path.join(stagingSmailDir, 'deploy')
const systemdDir = path.join(deployDir, 'systemd') const systemdDir = path.join(deployDir, 'systemd')
await mkdir(deployDir, { recursive: true, mode: 0o755 }) await mkdir(deployDir, { recursive: true, mode: 0o755 })
await mkdir(systemdDir, { recursive: true, mode: 0o755 }) await mkdir(systemdDir, { recursive: true, mode: 0o755 })
const srcDeploy = path.join(workspace, 'deploy') const srcDeploy = path.join(root, 'deploy')
const deployFiles = ['install-systemd.sh', 'update-systemd.sh'] const deployFiles = ['install-systemd.sh', 'update-systemd.sh']
for (const f of deployFiles) { for (const f of deployFiles) {
const src = path.join(srcDeploy, f) const src = path.join(srcDeploy, f)
@ -23,6 +22,7 @@ async function copyDeployFiles(stagingSmailDir, target, workspace) {
try { try {
await copyFile(src, dst) await copyFile(src, dst)
await chmod(dst, 0o755) await chmod(dst, 0o755)
if (files) files.push({ name: ['deploy', f].join('/'), ...await digestFile(dst) })
} catch (e) {} } catch (e) {}
} }
const srcSystemd = path.join(srcDeploy, 'systemd') const srcSystemd = path.join(srcDeploy, 'systemd')
@ -33,6 +33,7 @@ async function copyDeployFiles(stagingSmailDir, target, workspace) {
try { try {
await copyFile(src, dst) await copyFile(src, dst)
await chmod(dst, 0o755) await chmod(dst, 0o755)
if (files) files.push({ name: ['deploy', 'systemd', f].join('/'), ...await digestFile(dst) })
} catch (e) {} } catch (e) {}
} }
} }
@ -146,7 +147,7 @@ export async function packageRelease(selectedTargets = targets, { workspace = ro
await chmod(destination, 0o755) await chmod(destination, 0o755)
files.push({ name, ...await digestFile(destination) }) files.push({ name, ...await digestFile(destination) })
} }
await copyDeployFiles(runtime, target, workspace) await copyDeployFiles(runtime, target, workspace, files)
const version = await resolveAppVersion(workspace) const version = await resolveAppVersion(workspace)
const baseExt = target.startsWith('windows_') ? 'zip' : 'tar.gz' const baseExt = target.startsWith('windows_') ? 'zip' : 'tar.gz'
const archiveName = version && version !== 'dev' ? `Smail_${version}_${target}.${baseExt}` : `${name}.${baseExt}` const archiveName = version && version !== 'dev' ? `Smail_${version}_${target}.${baseExt}` : `${name}.${baseExt}`

View File

@ -50,14 +50,24 @@ test('六个平台发布包只包含三个程序和四个空目录,解压后
const programs = ['smail', 'smail-admin', 'smail-config'].map(name => name + extension) const programs = ['smail', 'smail-admin', 'smail-config'].map(name => name + extension)
const directories = ['config', 'data', 'log', 'ssl'] const directories = ['config', 'data', 'log', 'ssl']
const entries = await listArchiveEntries(release.archive) const entries = await listArchiveEntries(release.archive)
const deployEntries = [
'smail/deploy/',
'smail/deploy/install-systemd.sh',
'smail/deploy/update-systemd.sh',
'smail/deploy/systemd/',
'smail/deploy/systemd/smail.service',
'smail/deploy/systemd/smail-admin.service',
'smail/deploy/systemd/smail-tls-sync.service',
'smail/deploy/systemd/smail-tls-sync.path'
]
assert.deepEqual(entries.sort(), [ assert.deepEqual(entries.sort(), [
'smail/', ...programs.map(name => `smail/${name}`), ...directories.map(name => `smail/${name}/`) 'smail/', ...programs.map(name => 'smail/' + name), ...directories.map(name => 'smail/' + name + '/'), ...deployEntries
].sort()) ].sort())
const extracted = path.join(workspace, 'extracted', release.target) const extracted = path.join(workspace, 'extracted', release.target)
await mkdir(extracted, { recursive: true }) await mkdir(extracted, { recursive: true })
await extractArchive(release.archive, extracted) await extractArchive(release.archive, extracted)
const receipt = JSON.parse(await readFile(release.receipt, 'utf8')) const receipt = JSON.parse(await readFile(release.receipt, 'utf8'))
assert.equal(receipt.files.length, 3) assert.equal(receipt.files.length, 9)
assert.equal(receipt.archive.name, path.basename(release.archive)) assert.equal(receipt.archive.name, path.basename(release.archive))
const archiveBytes = await readFile(release.archive) const archiveBytes = await readFile(release.archive)
assert.equal(receipt.archive.bytes, archiveBytes.length) assert.equal(receipt.archive.bytes, archiveBytes.length)