-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminal-deploy.bash
executable file
·177 lines (169 loc) · 6.88 KB
/
terminal-deploy.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
echo
echo "88,dPYba,,adPYba, ,adPPYba, ,adPPYba, ,adPPYba, ,adPPYba, "
echo "88P' \"88\" \"8a a8\" \"8a a8\" \"8a I8[ \"\" a8P_____88 "
echo "88 88 88 8b d8 8b d8 \`\"Y8ba, 8PP\"\"\"\"\"\"\" "
echo "88 88 88 \"8a, ,a8\" \"8a, ,a8\" aa ]8I \"8b, ,aa "
echo "88 88 88 \`\"YbbdP\"' \`\"YbbdP\"' \`\"YbbdP\"' \`\"Ybbd8\"'"
echo
sleep 2
# go to where the bash file was executed from (should be the main project directory)
APP_PATH="`dirname \"$0\"`"
cd $APP_PATH || exit
###################################################################################################
# Print out the versions of the building tools to use
###################################################################################################
echo "###############################################################"
echo "# BUILD TOOL VERSIONS #"
echo "###############################################################"
echo
echo "Java Version:"
java --version
echo
echo "Javapackager Version:"
jdk="/Users/mpfthprblmtq/Library/Java/JavaVirtualMachines/corretto-17.0.3/Contents/Home/bin"
"$jdk"/jpackage --version
echo
echo
###################################################################################################
# Print out the version of the app we're publishing (found in the source code)
###################################################################################################
echo "###############################################################"
echo "# APP VERSION #"
echo "###############################################################"
echo
# get the version using a grep from SettingsController.java
version=$(grep -Eoi '[0-9]+\.[0-9]+\.[0-9]+' src/main/java/com/mpfthprblmtq/moose/controllers/SettingsController.java)
echo "New version number: ${version}"
echo
echo
###################################################################################################
# Figuring out which type of installer to make
###################################################################################################
echo "###############################################################"
echo "# PACKAGING PROJECT #"
echo "###############################################################"
echo
echo "How would like the app packaged?"
echo " (1): .pkg"
echo " (2): .dmg"
echo
printf " [1/2] : "
read -r packageType
if [[ $packageType == "1" ]]
then
packageType="pkg"
elif [[ $packageType == "2" ]]
then
packageType="dmg"
else
echo
echo "Unknown response, exiting..."
exit
fi
echo
echo "Packaging the application into .$packageType file..."
echo
sleep 2
###################################################################################################
# Moving some resources around
###################################################################################################
# start from scratch
rm -rf deploy
mkdir deploy
# grab the jar from the build folder
printf "Copying jar file to deploy folder..."
cp "$APP_PATH"/out/artifacts/moose_jar/moose.jar "$APP_PATH"/deploy
cd "$APP_PATH"/deploy || exit
echo "Done."
# create resource directory for jpackage
printf "Creating resource directory..."
mkdir resources
cp "$APP_PATH"/src/main/resources/build-resources/moose-app-icon.icns "$APP_PATH"/deploy/resources
cp "$APP_PATH"/src/main/resources/build-resources/moose180-spaced.png "$APP_PATH"/deploy/resources/moose-background.png
cp "$APP_PATH"/src/main/resources/build-resources/moose180-spaced.png "$APP_PATH"/deploy/resources/moose-background-darkAqua.png
# TODO cp "$APP_PATH"/src/main/resources/build/moose-volume.icns "$APP_PATH"/deploy/resources
# TODO cp "$APP_PATH"/src/main/resources/build/moose-background.tiff "$APP_PATH"/deploy/resources/
echo "Done."
# create file association properties files
printf "Creating file extension properties files..."
mkdir properties
echo "mime-type=audio/mpeg\nextension=mp3" > properties/FAmp3.properties
echo "arguments=fileToOpen locationOfFileToOpen" > properties/FAmp3Launcher.properties
echo "Done."
###################################################################################################
# Actually building the package
###################################################################################################
printf "Building installation package..."
$jdk/jpackage \
--type "$packageType" \
--input . \
--main-jar moose.jar \
--name Moose \
--app-version "$version" \
--icon resources/moose-app-icon.icns \
--description "Test description" \
--vendor "PRBLMTQ" \
--copyright "Copyright 2018-2022 PRBLMTQ - Pat Ripley" \
--file-associations properties/FAmp3.properties \
--add-launcher MP3Launcher=properties/FAmp3Launcher.properties \
--resource-dir resources \
--verbose
echo "Done."
sleep 1
echo
# verify app built
installer=$APP_PATH/deploy/Moose-"$version".$packageType
if [ -f "$installer" ]
then
cp Moose-*.$packageType moose-"$version"-installer.$packageType
echo "Done with .$packageType!"
else
echo
echo "Error while building app!"
echo
exit
fi
echo
echo
###################################################################################################
# Clean up
###################################################################################################
echo "###############################################################"
echo "# CLEANING UP #"
echo "###############################################################"
echo
printf "Cleaning up..."
rm moose.jar
rm Moose-"$version"."$packageType"
rm -rf resources
rm -rf properties
echo "Done."
echo
echo
echo "###############################################################"
echo "# PROJECT BUILT AND PACKAGED SUCCESSFULLY #"
echo "###############################################################"
echo
ls -l
###################################################################################################
# Open the installer file from here if we want
###################################################################################################
echo
printf "Would you like to open the .%s file? [Y/N]: " $packageType
read -r openFile
if [[ $openFile == "y" || $openFile == "Y" ]]
then
open moose-"$version"-installer.$packageType
fi
echo " _/\_ __/\__ "
echo " ) . (_ _) .' ( "
echo " \`) '.( ) .' (\` "
echo " \`-._\(_ )/__(~\` "
echo " (ovo)-.__.--._ "
echo " ) \`-.______ "
echo " thanks / \`---._ "
echo " :) ( ,/ /) \ "
echo " \`''\/-. |"
echo " \ | "
echo " | | "
echo