Skip to content

Commit 5887bc1

Browse files
committed
Integrate release scripts and CI into base repo
1 parent 8679e9f commit 5887bc1

File tree

7 files changed

+396
-0
lines changed

7 files changed

+396
-0
lines changed

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: (Pre)release builds
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/release.yml
7+
branches:
8+
- "release/***"
9+
tags:
10+
- "v*"
11+
pull_request:
12+
paths:
13+
- .github/workflows/release.yml
14+
workflow_dispatch:
15+
16+
jobs:
17+
package:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- name: AppImage
23+
arch: x86_64
24+
runs_on: ubuntu-22.04
25+
apt_deps: libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev zlib1g-dev
26+
build_script: nix/build-appimage.sh
27+
upload_pattern: Blue_Nebula*.AppImage*
28+
29+
- name: Windows zipball (cross build)
30+
arch: x86_64
31+
runs_on: ubuntu-latest
32+
apt_deps: mingw-w64 g++-mingw-w64
33+
build_script: win/build-archive.sh
34+
upload_pattern: blue*.zip
35+
36+
- name: Windows installer (cross build)
37+
arch: x86_64
38+
runs_on: ubuntu-latest
39+
apt_deps: mingw-w64 g++-mingw-w64 nsis
40+
build_script: win/build-installer.sh
41+
upload_pattern: blue*win64.exe
42+
43+
- name: macOS zipball (universal)
44+
arch: x86_64
45+
runs_on: macos-14
46+
brew_deps: coreutils sdl2 sdl2_image sdl2_mixer glew
47+
build_script: mac/build-archive.sh
48+
upload_pattern: blue*.zip
49+
50+
name: ${{ matrix.name }} ${{ matrix.arch }}
51+
runs-on: ${{ matrix.runs_on }}
52+
env:
53+
ARCH: ${{ matrix.arch }}
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
lfs: true
58+
- name: Install dependencies with apt
59+
if: ${{ matrix.apt_deps }}
60+
run: sudo apt-get install -y ${{ matrix.apt_deps }}
61+
- name: Install dependencies with brew
62+
if: ${{ matrix.brew_deps }}
63+
run: brew install ${{ matrix.brew_deps }}
64+
- name: Build ${{ matrix.name }}
65+
run: bash ${{ matrix.build_script }}
66+
- name: Archive artifacts
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: ${{ matrix.name }} ${{ matrix.arch }}
70+
path: ${{ matrix.upload_pattern }}
71+
72+
upload:
73+
name: Create release and upload artifacts
74+
needs:
75+
- package
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Download artifacts
79+
uses: actions/download-artifact@v3
80+
- name: Inspect directory after downloading artifacts
81+
run: ls -alFR
82+
- name: Create release and upload artifacts
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
run: |
86+
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
87+
chmod +x pyuploadtool-x86_64.AppImage
88+
./pyuploadtool-x86_64.AppImage **/Blue*.AppImage* **/blue*.zip **/blue*win64.exe

release/LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

