-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign_and_upload_last_builds
executable file
·307 lines (231 loc) · 7.46 KB
/
sign_and_upload_last_builds
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#!/bin/bash
SET_TO_LATEST_FLAG=$1
# Directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Script dir: $SCRIPT_DIR"
. ./ADDRESS
. ./developer_sign_file.sh
. ./developer_upload_version_folder.sh
RELEASE_NOTES_FILENAME="release_notes.txt"
APPVEYOR_PATH="https://ci.appveyor.com/api/projects/geneotech/Hypersomnia/artifacts"
WORKFLOWS_PATH="https://nightly.link/TeamHypersomnia/Hypersomnia/workflows"
LIBSTEAM_INTEGRATION_BIN_LINK="https://github.com/TeamHypersomnia/Hypersomnia/raw/master/cmake/steam_integration/bin"
APPVEYOR_FILES=("Hypersomnia-for-Windows.exe" "Hypersomnia-for-Windows.zip" $RELEASE_NOTES_FILENAME)
download_file() {
URL_LEFT=$1
FILENAME=$2
FINAL_URL="${URL_LEFT}${FILENAME}"
LOG_FILENAME="$FILENAME.download.log"
echo "wget $FINAL_URL"
#echo "Downloading $FILENAME..."
wget --show-progress $FINAL_URL -o $LOG_FILENAME
}
download_from_appveyor() {
local PLATFORM="Windows"
for i in "${APPVEYOR_FILES[@]}"
do
download_file "$APPVEYOR_PATH/" $i
done
#dos2unix $RELEASE_NOTES_FILENAME
}
download_from_github_actions() {
local PLATFORM=$1
download_file "$WORKFLOWS_PATH/${PLATFORM}_build/master/" "$PLATFORM-binaries.zip"
}
unpack_from_appveyor() {
local PLATFORM="Windows"
rm -rf binaries-$PLATFORM
mkdir binaries-$PLATFORM
for i in "${APPVEYOR_FILES[@]}"
do
cp $i binaries-$PLATFORM
done
}
unpack_from_github_actions() {
local PLATFORM=$1
rm -rf binaries-$PLATFORM
if unzip $PLATFORM-binaries.zip -d binaries-$PLATFORM; then
pushd binaries-$PLATFORM/
mv hypersomnia/$RELEASE_NOTES_FILENAME ./
rmdir hypersomnia
popd
fi
}
sign_platform_file() {
local FILE_PATH=$1
local SIGN_NAMESPACE=$2
echo "Signing $FILE_PATH"
SIGNATURE_FILE_PATH="$FILE_PATH.sig"
developer_sign_file $SIGN_NAMESPACE $FILE_PATH
}
read_version() {
local PLATFORM=$1
local VERSION_PATH="binaries-$PLATFORM/$RELEASE_NOTES_FILENAME"
if [[ "$PLATFORM" == "Windows" ]]; then
local FIXED_PATH="$VERSION_PATH.dos"
cp $VERSION_PATH $FIXED_PATH
dos2unix $FIXED_PATH
VERSION=$(head -n 1 $FIXED_PATH)
COMMIT_HASH=$(sed -n '2p' < $FIXED_PATH)
else
VERSION=$(head -n 1 $VERSION_PATH)
COMMIT_HASH=$(sed -n '2p' < $VERSION_PATH)
fi
}
print_version() {
read_version $1
echo "$1 version: $VERSION"
}
create_version_file() {
PLATFORM=$1
SIGNATURE_FILE_PATH=$2
read_version $PLATFORM
VERSION_FILE_PATH="$OUTPUT_FOLDER/version-$PLATFORM.txt"
echo "Writing a version file $VERSION_FILE_PATH using signature $SIGNATURE_FILE_PATH..."
echo $VERSION > $VERSION_FILE_PATH
echo "Commit hash: $COMMIT_HASH" >> $VERSION_FILE_PATH
cat $SIGNATURE_FILE_PATH >> $VERSION_FILE_PATH
}
sign_and_version() {
local PLATFORM=$1
local EXTENSION=$2
local ARTIFACT_TYPE=$3
local FOLDER="binaries-$PLATFORM"
local FILE_PATH="$FOLDER/Hypersomnia-for-$PLATFORM.$EXTENSION"
SIGN_NAMESPACE="hypersomnia"
if [[ "$ARTIFACT_TYPE" == "updater" ]]; then
SIGN_NAMESPACE="self_updater"
fi
if [[ "$SKIP_SIGNING" == "1" ]]; then
echo "Skipping signing due to SKIP_SIGNING specified."
else
sign_platform_file $FILE_PATH $SIGN_NAMESPACE
if [[ "$ARTIFACT_TYPE" == "updater" ]]; then
create_version_file $PLATFORM $SIGNATURE_FILE_PATH
fi
mv $SIGNATURE_FILE_PATH $OUTPUT_FOLDER
fi
cp $FILE_PATH $OUTPUT_FOLDER
}
sign_and_version_AppImage() {
local TYPE=$1
local PLATFORM="Linux"
local VERSION_FILENAME="version-AppImage.txt"
local APPIMAGE_FILENAME="Hypersomnia.AppImage"
if [[ "$TYPE" == "Headless" ]]; then
PLATFORM="LinuxHeadless";
VERSION_FILENAME="version-Headless-AppImage.txt"
APPIMAGE_FILENAME="Hypersomnia-Headless.AppImage"
fi
local FILE_PATH="binaries-$PLATFORM/$APPIMAGE_FILENAME"
SIGN_NAMESPACE="self_updater"
if [[ "$SKIP_SIGNING" == "1" ]]; then
echo "Skipping signing due to SKIP_SIGNING specified."
else
sign_platform_file $FILE_PATH $SIGN_NAMESPACE
create_version_file $PLATFORM $SIGNATURE_FILE_PATH
mv "$OUTPUT_FOLDER/version-$PLATFORM.txt" "$OUTPUT_FOLDER/$VERSION_FILENAME"
mv $SIGNATURE_FILE_PATH $OUTPUT_FOLDER
fi
cp $FILE_PATH $OUTPUT_FOLDER
}
upload_to_steam() {
local SDK="$SCRIPT_DIR/steamworks/sdk"
local CONTENT_BUILDER="$SDK/tools/ContentBuilder"
local CONTENT="$CONTENT_BUILDER/content"
local STEAMCMD_DIR="$CONTENT_BUILDER/builder_linux"
echo "SDK: $SDK"
echo "CONTENT: $CONTENT"
echo "Copying app_build.vdf"
cp $SCRIPT_DIR/vdf/app_build.vdf $CONTENT_BUILDER/scripts
rm -rf $CONTENT
mkdir $CONTENT
mkdir $CONTENT/windows
mkdir $CONTENT/linux
mkdir $CONTENT/macos
local APPIMAGE="binaries-Linux/Hypersomnia.AppImage"
chmod +x $APPIMAGE
local STEAM_APPIMAGE="binaries-Linux/Hypersomnia-Steam.AppImage"
chmod +x $STEAM_APPIMAGE
mv $STEAM_APPIMAGE $CONTENT/linux/Hypersomnia.AppImage
echo "Repacking Windows .zip for Steam release."
unzip "binaries-Windows/Hypersomnia-for-Windows.zip" -d $CONTENT/windows
curl -O --location "${LIBSTEAM_INTEGRATION_BIN_LINK}/windows/steam_integration.dll"
cp $SDK/redistributable_bin/win64/steam_api64.dll $CONTENT/windows/hypersomnia
cp steam_integration.dll $CONTENT/windows/hypersomnia
pushd binaries-MacOS
echo "Repacking MacOS App folder for Steam release."
7z x Hypersomnia-for-MacOS.app.sfx
mv Hypersomnia.app $CONTENT/macos
local MACOS_EXECUTABLE_FOLDER="$CONTENT/macos/Hypersomnia.app/Contents/MacOS/"
curl -O --location "${LIBSTEAM_INTEGRATION_BIN_LINK}/macos/libsteam_integration.dylib"
cp $SDK/redistributable_bin/osx/libsteam_api.dylib $MACOS_EXECUTABLE_FOLDER
cp libsteam_integration.dylib $MACOS_EXECUTABLE_FOLDER
popd
pushd $STEAMCMD_DIR
if [[ "$SKIP_UPLOADING_TO_STEAM" == "1" ]]; then
echo "Skipping uploading to Steam due to SKIP_UPLOADING_TO_STEAM specified."
else
./steamcmd.sh +login $STEAM_LOGIN +run_app_build ../scripts/app_build.vdf +quit
fi
popd
}
DEPLOYMENT_FOLDER="/tmp/hypersomnia-deployment"
if [[ "$SKIP_DOWNLOADING" == "1" ]]; then
echo "Reusing $DEPLOYMENT_FOLDER"
else
rm -rf $DEPLOYMENT_FOLDER
mkdir $DEPLOYMENT_FOLDER
fi
pushd /tmp/hypersomnia-deployment
if [[ "$SKIP_DOWNLOADING" == "1" ]]; then
echo "SKIPPING DOWNLOAD! Re-using previously downloaded files."
else
download_from_github_actions Linux
download_from_github_actions LinuxHeadless
download_from_github_actions MacOS
download_from_appveyor
fi
unpack_from_github_actions Linux
unpack_from_github_actions LinuxHeadless
unpack_from_github_actions MacOS
unpack_from_appveyor
print_version Windows
print_version Linux
print_version LinuxHeadless
print_version MacOS
read_version Linux
REFERENCE_VERSION=$VERSION
REFERENCE_NOTICE=""
if [[ "$SET_TO_LATEST_FLAG" == "--set-to-latest" ]]; then
REFERENCE_NOTICE="Latest version will be set to $REFERENCE_VERSION. "
fi
# At some point all versions will NEED to be the same
# for the game not to trigger warnings about binary compatibility.
read -p "${REFERENCE_NOTICE}Sign and upload? (Yy/Nn) " -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Exiting without signing."
exit 1
fi
echo "Signing and uploading."
OUTPUT_FOLDER=$REFERENCE_VERSION
rm -rf $OUTPUT_FOLDER
mkdir $OUTPUT_FOLDER
if [[ "$UPLOAD_TO_STEAM" == "1" ]]; then
echo "Uploading to Steam."
upload_to_steam
fi
sign_and_version_AppImage
sign_and_version_AppImage Headless
sign_and_version Windows exe "updater"
sign_and_version Windows zip "release"
sign_and_version MacOS app.sfx "updater"
sign_and_version MacOS dmg "release"
if [[ "$SKIP_UPLOADING" == "1" ]]; then
echo "Skipping uploading due to SKIP_UPLOADING specified."
else
developer_upload_version_folder $OUTPUT_FOLDER $REFERENCE_VERSION $SET_TO_LATEST_FLAG
fi
popd