Steam
How to deploy an app to Steam using codemagic.yaml
A sample project showcasing steps included in this guide is available in our Sample projects repository.
Prerequisites
- A Unity Plus or Pro license. Your license is used to activate Unity on the Codemagic build server so the project can be built. The license is returned automatically once the workflow completes.
- A Steam Partner account is required to publish to Steam.
Getting Started
SteamCMD is a tool used to upload builds to Steam. SteamCMD requires logging in to Steam and typically requires entering a Steam Guard code. There are two ways of solving this problem.
Disable Steam Guard for the account doing the Steam upload. This is not recommended, as it makes the Steam account less secure.
Use sentry files that are generated after logging in successfully to Steam. A Steam Guard code is not required when these sentry files are present on the build machine. Thus, we will save the sentry files as secure environment variables and place them at the correct path when the build starts.
Obtain the sentry files:
First, you need to install the SteamCMD.
mkdir ~/Steam
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_osx.tar.gz" | tar zxvf - -C ~/Steam
sudo apt-get install lib32gcc1
mkdir ~/Steam
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - -C ~/Steam
Then log into Steam using the following command, which will prompt for the Steam Guard code:
~/Steam/steamcmd.sh +login steam $STEAM_USERNAME $STEAM_PASSWORD
The ssfn file will be stored as ~/Steam/ssfn*******************
and the config.vdf file as ~/Steam/config/config.vdf
.
Configure environment variables
- Open your Codemagic app settings, and go to the Environment variables tab.
- Enter the desired Variable name, e.g.
SSFN_FILE_NAME
. - Enter the ssfn file name as Variable value.
- Enter the variable group name, e.g. steam. Click the button to create the group.
- Make sure the Secure option is selected.
- Click the Add button to add the variable.
- Enter another variable named
SSFN_FILE
and copy/paste thebase64
encoded value of the ssfn file. Follow the instructions for storing binary files. - Repeat the previous step to add the
config.vdf
file as a variable namedCONFIG_FILE
.
\n
of the encoded value before saving it to Codemagic.If you don’t want to install the SteamCMD on your local machine to obtain the sentry files, you can use Codemagic machines to do so and then copy them into your local machine using the secure copy command scp
.
scp -P <port> builder@X.X.X.X ~/Library/Application\ Support/ssfn******************* .
scp -P <port> builder@X.X.X.X ~/Library/Application\ Support/config/config.vdf .
Decode Sentry Files
In your workflow you need to base64 decode these binary files before they can be used:
- name: Decode Sentry files
script: |
echo $CONFIG_FILE | base64 --decode > steam/config.vdf
echo $SSFN_FILE | base64 --decode > steam/$SSFN_FILE_NAME
Copy Sentry files
And then copy them to the correct path, depending on the build machine type:
- name: Copy Sentry Files
script: |
mkdir -p ~/Library/Application\ Support/Steam/config
cp ~/clone/steam/$SSFN_FILE_NAME ~/Library/Application\ Support/Steam
cp ~/clone/steam/config.vdf ~/Library/Application\ Support/Steam/config
- name: Copy Sentry Files
script: |
mkdir -p ~/Steam/config
cp ~/clone/steam/$SSFN_FILE_NAME ~/Steam
cp ~/clone/steam/config.vdf ~/Steam/config
Upload to Steam
To configure the upload to Steam, edit the following two files in the project by adding your application’s AppID, DepotID, and branch name for deployment:
steam/app_build.vdf
"AppBuild"
{
"AppID" "2086870" // Your AppID
"Desc" "Published using Codemagic" // internal description for this build
"Preview" "0" // make this a preview build only, nothing is uploaded
"Local" "" // put content on local content server instead of uploading to Steam
"SetLive" "cm-release" // set this build live on cm-branch branch (Change this)
"ContentRoot" "..\win64" // content root folder relative to this script file
"BuildOutput" ".\output\" // put build cache and log files on different drive for better performance
"Depots"
{
// file mapping instructions for each depot are in separate script files
"2086871" "depot_build.vdf"
}
}
steam/depot_build.vdf
"DepotBuild"
{
// Set your assigned depot ID here
"DepotID" "2086871"
// include all files recursively
"FileMapping"
{
// This can be a full path, or a path relative to ContentRoot
"LocalPath" "*"
// This is a path relative to the install folder of your game
"DepotPath" "."
// If LocalPath contains wildcards, setting this means that all
// matching files within subdirectories of LocalPath will also
// be included.
"Recursive" "1"
}
}
Finally, use the following script in your codemagic.yaml
to publish your app to Steam:
scripts:
- name: Upload Build to Steam
script: |
~/Steam/steamcmd.sh +login $STEAM_USERNAME $STEAM_PASSWORD +run_app_build ~/clone/steam/app_build.vdf +quit