#!/usr/bin/env bash # Monta A Day in the Woods (passeio num mapa em laco de tempo, de ditam, MIT; JavaScript puro + jQuery 3.5.1 do repositorio, # Ludum Dare 47) a partir do commit 85b8f65 de github.com/ditam/loop-game. Nao ha etapa de build: o script baixa o tarball # (sha256), aplica a-day-in-the-woods/a-day-in-the-woods-fredygames.patch (tira o link da Google Fonts e usa a Dancing Script # auto-hospedada), junta a fonte (OFL-1.1, repositorio google/fonts no commit pinado) em fonts/ e empacota so o que o jogo usa, # num tar.gz deterministico. # # src/FredGames.Bundler/Builds/build-a-day-in-the-woods.sh # # Saida: artifacts/build/a-day-in-the-woods-85b8f65/a-day-in-the-woods-85b8f65-dist.tar.gz set -euo pipefail COMMIT=85b8f6523fb06d2aa26663055112de2c3daab064 SHA256=93e2048eb9ebc32e3218f687fc965ae9673a7e7d2008e880acec6eff70e4e25a GF=24ddc1f324cac5d9f5aedca126d298f56e3f1640 FONT=21808625578fe8d8cd10cb684be546dca077b27cd03a53a2f1ec11dc743c924c OFL=6f090277c00af96651ce6dbcc38ff1591047a3bffef486e80b6a32e8276a8201 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/a-day-in-the-woods-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tgz="$cache/a-day-in-the-woods-${COMMIT:0:7}.tar.gz" fetch() { # url sha256 destino [ -f "$3" ] || { curl -fsSL --retry 4 "$1" -o "$3.partial" && mv "$3.partial" "$3"; } echo "$2 $3" | shasum -a 256 -c - >/dev/null } mkdir -p "$cache" fetch "https://github.com/ditam/loop-game/archive/$COMMIT.tar.gz" "$SHA256" "$tgz" gfurl="https://raw.githubusercontent.com/google/fonts/$GF/ofl/dancingscript" fetch "$gfurl/DancingScript%5Bwght%5D.ttf" "$FONT" "$cache/DancingScript.ttf" fetch "$gfurl/OFL.txt" "$OFL" "$cache/OFL-dancingscript.txt" rm -rf "$out" mkdir -p "$out/tree" "$out/dist/fonts" tar -xzf "$tgz" -C "$out/tree" --strip-components 1 cd "$out/tree" patch -s -p1 < "$here/a-day-in-the-woods/a-day-in-the-woods-fredygames.patch" cp index.html styles.css constants.js init.js main.js tasks.js ui.js utils.js favicon.png "$out/dist/" cp -R assets ext "$out/dist/" cp "$cache/DancingScript.ttf" "$out/dist/fonts/" cp "$cache/OFL-dancingscript.txt" "$out/dist/fonts/OFL.txt" cp LICENSE "$out/dist/LICENSE.txt" if grep -rqE 'https?://' "$out/dist/index.html" "$out/dist/styles.css" "$out/dist/"*.js; then echo "Endereco externo" >&2; exit 1; fi find "$out/dist" -exec touch -t 202604090000 {} + ( cd "$out" && find dist -type f | LC_ALL=C sort > files.txt \ && COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n -cf - -T files.txt \ | gzip -n -9 > "a-day-in-the-woods-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) rm -rf "$out/tree" shasum -a 256 "$out/a-day-in-the-woods-${COMMIT:0:7}-dist.tar.gz"