Build and bundle for multiple platforms from the command line

Here is an alternative version which is meant for copying builds to Steam SDK folder. I run this script to build, check that build is built properly, then run another script to do the actual uploading. You will need to become familiar with Steam’s tools for this to make use of this. Using something like this is a significant time saver.

#!/bin/bash
title=$(less game.project | grep "^title = " | cut -d "=" -f2 | sed -e 's/^[[:space:]]*//')
title_no_space=$(echo -e "${title}" | tr -d '[[:space:]]')
contentroot=C:/steamworks_sdk/sdk/tools/ContentBuilder/content/

echo "Project: ${title}"

if [ ! -f bob.jar ]
	then
		echo "Unable to find bob.jar. Download it from d.defold.com."
		exit 1
fi

bob() {
	java -jar bob.jar $@
}

build() {
	platform=$1
	shift 1
	rm -rf build
	bob --archive clean resolve build --build-report-html "build-report-${platform}.html" --texture-compression true --variant "release"  --platform "${platform}" -e a@a.com -u fake_token
}


bundle() {
	platform=$1
	echo "${platform}"
	shift 1
	bob --platform ${platform} --bundle-output build/${platform} $@ bundle
}

move_to_steam() {
	platform=$1
	if [ "${platform}" == "x86_64-darwin" ]
		then
			echo "${title_no_space}_${platform}"
			echo "Removing old ${contentroot}${title_no_space}_${platform}"
			rm -rf "${contentroot}${title_no_space}_${platform}"
			if ! cd build/${platform} ; then read -p "Build folder ${platform} not found! - Press Enter"; exit 1; fi
			mkdir -p "${contentroot}${title_no_space}_${platform}"
			cp -r * "${contentroot}${title_no_space}_${platform}"
			cd ../..	
	else
		echo "${title_no_space}_${platform}"
		echo "Removing old ${contentroot}${title_no_space}_${platform}"
		rm -rf "${contentroot}${title_no_space}_${platform}"
		if ! cd "build/${platform}/${title}" ; then read -p "Build folder ${platform} not found! - Press Enter"; exit 1; fi
		mkdir -p "${contentroot}${title_no_space}_${platform}"
		cp -r * "${contentroot}${title_no_space}_${platform}"
		cd ../../..
	fi
}

do_platform() {
	platform=$1
	shift 1
	echo -e "\n[Building ${platform}]"
	build ${platform}
	echo -e "\n[Bundling ${platform}]"
	bundle ${platform}
	echo -e "\n[Moving to Steam ${platform}]"
	move_to_steam ${platform}
	echo -e "\n[${platform} Done]"
}

# build / bundle / archive platforms

do_platform x86_64-win32
do_platform x86_64-linux
do_platform x86_64-darwin

# play some music to let us known it's done

ffplay fanfare.mp3 -autoexit -nodisp

echo -e "\n[All Done!! - You can now run upload_steam]"

read -p "Press enter to close"

To be clear the upload script looks similar to this, you’ll need to have all of the related files setup properly for it to work.

builder\steamcmd.exe +login username password +run_app_build ..\scripts\app_build_#.vdf
5 Likes