-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildRelease
More file actions
executable file
·91 lines (77 loc) · 3.08 KB
/
Copy pathbuildRelease
File metadata and controls
executable file
·91 lines (77 loc) · 3.08 KB
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
#!/bin/bash
#
# Infomaniak Authenticator - Multiplatform
# Copyright (C) 2026 Infomaniak Network SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Variables
BOLD=$(tput bold)
BOLD_OFF=$(tput sgr0)
GREEN='\033[0;32m'
GREEN_BOLD='\033[1;32m'
COLOR_OFF='\033[0m'
# Function to check whether a string is a valid version (x.x.x)
function is_valid_version {
if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
return 0
else
return 1
fi
}
# Function to display documentation
function show_help {
echo "Usage: $0 <version>"
echo " <version> The version number in the format x.x.x"
echo "Examples:"
echo " $0 1.2.3"
}
function release_ios {
IOS_TAG=$1
echo "Releasing iOS version $1"
echo "Deletes all old caches"
./gradlew clean
rm -rf build # We delete to avoid caching problems
rm -rf .gradle # We delete to avoid caching problems
rm -rf release # The release folder contains the old archives
# Build
echo "Build all Modules for XCFrameworks"
./gradlew :multiplatform-authenticator:AuthenticatorCore:assembleCoreAuthenticatorXCFramework
# Archive
echo "Archive XCFramework to ${BOLD}release${BOLD_OFF} folder"
mkdir -p release
zip -r release/CoreAuthenticator.xcframework.zip multiplatform-authenticator/AuthenticatorCore/build/XCFrameworks/release/CoreAuthenticator.xcframework
# Calculate checksums
echo "Calculate modules checksums from release folder"
MULTIPLATFORM_LIB_CHECKSUM=$(swift package compute-checksum release/CoreAuthenticator.xcframework.zip)
# Update Package.swift
echo "${BOLD}Update Package.swift${BOLD_OFF}"
MULTIPLATFORM_LIB_URL="https://github.com/Infomaniak/android-authenticator/releases/download/$IOS_TAG/CoreAuthenticator.xcframework.zip"
# With the `sed` command the regex doesn't work, whereas with the `perl` command it does.
perl -0777 -pi -e "s|url: \".*CoreAuthenticator.xcframework.zip\",(\s*)checksum: \".*\"|url: \"$MULTIPLATFORM_LIB_URL\",\1checksum: \"$MULTIPLATFORM_LIB_CHECKSUM\"|g" Package.swift
# Upload info
echo -e "${GREEN}Check the${COLOR_OFF} ${GREEN_BOLD}release${COLOR_OFF} ${GREEN}folder to see if the archives are there, then you can upload them to a GitHub release.${COLOR_OFF}"
}
# Check arguments, if no arguments are supplied, the documentation is displayed
if [ $# -eq 0 ]; then
show_help
exit 1
fi
VERSION=$1
if ! is_valid_version "$VERSION"; then
echo "Error: Invalid version format. It should be x.x.x"
show_help
exit 1
fi
release_ios "$1"