Skip to content

Commit b41e412

Browse files
committed
Add release scripts
1 parent 3d6b02a commit b41e412

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
all:
2+
@echo This makefile is for releasing cat-o-licious for various OSes.
3+
4+
release-macos:
5+
bash hack/release-macos.sh
6+
7+
release-ubuntu:
8+
bash hack/release-ubuntu.sh
9+
10+
release-windows:
11+
bash hack/release-windows.sh

hack/release-macos.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# release-macos.sh produces the cat-o-licious zip containing a mac bundle
3+
# with all required assets to for users to unpack and run the game.
4+
#
5+
# Requires a working Go compiler.
6+
#
7+
# Tested on macOS High Sierra version 10.13.6.
8+
9+
set -ex
10+
11+
VERSION=1.0
12+
RELEASE=release/cat-o-licious.app
13+
ICONSET=release/cat-o-licious.iconset
14+
ICON=assets/img/player_frame_3.png
15+
16+
rm -rf $ICONSET $RELEASE || true
17+
trap "rm -rf $ICONSET $RELEASE" EXIT
18+
19+
mkdir -p $ICONSET $RELEASE/Contents/{MacOS,Resources}
20+
21+
for SIZE in 16 32 64 128 256 512 1024
22+
do
23+
sips -z $SIZE $SIZE $ICON \
24+
--out $ICONSET/icon_${SIZE}x${SIZE}.png
25+
26+
[ $SIZE -eq 1024 ] && continue
27+
28+
SIZE2X=$((SIZE+SIZE))
29+
30+
sips -z $SIZE2X $SIZE2X $ICON --out $ICONSET/icon_${SIZE}x${SIZE}@2x.png
31+
done
32+
33+
iconutil --convert icns --output $RELEASE/Contents/Resources/icon.icns $ICONSET
34+
cp -r assets $RELEASE/Contents/Resources
35+
go build -tags static -o $RELEASE/Contents/Resources/cat-o-licious
36+
37+
cat << EOF > $RELEASE/Contents/Info.plist
38+
<?xml version="1.0" encoding="UTF-8"?>
39+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
40+
<plist version="1.0">
41+
<dict>
42+
<key>CFBundleExecutable</key>
43+
<string>cat-o-licious</string>
44+
<key>CFBundleIconFile</key>
45+
<string>icon</string>
46+
<key>CFBundleIdentifier</key>
47+
<string>com.github.fiorix.cat-o-licious</string>
48+
<key>NSHighResolutionCapable</key>
49+
<true/>
50+
<key>LSUIElement</key>
51+
<false/>
52+
</dict>
53+
</plist>
54+
EOF
55+
56+
cat << EOF > $RELEASE/Contents/MacOS/cat-o-licious
57+
#!/bin/bash
58+
cd \$(dirname \$0)/../Resources
59+
exec ./cat-o-licious
60+
EOF
61+
62+
chmod +x $RELEASE/Contents/MacOS/cat-o-licious
63+
64+
APP=$(basename $RELEASE)
65+
ZIP=$(basename $RELEASE | sed 's/\.app//g')-${VERSION}-macos.zip
66+
(cd release && zip -r $ZIP $APP)

hack/release-ubuntu.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
# release-ubuntu.sh produces a cat-o-licious debian package containing the
3+
# game binary and assets.
4+
#
5+
# Tested on Ubuntu 18.04 LTS, ubuntu/bionic64 on vagrant.
6+
7+
set -ex
8+
9+
VERSION=1.0-1
10+
RELEASE=release/cat-o-licious_${VERSION}
11+
12+
rm -rf pkgs $RELEASE || true
13+
trap "rm -rf pkgs $RELEASE" EXIT
14+
15+
PKGS=" \
16+
golang \
17+
libasound2-dev \
18+
libx11-dev \
19+
libxcursor-dev \
20+
libxext-dev \
21+
libxi-dev \
22+
libxinerama-dev \
23+
libxrandr-dev \
24+
libxss-dev \
25+
libxxf86vm-dev \
26+
zlib1g-dev \
27+
"
28+
29+
sudo apt-get install -y $PKGS
30+
31+
DEPS=""
32+
for PKG in $PKGS
33+
do
34+
[ "$(echo $PKG | grep -e '-dev')" == "" ] && continue
35+
36+
IFS=',' read -r -a array <<< $(dpkg -s $PKG | grep Depends: | sed 's/Depends: //g')
37+
for element in "${array[@]}"
38+
do
39+
[ "$(echo $element | grep -e '\(-dev\|-doc\)')" != "" ] && continue
40+
[ "$DEPS" != "" ] && DEPS="${DEPS},"
41+
DEPS="$DEPS $element"
42+
done
43+
done
44+
45+
mkdir -p $RELEASE/{DEBIAN,usr/bin,usr/games/cat-o-licious}
46+
cp -r assets $RELEASE/usr/games/cat-o-licious
47+
go build -tags static -o $RELEASE/usr/games/cat-o-licious/cat-o-licious
48+
49+
cat << EOF > $RELEASE/DEBIAN/control
50+
Package: cat-o-licious
51+
Version: $VERSION
52+
Section: base
53+
Priority: optional
54+
Architecture: amd64
55+
Depends: $DEPS
56+
Maintainer: Alexandre Fiori <[email protected]>
57+
Description: Simple cat game written in Go and SDL.
58+
See https://github.com/fiorix/cat-o-licious for details.
59+
EOF
60+
61+
cat << EOF > $RELEASE/usr/bin/cat-o-licious
62+
#!/bin/bash
63+
cd /usr/games/cat-o-licious
64+
exec ./cat-o-licious
65+
EOF
66+
67+
chmod +x $RELEASE/usr/bin/cat-o-licious
68+
69+
dpkg-deb --build $RELEASE

hack/release-windows.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# release-windows.sh produces the cat-o-licious zip containing an executable
3+
# file and all required assets to for users to unpack and run the game.
4+
#
5+
# Requires a working Go compiler, mingw64, git, and zip utilities.
6+
#
7+
# Tested on Windows 10.
8+
9+
set -ex
10+
11+
VERSION=1.0
12+
RELEASE=release/cat-o-licious-${VERSION}
13+
14+
rm -rf $RELEASE || true
15+
trap "rm -rf $RELEASE" EXIT
16+
17+
mkdir -p $RELEASE
18+
19+
cp -r assets $RELEASE
20+
go build -tags static -o $RELEASE/cat-o-licious.exe
21+
22+
APP=$(basename $RELEASE)
23+
ZIP=$APP-windows.zip
24+
(cd release && zip -r $ZIP $APP)

0 commit comments

Comments
 (0)