52 lines
1.3 KiB
Bash
Raw Normal View History

2025-05-08 07:02:42 +09:00
#!/bin/bash -e
# see .gitea/workflows/build.yml
APP_VERSION="${1:-$(git describe --tags --always)}"
2025-05-09 04:47:18 +09:00
pack() {
local is_windows=0
local suffix=""
if [[ "$1" == *.exe ]]; then
suffix=".exe"
is_windows=1
fi
local exe_dir="$(dirname "$1")"
2025-05-09 05:00:21 +09:00
local archive_name="$(basename "$1" ".exe")-${APP_VERSION}"
2025-05-09 04:47:18 +09:00
local exe_name="um${suffix}"
echo "archiving ${exe_name}..."
2025-05-09 05:00:21 +09:00
mv "$1" "${exe_name}"
2025-05-09 04:47:18 +09:00
if [[ "$is_windows" == 1 ]]; then
2025-05-09 05:00:21 +09:00
echo zip -Xqj9 "dist/${archive_name}.zip" -- "${exe_name}" README.md LICENSE
exit 1
2025-05-09 04:47:18 +09:00
else
tar \
--sort=name --format=posix \
--pax-option=exthdr.name=%d/PaxHeaders/%f \
--pax-option=delete=atime,delete=ctime \
--clamp-mtime --mtime='1970-01-01T00:00:00Z' \
--numeric-owner --owner=0 --group=0 \
2025-05-09 05:00:21 +09:00
--mode=0755 -c -- \
"${exe_name}" README.md LICENSE |
2025-05-09 04:47:18 +09:00
gzip -9 >"dist/${archive_name}.tar.gz"
fi
2025-05-09 05:00:21 +09:00
rm -rf "$exe_dir" "${exe_name}"
2025-05-09 04:47:18 +09:00
}
for exe in prepare/*/um*; do
pack "$exe"
done
pushd dist
2025-05-08 07:02:42 +09:00
if command -v strip-nondeterminism >/dev/null 2>&1; then
echo 'strip archives...'
strip-nondeterminism *.zip *.tar.gz
fi
echo 'Creating checksum...'
sha256sum *.zip *.tar.gz >sha256sum.txt
popd