Skip to content

Commit 3b24fd1

Browse files
committed
ci: select latest release bundle
1 parent bf45354 commit 3b24fd1

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

scripts/reproduce-release.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,33 @@ checksum_tree() {
4646
) > "$output"
4747
}
4848

49+
file_mtime() {
50+
if stat -f %m "$1" >/dev/null 2>&1; then
51+
stat -f %m "$1"
52+
else
53+
stat -c %Y "$1"
54+
fi
55+
}
56+
57+
latest_file() {
58+
local root=$1
59+
local pattern=$2
60+
local latest=
61+
local latest_mtime=0
62+
local candidate
63+
local candidate_mtime
64+
65+
while IFS= read -r -d '' candidate; do
66+
candidate_mtime=$(file_mtime "$candidate")
67+
if [[ -z "$latest" || "$candidate_mtime" -gt "$latest_mtime" ]]; then
68+
latest=$candidate
69+
latest_mtime=$candidate_mtime
70+
fi
71+
done < <(find "$root" -type f -name "$pattern" -print0)
72+
73+
printf '%s\n' "$latest"
74+
}
75+
4976
download_bundletool() {
5077
if [[ -f "$bundletool_jar" ]]; then
5178
local actual
@@ -93,7 +120,7 @@ fi
93120

94121
aab_path=${AAB_PATH:-}
95122
if [[ -z "$aab_path" ]]; then
96-
aab_path=$(find app/build/outputs/bundle/mainnetRelease -name 'bitkit-mainnet-release-*.aab' | LC_ALL=C sort | tail -n 1)
123+
aab_path=$(latest_file app/build/outputs/bundle/mainnetRelease 'bitkit-mainnet-release-*.aab')
97124
fi
98125
if [[ ! -f "$aab_path" ]]; then
99126
echo "AAB not found. Set AAB_PATH or run bundleMainnetRelease first." >&2
@@ -153,4 +180,3 @@ Bundletool: $bundletool_version
153180
EOF
154181

155182
echo "Wrote reproducibility artifacts to '$output_dir'."
156-

0 commit comments

Comments
 (0)