]> Untitled Git - godot-builder.git/blob - builder/godot-export.sh
Updated prod compose file
[godot-builder.git] / builder / godot-export.sh
1 #!/bin/bash
2
3 # builds a Godot project with all its native export config options
4 ################################################################################
5 # get project 
6
7 URI_PROJECT_SNAPSHOT=$1
8
9 [[ -z "$URI_PROJECT_SNAPSHOT" ]] && echo No URI_PROJECT_SNAPSHOT, exiting && exit 1
10
11 echo --------------------------------------------------------------------------------
12 echo Getting project - $URI_PROJECT_SNAPSHOT
13
14 DIR_BUILD=/build
15 DIR_PROJECT_ROOT=/project
16
17 # clean project root
18 rm -rf $DIR_PROJECT_ROOT/* && \
19     wget $URI_PROJECT_SNAPSHOT && \
20     tar -xf *.tar.gz -C $DIR_PROJECT_ROOT && \
21     rm *.tar.gz
22
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}')
25
26 echo Project directory - $DIR_PROJECT
27
28 ################################################################################
29 # execute project build
30
31 DIR_DEBUG=$DIR_BUILD/$PROJECT_ID/debug
32 DIR_RELEASE=$DIR_BUILD/$PROJECT_ID/release
33
34 GODOT="godot --headless --path $DIR_PROJECT"
35 EXPORT_PRESETS_CFG="$DIR_PROJECT/export_presets.cfg"
36
37 echo --------------------------------------------------------------------------------
38 echo Godot version - $($GODOT --headless --version)
39
40 # iterate through all build types present in config file
41 # if arg is given, override automated export discovery
42 if [[ -n "$2" ]]
43 then
44     EXPORT_NAMES=$2
45 else
46     EXPORT_NAMES=$(awk -F= '$1=="name"{print $2}' $EXPORT_PRESETS_CFG | sed 's/"//g')
47 fi
48
49 for EXPORT_NAME in $EXPORT_NAMES
50 do
51     echo --------------------------------------------------------------------------------
52     echo Starting project build for export $EXPORT_NAME
53
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
57
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')
62
63     DEBUG_BUILD_PATH=$DIR_DEBUG/$EXPORT_NAME/$EXPORT_FNAME
64     RELEASE_BUILD_PATH=$DIR_RELEASE/$EXPORT_NAME/$EXPORT_FNAME
65
66     ######
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
70
71     echo $GODOT --export-release "$EXPORT_NAME" $RELEASE_BUILD_PATH
72     $GODOT --export-release "$EXPORT_NAME" $RELEASE_BUILD_PATH
73
74     ######
75     # zip debug and release builds and shasum them
76     for DIR in $DIR_DEBUG $DIR_RELEASE
77     do
78         ZIP_PATH=$DIR/$EXPORT_NAME
79         echo
80         echo Zipping $ZIP_PATH
81         zip -r $EXPORT_NAME $ZIP_PATH && mv *.zip $DIR
82     done
83 done
84
85 echo --------------------------------------------------------------------------------
86 echo Computing shasums for zip files
87
88 for DIR in $DIR_DEBUG $DIR_RELEASE
89 do
90     $(cd $DIR && sha1sum *.zip >shasum.txt)
91
92     echo
93     echo SHASUM from $DIR -
94
95     find $DIR -type f -name shasum.txt | xargs cat
96 done
97