Skip to content

Commit

Permalink
modify pipeline to build Vulkan Experimental AppImage (#18)
Browse files Browse the repository at this point in the history
* modify pipeline to build development snapshot

https://play0ad.com/the-next-alpha-of-0-a-d-will-feature-an-experimental-vulkan-backend/

https://wildfiregames.com/forum/topic/104382-vulkan-new-graphics-api/


* workflow.sh: move build directory outside container to WORKSPACE

* make-appimage.sh: run container as user 0ad


* remove version file
  • Loading branch information
andy5995 authored Jan 17, 2023
1 parent 2b9e96f commit 7592be8
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 74 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,30 @@ on:
paths:
- '.github/workflows/appimage.yml'
- 'AppRun'
- 'version'
- 'workflow.sh'
pull_request:
branches: [ "trunk" ]
paths:
- '.github/workflows/appimage.yml'
- 'AppRun'
- 'version'
- 'workflow.sh'

jobs:
# Label of the container job
build-appimage:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
# Docker Hub image that `container-job` executes in
container: andy5995/0ad-build-env:bionic
runs-on: self-hosted
env:
ARCH: x86_64
WORKSPACE: ${{ github.workspace }}
VERSION: 0.0.27-svn-unstable
steps:
- uses: actions/checkout@v3
- name: Read version file
id: getversion
run: echo "version=$(cat $WORKSPACE/version)" >> $GITHUB_OUTPUT
- name: Run Workflow script
run: |
echo "VERSION=${{ steps.getversion.outputs.version }}" >> $GITHUB_ENV
# GIHUB_ENV was already passed when the service container started,
# so VERSION still needs to be exported before the script is run
export VERSION=${{ steps.getversion.outputs.version }}
ln -s /0ad-svn
$WORKSPACE/workflow.sh
- name: Release AppImage
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/tools/
/linuxdeploy-plugin-gtk.sh
/*.AppImage*
/0ad-svn
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ if desired:
## Build locally

You can build the appimage locally if you have docker installed. While in the
repo root, run:
repo root, to build the latest stable version, run:

./make-appimage.sh

or to build an svn snapshot:

VERSION=0.0.27-svn-unstable ./make-appimage.sh

To speed up the process, prior to running the above script, copy the source
and data archives (e.g., 0ad-0.0.26-alpha-unix-{build,data}.tar.xz) to the
repo root (otherwise they'll be downloaded during the script execution).

If choosing the svn version, the svn repository will be checked out, unless
you aleady have it in the repo root.
14 changes: 13 additions & 1 deletion make-appimage.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/bin/sh



export WORKSPACE="/0ad"
export VERSION=${VERSION:="0.0.26-alpha"}

echo "Version is set to '$VERSION'"
echo "use 'VERSION=<version> $0' to change it."
echo "Waiting 10 seconds to start, hit CTRL-C now to cancel..."

read -t 10

set -ev

docker run -it --rm \
-e VERSION=$(cat version) \
-u 0ad \-
-e VERSION=$VERSION \
-e ARCH=x86_64 \
-e WORKSPACE \
-e HOSTUSER=$USER \
Expand Down
1 change: 0 additions & 1 deletion version

This file was deleted.

177 changes: 116 additions & 61 deletions workflow.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#!/bin/bash
set -ev

export {CC=gcc-8,CXX=g++-8}

# This var is set in the the docker container
if [ -z "DOCKER_0AD_BUILD" ]; then
@echo "This script is intended to be run inside a docker container."
@echo "(hint: andy5995/0ad-build-env:bionic)"
exit 1
fi

if [ -z "$VERSION" ]; then
echo "VERSION must be set."
exit 1
Expand All @@ -17,32 +26,43 @@ if [ ! -e "AppRun" ]; then
fi

MINISIGN_VERSION="0.10"
TOOLS_DIR="/tools"

if [ -z "$TOOLS_DIR" ];
then TOOLS_DIR="/tools"
fi

if [ ! -d "$TOOLS_DIR" ]; then
mkdir -v -p "$TOOLS_DIR"
fi

MINISIGN_PATH="$TOOLS_DIR/minisign-$MINISIGN_VERSION-linux/x86_64/minisign"
URI=https://releases.wildfiregames.com

BUILD_DIR="$WORKSPACE/build"
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
mkdir -v -p $BUILD_DIR

if [ "$VERSION" != "0.0.27-svn-unstable" ]; then
ABS_PATH_SRC_ROOT="$WORKSPACE/0ad-$VERSION"
else
ABS_PATH_SRC_ROOT="$WORKSPACE/0ad-svn"
fi

export -p

# 0ad signing keys
# key for a26
MINISIGN_KEY=RWTWLbO12+ig3lUExIor3xd6DdZaYFEozn8Bu8nIzY3ImuRYQszIQyyy
# key for a25
# MINISIGN_KEY=RWT0hFWv57I2RFoJwLVjxEr44JOq/RkEx1oT0IA3PPPICnSF7HFKW1CT

linux_deploy_version="1-alpha-20220822-1"

mkdir -m 777 -p $TOOLS_DIR
cd "$TOOLS_DIR"

if [ ! -r "linuxdeploy-$ARCH.AppImage" ]; then
curl -LO https://github.com/linuxdeploy/linuxdeploy/releases/download/$linux_deploy_version/linuxdeploy-$ARCH.AppImage
chmod +x linuxdeploy-$ARCH.AppImage
./linuxdeploy-$ARCH.AppImage --appimage-extract
fi

if [ ! -r minisign-${MINISIGN_VERSION}-linux.tar.gz ]; then
curl -LO https://github.com/jedisct1/minisign/releases/download/${MINISIGN_VERSION}/minisign-${MINISIGN_VERSION}-linux.tar.gz
curl -LO https://github.com/jedisct1/minisign/releases/download/${MINISIGN_VERSION}/minisign-${MINISIGN_VERSION}-linux.tar.gz.minisig
fi
tar xf minisign-$MINISIGN_VERSION-linux.tar.gz
tar xf minisign-$MINISIGN_VERSION-linux.tar.gz -C "$TOOLS_DIR"
$MINISIGN_PATH -Vm minisign-$MINISIGN_VERSION-linux.tar.gz -P RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3

cd "$WORKSPACE"
Expand All @@ -55,59 +75,78 @@ if [ ! -r linuxdeploy-plugin-gtk.sh ]; then
chmod +x linuxdeploy-plugin-gtk.sh
fi

# Get, check, and extract source
source=0ad-$VERSION-unix-build.tar.xz
source_sum=$source.sha1sum
if [ "$USER" != "0ad" -]; then
run_cmd="su 0ad --command"
else
run_cmd="/bin/bash -c"
fi

for file in $source $source_sum; do
if [ ! -r "$file" ]; then
curl -LO "$URI/$file"
fi
done
if [ "$VERSION" != "0.0.27-svn-unstable" ]; then
# Get, check, and extract source
source=0ad-$VERSION-unix-build.tar.xz
source_sum=$source.sha1sum

if [ -n "${URI##*/rc*}" ]; then
if [ ! -r $URI/$source.minisig ]; then
curl -LO $URI/$source.minisig
for file in $source $source_sum; do
if [ ! -r "$file" ]; then
curl -LO "$URI/$file"
fi
done

