-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·59 lines (46 loc) · 1.6 KB
/
build.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
#!/usr/bin/env bash
# prepare variables
CLI="package-generator-cli"
INFOJSONPATH="$CLI.artifactbundle/info.json"
TMPPATH=$(mktemp)
TMPRELEASEFOLDER=$(mktemp -d)
REPO="mackoj/PackageGeneratorCLI"
SOURCEFOLDER=$(pwd)
if [[ $(uname -m) == "x86_64" ]]; then
TRIPLE="x86_64-apple-macosx"
else
TRIPLE="arm64-apple-macosx"
fi
TMPRELEASEPROJECT=$TMPRELEASEFOLDER/PackageGeneratorCLI
# TAG=$(curl -s "https://api.github.com/repos/$REPO/tags" | jq --compact-output --raw-output '.[0].name ')
TAG="main"
CLIBINPATH="$CLI.artifactbundle/$TRIPLE/bin"
ZIPOUTPUT=$CLI-$TRIPLE.artifactbundle.zip
# generation
############
echo "Cloning $REPO @ $TAG"
cd "$TMPRELEASEFOLDER" || exit
git clone --depth 1 --branch "$TAG" https://github.com/$REPO.git
cd "$TMPRELEASEPROJECT" || exit
echo "Building $TAG"
git checkout "$TAG"
echo "Building $TAG"
swift build -c release
echo "Creating Artifactbundle"
mkdir -p $CLIBINPATH
cp -f .build/release/$CLI $CLIBINPATH
cp info.json "$INFOJSONPATH"
echo "Updating Artifactbundle Info.json"
jq '.artifacts."package-generator-cli".version = "'"$TAG"'"' "$INFOJSONPATH" > "$TMPPATH"
mv "$TMPPATH" "$INFOJSONPATH"
jq '.artifacts."package-generator-cli".variants += [{ "path": "'"$TRIPLE"'/bin/package-generator-cli", "supportedTriples": ["'"$TRIPLE"'"] }] ' "$INFOJSONPATH" > "$TMPPATH"
mv "$TMPPATH" "$INFOJSONPATH"
echo "Zip Artifactbundle"
zip -r $ZIPOUTPUT $CLI.artifactbundle -x ".*" -x "__MACOSX"
cp $ZIPOUTPUT "$SOURCEFOLDER/$ZIPOUTPUT"
echo "Cleaning"
rm -rf $CLI.artifactbundle
cd "$SOURCEFOLDER" || exit
rm -rf "$TMPRELEASEFOLDER"
echo "Compute Checksum"
swift package compute-checksum $ZIPOUTPUT