-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-version-file.sh
executable file
·53 lines (37 loc) · 1.1 KB
/
generate-version-file.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
#!/bin/sh
echo "🚀 preparing a new OJP Version"
BRANCHNAME=$(git branch --show-current)
BRANCHPREFIX="release"
if [[ $BRANCHNAME == $BRANCHPREFIX/* ]]
then
echo "✅ assure working on a release branch branch"
else
echo "💣 Aborting as we're on the wrong branch"
exit 1
fi
VERSION=$(echo $BRANCHNAME | sed -e "s/^$BRANCHPREFIX\///")
echo "using $VERSION"
SEMVER=( ${VERSION//./ } )
if [ -z "${SEMVER[0]}" ]; then
echo "🛑 Missing major number"
exit 1
fi
if [ -z "${SEMVER[1]}" ]; then
echo "🛑 Missing minor number"
exit 1
fi
if [ -z "${SEMVER[2]}" ]; then
echo "🛑 Missing patch number"
exit 1
fi
echo "import Foundation
// This is automatically generated by 'create-version.sh'
public extension OJP {
/// Current version of the SDK: $VERSION
static let version = \"$VERSION\"
}" > Sources/OJP/Generated/Version.swift
echo "📝 done writing 'Sources/OJP/Generated/Version.swift'"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "writing $VERSION to 'Sources/OJP/Generated/Version.swift'"
git push