-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate_artifactbundle.sh
executable file
·69 lines (48 loc) · 1.4 KB
/
create_artifactbundle.sh
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
#!/usr/bin/env bash
# example
#
# - version
# scripts/create_artifactbundle.sh 1.0.0
#
# - version with artifactbundle name
# scripts/create_artifactbundle.sh 1.0.0 run-script-bin
set -Ceu
VERSION_STRING=$1
PRODUCT_NAME="run-script"
NAME=$PRODUCT_NAME
if (( $# > 1 )); then
NAME=$2
fi
ARTIFACT_BUNDLE_NAME="${NAME}.artifactbundle"
ARTIFACT_BUNDLE_BIN_PATH="${ARTIFACT_BUNDLE_NAME}/${NAME}/bin"
INFO_TEMPLATE="./scripts/info.json.template"
show_checksum() {
CHECKSUM=$(swift package compute-checksum ./${ARTIFACT_BUNDLE_NAME}.zip)
echo "checksum:"
echo ${CHECKSUM}
}
create_artifact_bundle() {
mkdir -p "${ARTIFACT_BUNDLE_BIN_PATH}"
sed "s/__VERSION__/${VERSION_STRING}/g; s/__NAME__/${NAME}/g" ${INFO_TEMPLATE} > "${ARTIFACT_BUNDLE_NAME}/info.json"
cp -f ".build/apple/Products/Release/${PRODUCT_NAME}" "${ARTIFACT_BUNDLE_BIN_PATH}"
cp -f LICENSE "${ARTIFACT_BUNDLE_NAME}"
mv "${ARTIFACT_BUNDLE_BIN_PATH}/${PRODUCT_NAME}" "${ARTIFACT_BUNDLE_BIN_PATH}/${NAME}"
}
zip_artifact_bundle() {
zip -yr - "${ARTIFACT_BUNDLE_NAME}" > "./${ARTIFACT_BUNDLE_NAME}.zip"
}
build_target() {
swift build -c release --product $PRODUCT_NAME --arch arm64 --arch x86_64
}
clear_outputs() {
rm -rf $ARTIFACT_BUNDLE_NAME
rm -f "${ARTIFACT_BUNDLE_NAME}.zip"
}
clear_outputs
if [ "$1" = "--clear" ]; then
exit
fi
build_target
create_artifact_bundle
zip_artifact_bundle
show_checksum