Skip to content

Commit c58bae7

Browse files
committed
Switch to GitHub actions and linuxdeploy
1 parent 10e85c0 commit c58bae7

File tree

9 files changed

+206
-100
lines changed

9 files changed

+206
-100
lines changed

.github/workflows/main.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
appimage-x86_64:
7+
name: AppImage x86_64
8+
runs-on: ubuntu-16.04
9+
env:
10+
ARCH: x86_64
11+
DIST: xenial
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
submodules: recursive
16+
- name: Build AppImage in Docker
17+
run: bash -ex ci/build-in-docker.sh
18+
- name: Archive artifacts
19+
uses: actions/upload-artifact@v2
20+
with:
21+
name: AppImage x86_64
22+
path: AppImageUpdate*.AppImage*
23+
24+
appimage-i386:
25+
name: AppImage i386
26+
runs-on: ubuntu-16.04
27+
env:
28+
ARCH: i386
29+
DIST: xenial
30+
steps:
31+
- uses: actions/checkout@v2
32+
with:
33+
submodules: recursive
34+
- name: Build AppImage in Docker
35+
run: bash -ex ci/build-in-docker.sh
36+
- name: Archive artifacts
37+
uses: actions/upload-artifact@v2
38+
with:
39+
name: AppImage i386
40+
path: AppImageUpdate*.AppImage*
41+
42+
upload:
43+
name: Create release and upload artifacts
44+
needs:
45+
- appimage-x86_64
46+
- appimage-i386
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Download artifacts
50+
uses: actions/download-artifact@v2
51+
- name: Inspect directory after downloading artifacts
52+
run: ls -alFR
53+
- name: Create release and upload artifacts
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
58+
chmod +x pyuploadtool-x86_64.AppImage
59+
./pyuploadtool-x86_64.AppImage **/AppImageUpdate*.AppImage*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ cmake-build-*/
77
*.bak
88
zsync2*.txt
99
*.AppImage*
10+
*.swp

ci/Dockerfile.xenial-i386

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM i386/ubuntu:xenial
2+
3+
ENV ARCH=i386
4+
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
gcc g++ clang make cmake libxpm-dev git libcurl4-openssl-dev wget zlib1g-dev libc6-dev bsdmainutils
8+
9+
RUN wget https://artifacts.assassinate-you.net/prebuilt-cmake/continuous/cmake-v3.19.1-ubuntu_xenial-i386.tar.gz -O- | \
10+
tar xz -C /usr/local --strip-components=1
11+
12+
ARG UID
13+
RUN adduser --system --group --uid "$UID" build
14+
USER build
15+
16+
ENV APPIMAGE_EXTRACT_AND_RUN=1

ci/Dockerfile.xenial-x86_64

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ubuntu:xenial
2+
3+
ENV ARCH=x86_64
4+
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
gcc g++ clang make cmake libxpm-dev git libcurl4-openssl-dev wget zlib1g-dev libc6-dev bsdmainutils
8+
9+
RUN wget https://artifacts.assassinate-you.net/prebuilt-cmake/continuous/cmake-v3.19.1-ubuntu_xenial-x86_64.tar.gz -O- | \
10+
tar xz -C /usr/local --strip-components=1
11+
12+
ARG UID
13+
RUN adduser --system --group --uid "$UID" build
14+
USER build
15+
16+
ENV APPIMAGE_EXTRACT_AND_RUN=1

