-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_xcframework.sh
executable file
·41 lines (38 loc) · 1.47 KB
/
build_xcframework.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
#!/usr/bin/env bash
SEMVER_REGEX="^([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$"
if [ -z "$GITHUB_TOKEN" ]; then
echo "ERROR: Please provide a Github token"
else
if echo $1 | grep -Eq $SEMVER_REGEX; then
# Run tests and build xcframework
if ./gradlew check && ./gradlew assembleTaxKalculatorXCFramework; then
DIRECTORY="swiftpm"
ZIP="TaxKalculator.xcframework.zip"
if [ -d "$DIRECTORY" ]; then
rm -rf $DIRECTORY
fi
if [ -f "$ZIP" ]; then
rm $ZIP
fi
mkdir $DIRECTORY
echo "INFO: Copying artifact"
cp -r build/XCFrameworks/release/TaxKalculator.xcframework $DIRECTORY
echo "INFO: Zipping"
cd $DIRECTORY
zip -r $ZIP .
if CHECK_SUM=$(swift package compute-checksum TaxKalculator.xcframework.zip); then
echo "INFO: $(date +'%c') - Updating Package.swift with checksum ${CHECK_SUM}"
sed -i .bak "s/checksum.*/checksum: \"${CHECK_SUM}\"/g" ../Package.swift
sed -i .bak \
"s/url: \"https:\/\/github.com\/hmrc\/tax-kalculator\/releases.*/url: \"https\:\/\/github.com\/hmrc\/tax-kalculator\/releases\/download\/${1}\/TaxKalculator.xcframework.zip\",/g" \
../Package.swift
else
echo "ERROR: $(date +'%c') - Failed to create checksum"
fi
else
echo "ERROR: $(date +'%c') - Build failed"
fi
else
echo "ERROR: Please provide a valid git tag"
fi
fi