Skip to content

Commit 662572c

Browse files
authored
Build Android release and upload to Cloud Bucket (#277)
1 parent 9fa781e commit 662572c

1 file changed

Lines changed: 85 additions & 5 deletions

File tree

‎.github/workflows/kernelctf-release-build.yaml‎

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,97 @@ jobs:
2929
- name: Checkout repo
3030
uses: actions/checkout@v4
3131

32-
- name: Check release does not exist yet
33-
run: curl --fail -I https://storage.googleapis.com/kernelctf-build/releases/${{inputs.releaseId}}/bzImage && exit 1 || true
32+
- name: Detect build type
33+
id: detect
34+
run: |
35+
# Detect Android builds by prefix, assume Linux for everything else
36+
if [[ "${{inputs.releaseId}}" =~ ^android- ]]; then
37+
echo "type=android" >> $GITHUB_OUTPUT
38+
echo "Detected Android build from releaseId prefix"
39+
else
40+
echo "type=linux" >> $GITHUB_OUTPUT
41+
echo "Detected Linux build (default)"
42+
fi
3443
35-
- name: Install prerequisites
44+
- name: Check release does not exist yet
45+
run: |
46+
if curl --fail -I https://storage.googleapis.com/kernelctf-build/releases/${{inputs.releaseId}}/bzImage 2>/dev/null; then
47+
echo "Error: Release ${{inputs.releaseId}} already exists"
48+
exit 1
49+
fi
50+
51+
- name: Install Linux build prerequisites
52+
if: steps.detect.outputs.type == 'linux'
3653
run: |
3754
sudo apt-get update
3855
sudo apt install -yq --no-install-recommends build-essential flex bison bc ca-certificates libelf-dev libssl-dev cpio pahole
56+
57+
- name: Install Android build prerequisites
58+
if: steps.detect.outputs.type == 'android'
59+
run: sudo apt install -yq --no-install-recommends git
60+
61+
- name: Setup Go
62+
if: steps.detect.outputs.type == 'android'
63+
uses: actions/setup-go@v5
64+
with:
65+
go-version: 'stable'
3966

40-
- name: Build
67+
- name: Build fetch_artifact tool
68+
if: steps.detect.outputs.type == 'android'
69+
run: |
70+
git clone https://android.googlesource.com/tools/fetch_artifact
71+
cd fetch_artifact
72+
go build -o fetch_artifact .
73+
sudo mv fetch_artifact /usr/local/bin/
74+
fetch_artifact --version || fetch_artifact --help
75+
76+
- name: Build Linux kernel
77+
if: steps.detect.outputs.type == 'linux'
4178
run: ./build_release.sh ${{inputs.releaseId}} ${{inputs.branch}}
4279

80+
- name: Build Android kernel
81+
if: steps.detect.outputs.type == 'android'
82+
run: |
83+
RELEASE_ID="${{inputs.releaseId}}"
84+
ARCH=$(echo $RELEASE_ID | cut -d'-' -f3)
85+
BUILD_ID=$(echo $RELEASE_ID | cut -d'-' -f4)
86+
87+
echo "Architecture: $ARCH"
88+
echo "Build ID: $BUILD_ID"
89+
90+
if [[ "$ARCH" == "x64" ]]; then
91+
TARGET="aosp_cf_x86_64_only_phone-userdebug"
92+
TARGET_BASE="aosp_cf_x86_64_only_phone"
93+
elif [[ "$ARCH" == "arm64" ]]; then
94+
TARGET="aosp_cf_arm64_only_phone-userdebug"
95+
TARGET_BASE="aosp_cf_arm64_only_phone"
96+
else
97+
echo "Error: Unsupported architecture: $ARCH"
98+
exit 1
99+
fi
100+
101+
RELEASE_DIR="releases/$RELEASE_ID"
102+
mkdir -p "$RELEASE_DIR"
103+
104+
echo "Fetching Android artifacts to $RELEASE_DIR..."
105+
106+
echo "Fetching cvd-host_package.tar.gz..."
107+
fetch_artifact \
108+
-target=$TARGET \
109+
-build_id=$BUILD_ID \
110+
-artifact=cvd-host_package.tar.gz
111+
mv cvd-host_package.tar.gz "$RELEASE_DIR/"
112+
113+
IMG_ARTIFACT="${TARGET_BASE}-img-${BUILD_ID}.zip"
114+
echo "Fetching ${IMG_ARTIFACT}..."
115+
fetch_artifact \
116+
-target=$TARGET \
117+
-build_id=$BUILD_ID \
118+
-artifact=$IMG_ARTIFACT
119+
mv "$IMG_ARTIFACT" "$RELEASE_DIR/"
120+
121+
echo "Android artifacts downloaded to $RELEASE_DIR"
122+
43123
- name: Show releases
44124
run: find releases -type f|xargs ls -al
45125

@@ -55,7 +135,7 @@ jobs:
55135
runs-on: ubuntu-24.04
56136
needs: build
57137
steps:
58-
- name: Download exploit
138+
- name: Download release
59139
uses: actions/download-artifact@v4
60140
with:
61141
name: ${{inputs.releaseId}}

0 commit comments

Comments
 (0)