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
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:
parent
79c6cfc4dd
commit
0ef8d30007
@ -9,13 +9,12 @@ import { buildPlan, root, targets } from './build-plugins.mjs'
|
||||
const execute = promisify(execFile)
|
||||
const runtimeDirectories = ['config', 'data', 'ssl', 'log']
|
||||
|
||||
async function copyDeployFiles(stagingSmailDir, target, workspace) {
|
||||
if (!target.startsWith('linux_')) return
|
||||
async function copyDeployFiles(stagingSmailDir, target, workspace, files) {
|
||||
const deployDir = path.join(stagingSmailDir, 'deploy')
|
||||
const systemdDir = path.join(deployDir, 'systemd')
|
||||
await mkdir(deployDir, { 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']
|
||||
for (const f of deployFiles) {
|
||||
const src = path.join(srcDeploy, f)
|
||||
@ -23,6 +22,7 @@ async function copyDeployFiles(stagingSmailDir, target, workspace) {
|
||||
try {
|
||||
await copyFile(src, dst)
|
||||
await chmod(dst, 0o755)
|
||||
if (files) files.push({ name: ['deploy', f].join('/'), ...await digestFile(dst) })
|
||||
} catch (e) {}
|
||||
}
|
||||
const srcSystemd = path.join(srcDeploy, 'systemd')
|
||||
@ -33,6 +33,7 @@ async function copyDeployFiles(stagingSmailDir, target, workspace) {
|
||||
try {
|
||||
await copyFile(src, dst)
|
||||
await chmod(dst, 0o755)
|
||||
if (files) files.push({ name: ['deploy', 'systemd', f].join('/'), ...await digestFile(dst) })
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
@ -146,7 +147,7 @@ export async function packageRelease(selectedTargets = targets, { workspace = ro
|
||||
await chmod(destination, 0o755)
|
||||
files.push({ name, ...await digestFile(destination) })
|
||||
}
|
||||
await copyDeployFiles(runtime, target, workspace)
|
||||
await copyDeployFiles(runtime, target, workspace, files)
|
||||
const version = await resolveAppVersion(workspace)
|
||||
const baseExt = target.startsWith('windows_') ? 'zip' : 'tar.gz'
|
||||
const archiveName = version && version !== 'dev' ? `Smail_${version}_${target}.${baseExt}` : `${name}.${baseExt}`
|
||||
|
||||
@ -50,14 +50,24 @@ test('六个平台发布包只包含三个程序和四个空目录,解压后
|
||||
const programs = ['smail', 'smail-admin', 'smail-config'].map(name => name + extension)
|
||||
const directories = ['config', 'data', 'log', 'ssl']
|
||||
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(), [
|
||||
'smail/', ...programs.map(name => `smail/${name}`), ...directories.map(name => `smail/${name}/`)
|
||||
'smail/', ...programs.map(name => 'smail/' + name), ...directories.map(name => 'smail/' + name + '/'), ...deployEntries
|
||||
].sort())
|
||||
const extracted = path.join(workspace, 'extracted', release.target)
|
||||
await mkdir(extracted, { recursive: true })
|
||||
await extractArchive(release.archive, extracted)
|
||||
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))
|
||||
const archiveBytes = await readFile(release.archive)
|
||||
assert.equal(receipt.archive.bytes, archiveBytes.length)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user