Skip to content

Commit 2041ab4

Browse files
probonopdTheAssassin
authored andcommitted
Add optional build-in-chroot step
For testing building in chroot; don't have to run this all the time later
1 parent 077ccc2 commit 2041ab4

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

.github/workflows/build.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,35 @@ jobs:
7272
signing-pubkey.asc
7373
runtime-*
7474
75+
build-in-chroot:
76+
runs-on: ubuntu-latest
77+
# if: false
78+
79+
strategy:
80+
fail-fast: false
81+
matrix:
82+
include:
83+
- alpine_arch: x86_64
84+
- alpine_arch: x86
85+
- alpine_arch: armhf
86+
- alpine_arch: aarch64
87+
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v3
91+
92+
- name: Get git hash
93+
run: |
94+
echo -n "https://github.com/${GITHUB_REPOSITORY}/commit/" > src/runtime/version
95+
git rev-parse --short HEAD | xargs >> src/runtime/version
96+
97+
- name: Build in chroot
98+
env:
99+
ALPINE_ARCH: ${{ matrix.alpine_arch }}
100+
run: |
101+
sudo apt-get -y install qemu-user-static
102+
chroot/chroot_build.sh
103+
75104
upload:
76105
name: Create release and upload artifacts
77106
runs-on: ubuntu-latest

chroot/chroot_build.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
set -ex
44

5-
if [ -z "${ARCHITECTURE}" ]; then
6-
echo "Usage: env ARCHITECTURE=<arch> $0"
5+
if [ -z "${ALPINE_ARCH}" ]; then
6+
echo "Usage: env ALPINE_ARCH=<arch> $0"
7+
echo "Example values: x86_64 x86 armhf aarch64"
78
exit 2
89
fi
910

@@ -28,10 +29,10 @@ cd "$tempdir"
2829
# Download and extract minimal Alpine system
2930
#############################################
3031

31-
wget "http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/${ARCHITECTURE}/alpine-minirootfs-3.17.2-${ARCHITECTURE}.tar.gz"
32+
wget "http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/${ALPINE_ARCH}/alpine-minirootfs-3.17.2-${ALPINE_ARCH}.tar.gz"
3233
mkdir -p ./miniroot
3334
cd ./miniroot
34-
sudo tar xf ../alpine-minirootfs-*-"${ARCHITECTURE}".tar.gz
35+
sudo tar xf ../alpine-minirootfs-*-"${ALPINE_ARCH}".tar.gz
3536
cd -
3637

3738
#############################################
@@ -50,14 +51,14 @@ sudo cp -p /etc/resolv.conf miniroot/etc/
5051
# Run build.sh in chroot
5152
#############################################
5253

53-
if [ "$ARCHITECTURE" = "x86" ] || [ "$ARCHITECTURE" = "x86_64" ]; then
54+
if [ "$ALPINE_ARCH" = "x86" ] || [ "$ALPINE_ARCH" = "x86_64" ]; then
5455
echo "Architecture is x86 or x86_64, hence not using qemu-arm-static"
5556
sudo cp "$repo_root_dir"/chroot/build.sh miniroot/build.sh && sudo chroot miniroot /bin/sh -ex /build.sh
56-
elif [ "$ARCHITECTURE" = "aarch64" ] ; then
57+
elif [ "$ALPINE_ARCH" = "aarch64" ] ; then
5758
echo "Architecture is aarch64, hence using qemu-aarch64-static"
5859
sudo cp "$(which qemu-aarch64-static)" miniroot/usr/bin
5960
sudo cp "$repo_root_dir"/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-aarch64-static /bin/sh -ex /build.sh
60-
elif [ "$ARCHITECTURE" = "armhf" ] ; then
61+
elif [ "$ALPINE_ARCH" = "armhf" ] ; then
6162
echo "Architecture is armhf, hence using qemu-arm-static"
6263
sudo cp "$(which qemu-arm-static)" miniroot/usr/bin
6364
sudo cp "$repo_root_dir"/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-arm-static /bin/sh -ex /build.sh
@@ -71,8 +72,15 @@ fi
7172
#############################################
7273

7374
# Use the same architecture names as https://github.com/AppImage/AppImageKit/releases/
74-
if [ "$ARCHITECTURE" = "x86" ] ; then ARCHITECTURE=i686 ; fi
75+
case "$ALPINE_ARCH" in
76+
x86)
77+
appimage_arch=i686
78+
;;
79+
*)
80+
appimage_arch="$ALPINE_ARCH"
81+
;;
82+
esac
7583

7684
cd "$repo_root_dir"
7785
mkdir -p ./out/
78-
sudo find "$tempdir"/miniroot/ -type f -executable -name 'runtime-fuse3' -exec cp {} "out/runtime-${ARCHITECTURE}" \;
86+
sudo find "$tempdir"/miniroot/ -type f -executable -name 'runtime-fuse3' -exec cp {} "out/runtime-${appimage_arch}" \;

0 commit comments

Comments
 (0)