ci/build-appimages.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#! /bin/bash
2+
3+
set -x
4+
set -e
5+
6+
if [ "$ARCH" == "" ]; then
7+
echo "Usage: env ARCH=... bash $0"
8+
exit 2
9+
fi
10+
11+
# use RAM disk if possible
12+
# in Docker, /dev/shm is typically mounted with noexec, so one can't run executable stored in there
13+
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
14+
TEMP_BASE=/dev/shm
15+
else
16+
TEMP_BASE=/tmp
17+
fi
18+
19+
BUILD_DIR="$(mktemp -d -p "$TEMP_BASE" zsync2-build-XXXXXX)"
20+
21+
cleanup () {
22+
if [ -d "$BUILD_DIR" ]; then
23+
rm -rf "$BUILD_DIR"
24+
fi
25+
}
26+
27+
trap cleanup EXIT
28+
29+
# store repo root as variable
30+
REPO_ROOT="$(readlink -f "$(dirname "$(dirname "$0")")")"
31+
OLD_CWD="$(readlink -f .)"
32+
33+
pushd "$BUILD_DIR"
34+
35+
cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo
36+
37+
# create AppDir
38+
mkdir -p AppDir
39+
40+
# now, compile and install to AppDir
41+
make -j"$(nproc)"
42+
make install DESTDIR=AppDir
43+
44+
# get linuxdeploy
45+
wget https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-"$ARCH".AppImage
46+
chmod +x linuxdeploy*.AppImage
47+
48+
patch_appimage() {
49+
while [[ "$1" != "" ]]; do
50+
dd if=/dev/zero of="$1" conv=notrunc bs=1 count=3 seek=8
51+
shift
52+
done
53+
}
54+
patch_appimage linuxdeploy-"$ARCH".AppImage
55+
56+
# determine Git commit ID
57+
# linuxdeploy uses this for naming the file
58+
export VERSION=$(cd "$REPO_ROOT" && git rev-parse --short HEAD)
59+
60+
# prepend GitHub actions run number if possible
61+
if [ "$GITHUB_RUN_NUMBER" != "" ]; then
62+
export VERSION="$GITHUB_RUN_NUMBER-$VERSION"
63+
fi
64+
65+
for app in zsync2 zsyncmake2; do
66+
# prepare for next app
67+
pushd AppDir
68+
rm AppRun *.desktop || true
69+
popd
70+
71+
# prepare AppDir with linuxdeploy and create AppImage
72+
export UPD_INFO="gh-releases-zsync|AppImage|zsync2|continuous|$app-*x86_64.AppImage.zsync"
73+
74+
./linuxdeploy-"$ARCH".AppImage --appdir AppDir \
75+
-d "$REPO_ROOT"/resources/"$app".desktop \
76+
-i "$REPO_ROOT"/resources/zsync2.svg \
77+
--output appimage
78+
done
79+
80+
# move AppImages to old cwd
81+
mv zsync*2*.AppImage* "$OLD_CWD"/
82+
83+
popd

ci/build-in-docker.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#! /bin/bash
2+
3+
if [[ "$DIST" == "" ]] || [[ "$ARCH" == "" ]]; then
4+
echo "Usage: env ARCH=... DIST=... bash $0"
5+
exit 1
6+
fi
7+
8+
set -e
9+
set -x
10+
11+
cwd="$PWD"
12+
repo_root="$(readlink -f "$(dirname "$0")"/..)"
13+
14+
# needed to keep user ID in and outside Docker in sync to be able to write to workspace directory
15+
uid="$(id -u)"
16+
image=zsync2-build:"$DIST"-"$ARCH"-uid"$uid"
17+
dockerfile=Dockerfile."$DIST"-"$ARCH"
18+
19+
if [ ! -f "$repo_root"/ci/"$dockerfile" ]; then
20+
echo "Error: $dockerfile could not be found"
21+
exit 1
22+
fi
23+
24+
# building local image to "cache" installed dependencies for subsequent builds
25+
docker build -t "$image" -f "$repo_root"/ci/"$dockerfile" --build-arg UID="$uid" "$repo_root"/ci
26+
27+
# mount workspace read-only, trying to make sure the build doesn't ever touch the source code files
28+
# of course, this only works reliably if you don't run this script from that directory
29+
# but it's still not the worst idea to do so
30+
docker run --rm -i -e CI=1 -e GITHUB_RUN_NUMBER -v "$repo_root":/ws:ro -v "$cwd":/out "$image" \
31+
bash -xec 'cd /out && bash -xe /ws/ci/build-appimages.sh'

resources/bootstrap-container.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

resources/build-appimages.sh

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)