if [ -n "${URI##*/rc*}" ]; then
if [ ! -r $URI/$source.minisig ]; then
curl -LO $URI/$source.minisig
fi
$MINISIGN_PATH -Vm $source -P $MINISIGN_KEY
fi
sha1sum -c $source_sum
$run_cmd "tar xJf $WORKSPACE/$source"
else
if [ ! -r "0ad-svn" ]; then
svn co https://svn.wildfiregames.com/public/ps/trunk/ 0ad-svn
else
cd 0ad-svn
svn up
fi
$MINISIGN_PATH -Vm $source -P $MINISIGN_KEY
fi
sha1sum -c $source_sum

BUILD_DIR="/build"
mkdir -m 777 -p $BUILD_DIR
cd $BUILD_DIR
su 0ad --command "tar xJf $WORKSPACE/$source"

# name: build
cd 0ad-$VERSION/build/workspaces
su 0ad --command "./update-workspaces.sh \
-j$(nproc) && \
if [ ! -r "$ABS_PATH_SRC_ROOT/source/main.cpp" ]; then
echo "set the source root!"
exit 1
fi
cd "$ABS_PATH_SRC_ROOT/build/workspaces"

$run_cmd "ionice -c3 nice -n 19 \
./update-workspaces.sh \
-j$(nproc) && \
make config=release -C gcc -j$(nproc)"

# name: prepare AppDir
cd $WORKSPACE
# Get, check, and extract data
data=0ad-$VERSION-unix-data.tar.xz
data_sum=$data.sha1sum
echo "Getting data and extracting archive..."
for file in $data $data_sum; do
if [ ! -r "$file" ]; then
curl -LO "$URI/$file"
fi
done

