Skip to content

Commit d2a0a44

Browse files
committed
workflows: Add release action
1 parent d8ec154 commit d2a0a44

16 files changed

+854
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
set -eu
3+
function handle_archive_universally() {
4+
if [[ $# -ne 3 ]]; then
5+
return 1
6+
fi
7+
RAW_ARCHIVE_NAME="$1"
8+
OS="$2"
9+
ARCH="$3"
10+
11+
NATIVELAYOUT="android-tools-static-$PROJECT_VERSION-$OS-nativelayout-$ARCH"
12+
STANDARDLAYOUT="android-tools-static-$OS-standardlayout-$ARCH"
13+
STANDARDLAYOUTEX="android-tools-static-$OS-standardlayout-extra-$ARCH"
14+
15+
# Extract the input archive. The contents of this archive are expected to be extracted
16+
# to android-tools-static/.
17+
# The contents of this archive are modified and removed from. Archives of all layouts
18+
# are created during the process.
19+
tar -oxf "$RAW_ARCHIVE_NAME"
20+
21+
# x86_64 linux (alpine native) is the source of manpages for all targets.
22+
# This means that most targets don't have to have a pandoc dependency.
23+
if [[ "$OS" == "linux" && "$ARCH" == "x86_64" ]]; then
24+
cp android-tools-static/man1/adb.1 .
25+
fi
26+
27+
rm -rf android-tools-static/man1/
28+
cp adb.1 android-tools-static/
29+
30+
if [[ "$OS" == "macos" ]]; then
31+
# macOS universal2 has two SBOMs per archive.
32+
for sbom_path in android-tools-static/*-SBOM.json; do
33+
BASENAME="$(basename "$sbom_path")"
34+
SBOM_ARCH="${BASENAME%-SBOM.json}"
35+
SBOM_PATH="android-tools-static-$PROJECT_VERSION-$OS-$SBOM_ARCH-SBOM.json"
36+
mv "$sbom_path" "release-artifacts/$SBOM_PATH"
37+
done
38+
else
39+
# Remove SBOM from the archive, give it an appropriate name and add it
40+
# to to_release.
41+
SBOM_PATH="android-tools-static-$PROJECT_VERSION-$OS-$ARCH-SBOM.json"
42+
mv "android-tools-static/SBOM.json" "release-artifacts/$SBOM_PATH"
43+
fi
44+
45+
#
46+
# nativelayout
47+
#
48+
mv android-tools-static "$NATIVELAYOUT"
49+
50+
if [[ "$OS" == "windows" ]]; then
51+
zip -r "release-artifacts/$NATIVELAYOUT.zip" "$NATIVELAYOUT"
52+
else
53+
tar -czf "release-artifacts/$NATIVELAYOUT.tar.gz" "$NATIVELAYOUT"
54+
fi
55+
56+
#
57+
# standardlayout-extra
58+
#
59+
mv "$NATIVELAYOUT" android-tools-static
60+
61+
rm -rf android-tools-static/bash-completion/
62+
rm android-tools-static/adb.1
63+
64+
if [[ "$OS" == "windows" ]]; then
65+
for executable in android-tools-static/*.exe; do
66+
mv "$executable" "${executable/.exe}"
67+
done
68+
fi
69+
70+
tar -czf "release-artifacts/$STANDARDLAYOUTEX.tar.gz" android-tools-static
71+
72+
#
73+
# standardlayout
74+
#
75+
if [[ "$OS" == "windows" ]]; then
76+
cp "release-artifacts/$STANDARDLAYOUTEX.tar.gz" "release-artifacts/$STANDARDLAYOUT.tar.gz"
77+
else
78+
for exe in android-tools-static/*; do
79+
[[ -x "$exe" ]] || continue
80+
[[ "$exe" == *".dll" ]] && continue
81+
82+
# Follow the requirements stated in README.
83+
BASENAME="$(basename "$exe")"
84+
if [[ $BASENAME != adb && \
85+
$BASENAME != append2simg && \
86+
$BASENAME != fastboot && \
87+
$BASENAME != img2simg && \
88+
$BASENAME != simg2img ]]; then
89+
rm "$exe"
90+
fi
91+
done
92+
93+
tar -czf "release-artifacts/$STANDARDLAYOUT.tar.gz" android-tools-static
94+
fi
95+
rm -rf android-tools-static
96+
}
97+
98+
mkdir release-artifacts
99+
100+
handle_archive_universally linux-build-x86_64/android-tools-static-linux-x86_64.tar linux x86_64
101+
for arch in aarch64 ppc64le riscv64 armv6l armv7l; do
102+
handle_archive_universally linux-build-$arch/android-tools-static-linux-$arch.tar linux $arch
103+
done
104+
handle_archive_universally windows-build-x86_64/android-tools-static-windows-x86_64.tar windows x86_64
105+
handle_archive_universally windows-build-x86/android-tools-static-windows-x86.tar windows x86
106+
handle_archive_universally osx-build/android-tools-static-macos-universal2.tar macos universal2
107+
108+
SOURCE_WIN_AR_NAME="android-tools-static-$PROJECT_VERSION-src-windows"
109+
SOURCE_AR_NAME="android-tools-static-$PROJECT_VERSION-src"
110+
111+
mkdir "$SOURCE_WIN_AR_NAME"
112+
tar -C "$SOURCE_WIN_AR_NAME" -xf source/source.tar
113+
rm -rf "$SOURCE_WIN_AR_NAME"/.git "$SOURCE_WIN_AR_NAME"/vendor/*/.git
114+
find "$SOURCE_WIN_AR_NAME/subprojects" -maxdepth 1 -mindepth 1 -type d \
115+
! -name packagefiles ! -name "boringssl-*" ! -name "AdbWinApi-*" \
116+
-exec rm -rf '{}' +
117+
find "$SOURCE_WIN_AR_NAME/vendor/boringssl" -mindepth 1 -delete
118+
touch "$SOURCE_WIN_AR_NAME/nopatch"
119+
120+
zip -r "release-artifacts/$SOURCE_WIN_AR_NAME.zip" "$SOURCE_WIN_AR_NAME"
121+
122+
mv "$SOURCE_WIN_AR_NAME" "$SOURCE_AR_NAME"
123+
rm -r "$SOURCE_AR_NAME"/subprojects/AdbWinApi-*
124+
tar -czf "release-artifacts/$SOURCE_AR_NAME.tar.gz" "$SOURCE_AR_NAME"

0 commit comments

Comments
 (0)