release/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Blue Nebula releases
2+
3+
This repository provides all resources necessary to deploy release builds of Blue Nebula for the supported platforms (as of writing, Linux, macOS and Windows).
4+
5+
### --> Check out our [download page](https://github.com/blue-nebula/base/releases/latest) <--
6+
7+
8+
## Licensing
9+
10+
The files inside this repository are, unless noted otherwise, "licensed" under the terms of the [Unlicense](https://unlicense.org/). Please see [`LICENSE.txt`](LICENSE.txt) for more information.
11+
12+
The software bundled by these scripts is subject to copyright itself and is not covered by `LICENSE.txt`. Please refer to the authors for more information.

release/mac/build-archive.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#! /bin/bash
2+
3+
set -euxo pipefail
4+
5+
case "$ARCH" in
6+
x86_64|amd64|win64)
7+
export ARCH="x86_64"
8+
;;
9+
*)
10+
echo "Error: \$ARCH unset, please export ARCH=... (e.g., x86_64)"
11+
exit 1
12+
;;
13+
esac
14+
15+
# use RAM disk if possible
16+
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
17+
TEMP_BASE=/dev/shm
18+
fi
19+
20+
# use RAM disk if possible (e.g., while cross-compiling)
21+
# RAM disk is not available on mac, therefore we use the system default there
22+
if [[ "${TEMP_BASE:-}" != "" ]]; then
23+
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" blue-nebula-build-XXXXXX)
24+
else
25+
BUILD_DIR=$(mktemp -d blue-nebula-build-XXXXXX)
26+
fi
27+
28+
cleanup () {
29+
if [ -d "$BUILD_DIR" ]; then
30+
rm -rf "$BUILD_DIR"
31+
fi
32+
}
33+
34+
trap cleanup EXIT
35+
36+
OLD_CWD="$(realpath .)"
37+
38+
pushd "$BUILD_DIR"
39+
40+
# first, we need to build macdylibbundler
41+
git clone https://github.com/auriamg/macdylibbundler
42+
pushd macdylibbundler
43+
44+
make -j7
45+
46+
# it just creates the binary here, so let's just add it to $PATH to be able to access it conveniently
47+
PATH="$(realpath .):$PATH"
48+
export PATH
49+
50+
popd
51+
52+
# now let's build the binaries and install them into the usual FHS-style directory tree
53+
git clone --recursive https://github.com/blue-nebula/base.git
54+
55+
cd base
56+
57+
mkdir build
58+
cd build
59+
60+
# allow overwriting for cross compilation
61+
export CMAKE="${CMAKE:-cmake}"
62+
63+
if type nproc &>/dev/null; then
64+
procs=$(nproc --ignore=1)
65+
else
66+
# macos doesn't have nproc, and nprocs does not support ignore
67+
procs=$(nprocs)
68+
fi
69+
70+
# build universal binaries
71+
export CMAKE_OSX_ARCHITECTURES="arm64;x86_64"
72+
73+
# we do not need any prefix in our zip archive, so we just write /
74+
"$CMAKE" .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/
75+
76+
make preinstall -j"$procs"
77+
78+
# this is the name of the directory we will "install" to, as well as the created zip file's name
79+
DESTDIR=blue-nebula-"$(git describe --tags)"-macos-"$ARCH"
80+
81+
# install everything into a temporary FHS-style tree which we will later zip manually after having collected the deps
82+
make install DESTDIR="$DESTDIR" &>install.log
83+
84+
# now, we can use macdylibbundler to collect the deps
85+
# NOTE: THIS STEP DOES ONLY WORK ON MACOS PROPERLY
86+
# we could also patch the tool more (and provide search paths via -s for the osxcross libs), but it's easier to just run it on macOS
87+
dylibbundler -od -b -x "$DESTDIR"/bin/blue-nebula_osx -d "$DESTDIR"/lib/
88+
89+
# copy the license files from the bundled Windows libs dir... to be on the safe side
90+
cp ../src/bundled-libs/"${ARCH}"-w64-mingw32/lib/LICENSE* "$DESTDIR"/lib/
91+
92+
# let's build the final zip archive
93+
zip -r "$DESTDIR".zip "$DESTDIR"/* &>zip.log
94+
95+
# move the build product back into the filesystem
96+
mv ./*.zip "$OLD_CWD"

release/nix/build-appimage.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#! /bin/bash
2+
3+
set -euxo pipefail
4+
5+
if [ "$ARCH" == "" ]; then
6+
ARCH=$(uname -m)
7+
echo "Warning: \$ARCH unset, guessing as $ARCH"
8+
fi
9+
10+
# use RAM disk if possible
11+
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
12+
TEMP_BASE=/dev/shm
13+
else
14+
TEMP_BASE=/tmp
15+
fi
16+
17+
# save one processor core if possible for other stuff on dev machines
18+
if [ "$CI" == "" ]; then
19+
NPROC=$(nproc --ignore=1)
20+
else
21+
NPROC=$(nproc)
22+
fi
23+
24+
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" blue-nebula-build-XXXXXX)
25+
26+
cleanup () {
27+
if [ -d "$BUILD_DIR" ]; then
28+
rm -rf "$BUILD_DIR"
29+
fi
30+
}
31+
32+
trap cleanup EXIT
33+
34+
# store repo root as variable
35+
OLD_CWD="$(readlink -f .)"
36+
37+
pushd "$BUILD_DIR"
38+
39+
git clone --recursive https://github.com/blue-nebula/base.git
40+
41+
cd base
42+
43+
mkdir build
44+
cd build
45+
46+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
47+
48+
make -j"$NPROC"
49+
50+
make install DESTDIR=AppDir &>install.log
51+
52+
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-"$ARCH".AppImage
53+
54+
chmod +x linuxdeploy*.AppImage
55+
56+
# configure AppImageUpdate
57+
export UPD_INFO="gh-releases-zsync|blue-nebula|release|continuous|Blue_Nebula-*$ARCH.AppImage.zsync"
58+
VERSION=$(git describe --tags)
59+
export VERSION
60+
./linuxdeploy-"$ARCH".AppImage --appdir AppDir --output appimage
61+
62+
mv Blue_Nebula*.AppImage* "$OLD_CWD"

release/win/build-archive.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#! /bin/bash
2+
3+
set -euxo pipefail
4+
5+
case "$ARCH" in
6+
x86_64|amd64|win64)
7+
export ARCH="x86_64"
8+
;;
9+
*)
10+
echo "Error: \$ARCH unset, please export ARCH=... (e.g., x86_64)"
11+
exit 1
12+
;;
13+
esac
14+
15+
# use RAM disk if possible
16+
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
17+
TEMP_BASE=/dev/shm
18+
else
19+
TEMP_BASE=/tmp
20+
fi
21+
22+
# save one processor core if possible for other stuff on dev machines
23+
if [ "$CI" == "" ]; then
24+
NPROC=$(nproc --ignore=1)
25+
else
26+
NPROC=$(nproc)
27+
fi
28+
29+
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" blue-nebula-build-XXXXXX)
30+
31+
cleanup () {
32+
if [ -d "$BUILD_DIR" ]; then
33+
rm -rf "$BUILD_DIR"
34+
fi
35+
}
36+
37+
trap cleanup EXIT
38+
39+
# store repo root as variable
40+
OLD_CWD="$(readlink -f .)"
41+
42+
pushd "$BUILD_DIR"
43+
44+
git clone --recursive https://github.com/blue-nebula/base.git
45+
46+
cd base
47+
48+
mkdir build
49+
cd build
50+
51+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../ci/"$ARCH"-w64-mingw32.cmake
52+
53+
make preinstall -j"$NPROC"
54+
55+
cpack -G ZIP
56+
57+
mv ./*.zip "$OLD_CWD"

0 commit comments

Comments
 (0)