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