-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathgenerate_version
executable file
·31 lines (26 loc) · 1.13 KB
/
generate_version
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
version_number=$1
if [ -z "${version_number}" ]
then
version_number=`git describe --tags $(git rev-list --tags --max-count=1)`
fi
# Separate version core from pre-release data (e.g. "1.2.3-beta" -> "1.2.3" and "beta")
IFS='-' read -a components <<< "${version_number}"
# Separate components of the version core (e.g. "1.2.3" -> "1", "2", "3")
IFS='.' read -a version_components <<< "${components[0]}"
# Extract version components to variables
prerelease_components=${components[1]}
major=${version_components[0]}
minor=${version_components[1]}
patch=${version_components[2]}
# Set the string for pre-release identifier if needed
if [ -z "${prerelease_components}" ]
then
prereleaseIdentifier="nil"
else
prereleaseIdentifier=\"${prerelease_components}\"
fi
# Generate Swift file containing version information
version_file=Sources/InstantSearchCore/Helper/Version+Current.swift
> $version_file
echo "// This is generated file. Don't modify it manually." >> $version_file
echo "public extension Version { static let current: Version = .init(major: $major, minor: $minor, patch: $patch, prereleaseIdentifier: $prereleaseIdentifier) }" >> $version_file