ci: simplify packing script logic

This commit is contained in:
鲁树人 2025-05-09 04:47:18 +09:00
parent c0649d1246
commit 1a943309fa

View File

@ -3,32 +3,42 @@
APP_VERSION="${1:-$(git describe --tags --always)}" APP_VERSION="${1:-$(git describe --tags --always)}"
for exe in prepare/*/um-*.exe; do pack() {
name="$(basename "$exe" .exe)-$APP_VERSION" local is_windows=0
new_exe="$(dirname "$exe")/um.exe" local suffix=""
mv "$exe" "$new_exe" if [[ "$1" == *.exe ]]; then
suffix=".exe"
is_windows=1
fi
echo "archiving ${new_exe}..." local exe_dir="$(dirname "$1")"
zip -Xqj9 "dist/${name}.zip" "$new_exe" local archive_name="$(basename "$1" ".exe")-${APP_VERSION}${suffix}"
rm -f "$new_exe" local exe_name="um${suffix}"
done
for exe in prepare/*/um-*; do echo "archiving ${exe_name}..."
name="$(basename "$exe")-$APP_VERSION"
new_exe="$(dirname "$exe")/um"
mv "$exe" "$new_exe"
echo "archiving ${new_exe}..." # Prepare metadata
tar \ cp README.md LICENSE "$exe_dir"
--sort=name --format=posix \ mv "$1" "${exe_dir}/${exe_name}"
--pax-option=exthdr.name=%d/PaxHeaders/%f \
--pax-option=delete=atime,delete=ctime \ if [[ "$is_windows" == 1 ]]; then
--clamp-mtime --mtime='1970-01-01T00:00:00Z' \ zip -Xqj9 "dist/${archive_name}.zip" "${exe_name}" README.md LICENSE
--numeric-owner --owner=0 --group=0 \ else
--mode=0755 \ tar \
-c -C "$(dirname "$exe")" um | --sort=name --format=posix \
gzip -9 >"dist/${name}.tar.gz" --pax-option=exthdr.name=%d/PaxHeaders/%f \
rm -f "$exe" --pax-option=delete=atime,delete=ctime \
--clamp-mtime --mtime='1970-01-01T00:00:00Z' \
--numeric-owner --owner=0 --group=0 \
--mode=0755 \
-c -C "$exe_dir" "${exe_name}" README.md LICENSE |
gzip -9 >"dist/${archive_name}.tar.gz"
fi
rm -rf "$exe_dir"
}
for exe in prepare/*/um*; do
pack "$exe"
done done
pushd dist pushd dist