3 # builds a Godot project with all its native export config options
4 ################################################################################
7 URI_PROJECT_SNAPSHOT=$1
9 [[ -z "$URI_PROJECT_SNAPSHOT" ]] && echo No URI_PROJECT_SNAPSHOT, exiting && exit 1
11 echo --------------------------------------------------------------------------------
12 echo Getting project - $URI_PROJECT_SNAPSHOT
15 DIR_PROJECT_ROOT=/project
18 rm -rf $DIR_PROJECT_ROOT/* && \
19 wget $URI_PROJECT_SNAPSHOT && \
20 tar -xf *.tar.gz -C $DIR_PROJECT_ROOT && \
23 DIR_PROJECT=$(find $DIR_PROJECT_ROOT -type f -name project.godot | sed 's|/project.godot||')
24 PROJECT_ID=$(echo $DIR_PROJECT | awk -F/ '{print $NF}')
26 echo Project directory - $DIR_PROJECT
28 ################################################################################
29 # execute project build
31 DIR_DEBUG=$DIR_BUILD/$PROJECT_ID/debug
32 DIR_RELEASE=$DIR_BUILD/$PROJECT_ID/release
34 GODOT="godot --headless --path $DIR_PROJECT"
35 EXPORT_PRESETS_CFG="$DIR_PROJECT/export_presets.cfg"
37 echo --------------------------------------------------------------------------------
38 echo Godot version - $($GODOT --headless --version)
40 # iterate through all build types present in config file
41 # if arg is given, override automated export discovery
46 EXPORT_NAMES=$(awk -F= '$1=="name"{print $2}' $EXPORT_PRESETS_CFG | sed 's/"//g')
49 for EXPORT_NAME in $EXPORT_NAMES
51 echo --------------------------------------------------------------------------------
52 echo Starting project build for export $EXPORT_NAME
54 # create build folders
55 [[ -d $DIR_RELEASE/$EXPORT_NAME ]] || mkdir -p $DIR_RELEASE/$EXPORT_NAME
56 [[ -d $DIR_DEBUG/$EXPORT_NAME ]] || mkdir -p $DIR_DEBUG/$EXPORT_NAME
58 # get export name from config file
59 EXPORT_FNAME=$(awk -vname=${EXPORT_NAME} -F= \
60 '$1=="name" && $2~name{f=1} f==1 && $1=="export_path"{print $2;exit}' \
61 $EXPORT_PRESETS_CFG | sed -e 's|^.*/||' -e 's/"//g')
63 DEBUG_BUILD_PATH=$DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
64 RELEASE_BUILD_PATH=$DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
67 # do debug and release builds!
68 echo $GODOT --export-debug "$EXPORT_NAME" $DEBUG_BUILD_PATH
69 $GODOT --export-debug "$EXPORT_NAME" $DEBUG_BUILD_PATH
71 echo $GODOT --export-release "$EXPORT_NAME" $RELEASE_BUILD_PATH
72 $GODOT --export-release "$EXPORT_NAME" $RELEASE_BUILD_PATH
75 # zip debug and release builds and shasum them
76 for DIR in $DIR_DEBUG $DIR_RELEASE
78 ZIP_PATH=$DIR/$EXPORT_NAME
80 echo Zipping $ZIP_PATH
81 zip -r $EXPORT_NAME $ZIP_PATH && mv *.zip $DIR
85 echo --------------------------------------------------------------------------------
86 echo Computing shasums for zip files
88 for DIR in $DIR_DEBUG $DIR_RELEASE
90 $(cd $DIR && sha1sum *.zip >shasum.txt)
93 echo SHASUM from $DIR -
95 find $DIR -type f -name shasum.txt | xargs cat