if [ -n "${URI##*/rc*}" ] && [ ! -r $URI/$data.minisig ]; then
curl -LO $URI/$data.minisig
fi
if [ "$VERSION" != "0.0.27-svn-unstable" ]; then
# Get, check, and extract data
data=0ad-$VERSION-unix-data.tar.xz
data_sum=$data.sha1sum
echo "Getting data and extracting archive..."
for file in $data $data_sum; do
if [ ! -r "$file" ]; then
curl -LO "$URI/$file"
fi
done

$MINISIGN_PATH -Vm $data -P $MINISIGN_KEY
sha1sum -c $data_sum
su 0ad --command "tar xJf $data -C $BUILD_DIR"
if [ -n "${URI##*/rc*}" ] && [ ! -r $URI/$data.minisig ]; then
curl -LO $URI/$data.minisig
fi

ABS_PATH_SRC_ROOT="$BUILD_DIR/0ad-$VERSION"
if [ ! -r "$ABS_PATH_SRC_ROOT/source/main.cpp" ]; then
echo "set the source root!"
exit 1
$MINISIGN_PATH -Vm $data -P $MINISIGN_KEY
sha1sum -c $data_sum
$run_cmd "tar xJf $data"
else
if [ ! -r 0ad-spirv.zip ]; then
# see https://wildfiregames.com/forum/topic/104382-vulkan-new-graphics-api/
curl -LO https://releases.wildfiregames.com/rc/0ad-spirv.zip
# Later this will get extracted directly into the AppDir
fi
fi

APPDIR="$BUILD_DIR/AppDir"
Expand Down Expand Up @@ -137,12 +176,26 @@ mkdir -p "$APPDIR/usr/data/config"
cp -a binaries/data/config/default.cfg $APPDIR/usr/data/config
cp -a binaries/data/l10n $APPDIR/usr/data
cp -a binaries/data/tools $APPDIR/usr/data # for Atlas
cp -a binaries/data/mods $APPDIR/usr/data
mkdir -p $APPDIR/usr/data/mods
cp -a binaries/data/mods/mod $APPDIR/usr/data/mods
if [ "$VERSION" = "0.0.27-svn-unstable" ]; then
mkdir -p $APPDIR/usr/data/mods/public
$run_cmd "binaries/system/pyrogenesis -writableRoot \
-mod=mod \
-archivebuild=binaries/data/mods/public \
-archivebuild-output=$APPDIR/usr/data/mods/public/public.zip \
-archivebuild-compress" \
&& test -f "$APPDIR/usr/data/mods/public/public.zip"
cp -a binaries/data/mods/public/mod.json $APPDIR/usr/data/mods/public
unzip "$WORKSPACE/0ad-spirv.zip" -d $APPDIR/usr/data/mods/0ad-spirv
else
cp -a binaries/data/mods/public $APPDIR/usr/data/mods
fi
# Create the image
cd "$WORKSPACE"

DEPLOY_GTK_VERSION=3 # Variable used by gtk plugin
$TOOLS_DIR/squashfs-root/AppRun -d $APPDIR/usr/share/applications/0ad.desktop \
ionice -c3 $TOOLS_DIR/squashfs-root/AppRun -d $APPDIR/usr/share/applications/0ad.desktop \
--icon-file=$APPDIR/usr/share/pixmaps/0ad.png \
--icon-filename=0ad \
--executable $APPDIR/usr/bin/pyrogenesis \
Expand All @@ -156,10 +209,12 @@ mv 0_A.D.-$VERSION-$ARCH.AppImage 0ad-$VERSION-$DATE_STR-$ARCH.AppImage
echo "Generating sha1sum..."
sha1sum 0ad-$VERSION-$DATE_STR-$ARCH.AppImage > 0ad-$VERSION-$DATE_STR-$ARCH.AppImage.sha1sum

if [ -n "$HOSTUSER" ]; then
for file in 0ad*AppImage 0ad*.xz 0ad*.minisig 0ad*.sha1sum linuxdeploy-plugin-gtk.sh; do
chown $HOSTUSER "$file"
done
fi
# This doesn't work because there is probably no such
# user inside the container.
#if [ -n "$HOSTUSER" ]; then
#for file in 0ad*AppImage 0ad*.xz 0ad*.minisig 0ad*.sha1sum linuxdeploy-plugin-gtk.sh; do
#chown $HOSTUSER "$file"
#done
#fi

exit 0

0 comments on commit 7592be8

Please sign in to comment.