-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildapp.sh.example
executable file
·127 lines (119 loc) · 5.17 KB
/
buildapp.sh.example
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
#!/bin/zsh
# NOTE: This build file was used on an Apple macOS host.
# YMMV with another host OS.
###############################################################################
# Copy this file to buildapp.sh and set the following to have script generate
# builds with appropriate information
###############################################################################
# Go binary executable filename is taken from current directory name
BASEAPP=`basename $PWD`
# The application ID is in reverse FQDN (e.g., com.example.MySetup)
APPFQDN='your.reverse.FQDN'
# Name, version, build, and icon of final application
APPNAME='MySetup'
APPVERSION='0.0.1'
APPBUILD='1'
APPICON='Icon.png'
# Uncomment RELEASE for a release build (i.e., no debug code)
#RELEASE=true
# Location to place final application files
APPINSTALLERS=~"/Desktop/${APPNAME}-Installers/"
###############################################################################
if [[ $RELEASE = 'true' ]]
then
APPRELEASEFYNECROSS='-release'
APPRELEASE='--release'
fi
echo 'Checking if we have tools needed to build binaries...'
tools=('go' 'fyne' 'fyne-cross' 'docker')
for tool in "${tools[@]}" ;do
which $tool &> /dev/null
if [[ $? -eq 0 ]]
then
echo " '$tool' found"
else
echo " '$tool' NOT FOUND"
echo ""
echo "This script requires that"
echo " - Golang (https://go.dev/)"
echo " - Docker (https://docs.docker.com/desktop/release-notes/)"
echo " [specifically the docker CLI, or equivalent, such as Podman with"
echo " 'nerdctl' aliased as 'docker' and using dockerd(Moby) engine]"
echo " - Fyne (https://fyne.io/)"
echo " including the"
echo " - 'fyne' tool (https://developer.fyne.io/started/packaging)"
echo " - 'fyne-cross' tool (https://developer.fyne.io/started/cross-compiling)"
echo "are all installed."
echo ""
echo "Please verify that you have '$tool' installed and in your PATH. Aborting..."
exit
fi
done
echo "Checking if Docker daemon is responding..."
docker ps
if [[ $? -eq 0 ]]
then
echo "Docker daemon is responding"
else
echo "Docker daemon does not appear to be responding."
echo "You're not using Rancher Desktop with containerd are you?"
echo "Aborting..."
exit
fi
echo 'Installing...'
echo
echo ____________________________________________________________
echo Creating final build directory at ${APPINSTALLERS} for ${APPNAME}...
mkdir ${APPINSTALLERS}
echo ____________________________________________________________
echo Building Microsoft Windows version...
fyne-cross windows -name ${APPNAME}.exe -app-version ${APPVERSION} -app-build ${APPBUILD} -app-id ${APPFQDN}.${APPNAME} -icon ${APPICON} ${APPRELEASEFYNECROSS}
echo
echo Moving MS Windows version to Desktop...
cp fyne-cross/dist/windows-amd64/${APPNAME}.exe.zip ${APPINSTALLERS}
echo ____________________________________________________________
echo Building macOS architecture-specific versions...
echo ' • Building Intel x64 version...'
GOOS=darwin GOARCH=amd64 fyne package --name ${APPNAME}_amd64 --appVersion ${APPVERSION} --appBuild ${APPBUILD} --appID ${APPFQDN}.${APPNAME} --icon ${APPICON} ${APPRELEASE}
echo ' • Building Apple Silicon version...'
GOOS=darwin GOARCH=arm64 fyne package --name ${APPNAME}_arm64 --appVersion ${APPVERSION} --appBuild ${APPBUILD} --appID ${APPFQDN}.${APPNAME} --icon ${APPICON} ${APPRELEASE}
echo
echo Building macOS Universal Binary...
# Copy Intel version to final name
cp -R ${APPNAME}_amd64.app/ ${APPNAME}.app/
# Combine Intel and Apple Silicon binaries into a Universal Binary which is output to this final copy
lipo -create -output ./${APPNAME}.app/Contents/MacOS/${BASEAPP} ./${APPNAME}_amd64.app/Contents/MacOS/${BASEAPP} ./${APPNAME}_arm64.app/Contents/MacOS/${BASEAPP}
echo
echo Remove existing DMG staging files...
rm ${APPINSTALLERS}${APPNAME}.dmg &> /dev/null
rm ${APPINSTALLERS}${APPNAME}_tmp.dmg &> /dev/null
rm ${APPINSTALLERS}${APPNAME}/${APPNAME}.app/ &> /dev/null
echo
echo Creating .DMG file on Desktop...
mkdir ${APPINSTALLERS}${APPNAME}
cp -R ${APPNAME}.app/ ${APPINSTALLERS}${APPNAME}/${APPNAME}.app/
hdiutil create ${APPINSTALLERS}${APPNAME}_tmp.dmg -ov -volname "${APPNAME}" -fs HFS+ -srcfolder "${APPINSTALLERS}${APPNAME}/" > /dev/null
hdiutil convert ${APPINSTALLERS}${APPNAME}_tmp.dmg -format UDZO -o ${APPINSTALLERS}${APPNAME}.dmg > /dev/null
echo
echo '*******************************************************'
echo ' About to remove all the build objects'
echo '*******************************************************'
echo
read -s -k '? [Press any key to continue]'
echo
echo ____________________________________________________________
echo CLEANUP
echo
echo Removing tmp .DMG...
rm ${APPINSTALLERS}${APPNAME}_tmp.dmg
echo Removing DMG build folder...
rm -rf ${APPINSTALLERS}${APPNAME}/
echo Removing macOS Universal Binary and architecture-specific versions in dev folder...
rm -rf ${APPNAME}_amd64.app/
rm -rf ${APPNAME}_arm64.app/
rm -rf ${APPNAME}.app/
echo Removing fyne-cross directory...
rm -rf fyne-cross/
echo
echo ____________________________________________________________
echo Done.