#!/usr/bin/env bash set -euo pipefail if [[ $# -ne 3 ]]; then echo "Usage: $0 /path/to/server-linux-x86_64 GAME_VERSION GAME_COMMIT" >&2 exit 2 fi source_dir="${1%/}" game_version="$2" game_commit="${3,,}" repository_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" destination_dir="${repository_dir}/dist" licenses_dir="${destination_dir}/licenses" packaging_commit="$(git -C "${repository_dir}" rev-parse HEAD)" if ! git -C "${repository_dir}" diff --quiet \ || ! git -C "${repository_dir}" diff --cached --quiet; then echo "Commit dedicated packaging changes before staging a release." >&2 exit 1 fi if [[ ! "${game_version}" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then echo "GAME_VERSION must contain only letters, numbers, dots, underscores, or hyphens." >&2 exit 2 fi if [[ ! "${game_commit}" =~ ^[0-9a-f]{40}$ ]]; then echo "GAME_COMMIT must be the full 40-character Git commit." >&2 exit 2 fi if [[ ! "${packaging_commit}" =~ ^[0-9a-f]{40}$ ]]; then echo "Could not resolve the dedicated packaging Git commit." >&2 exit 2 fi for filename in NETfishingServer.x86_64 NETfishingServer.pck; do if [[ ! -f "${source_dir}/${filename}" ]]; then echo "Missing ${source_dir}/${filename}" >&2 exit 1 fi done install -m 0755 "${source_dir}/NETfishingServer.x86_64" \ "${destination_dir}/NETfishingServer.x86_64" install -m 0644 "${source_dir}/NETfishingServer.pck" \ "${destination_dir}/NETfishingServer.pck" rm -rf -- "${licenses_dir}" install -d -m 0755 "${licenses_dir}" install -m 0644 "${repository_dir}/LICENSE" \ "${licenses_dir}/GPL-3.0-or-later.txt" install -m 0644 "${repository_dir}/ASSET-LICENSE.md" \ "${licenses_dir}/ASSET-LICENSE.md" install -m 0644 "${repository_dir}/THIRD-PARTY-NOTICES.md" \ "${licenses_dir}/THIRD-PARTY-NOTICES.md" install -m 0644 "${repository_dir}/TRADEMARKS.md" \ "${licenses_dir}/TRADEMARKS.md" install -m 0644 "${repository_dir}/CREDITS.md" \ "${licenses_dir}/CREDITS.md" cd -- "${destination_dir}" executable_sha256="$(sha256sum NETfishingServer.x86_64 | awk '{print $1}')" pck_sha256="$(sha256sum NETfishingServer.pck | awk '{print $1}')" apply_umask="$(umask)" umask 022 printf '%s\n' \ "manifest_version=2" \ "game_version=${game_version}" \ "game_commit=${game_commit}" \ "packaging_commit=${packaging_commit}" \ "export_preset=Linux Dedicated Server" \ "platform=linux-x86_64" \ "executable_sha256=${executable_sha256}" \ "pck_sha256=${pck_sha256}" \ > BUILD_INFO cat >SOURCE-CODE.md < SHA256SUMS echo "Staged dedicated server build in ${destination_dir}"