-
Notifications
You must be signed in to change notification settings - Fork 3
/
publish.sh
executable file
·68 lines (55 loc) · 1.88 KB
/
publish.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
60
61
62
63
64
65
66
67
68
#!/bin/bash
# A script to verify that the repo is up to date and the versions are correct and then runs the pod trunk push command
constants=$(<Sources/FirebaseConstants.swift)
regex="^.*static let version \= \"([0-9\.]*)\""
if [[ $constants =~ $regex ]]
then
versionConstant=${BASH_REMATCH[1]}
else
echo "Couldn't match the library version, exiting"
exit 1
fi
echo Version Constant $versionConstant
podspecFile=$(<TealiumFirebase.podspec)
podspecRegex="^.*s.version[[:space:]]*\= \"([0-9\.]*)\""
if [[ $podspecFile =~ $podspecRegex ]]
then
podspecVersion=${BASH_REMATCH[1]}
else
echo "Couldn't match the podspec version, exiting"
exit 1
fi
echo Podspec Version $podspecVersion
if [ $podspecVersion != $versionConstant ]
then
echo "The podspec version \"${podspecVersion}\" is different from the version constant \"${versionConstant}\".\nDid you forget to update one of the two?"
exit 1
fi
branch_name="$(git rev-parse --abbrev-ref HEAD)"
echo Current branch $branch_name
if [ $branch_name != "main" ]
then
echo "Check out to main branch before trying to publish. Current branch: ${branch_name}"
exit 1
fi
git fetch --tags
if ! git diff --quiet remotes/origin/main
then
echo "Make sure you are up to date with the remote before publishing"
exit 1
fi
latestTag=$(git describe --tags --abbrev=0)
echo Latest tag $latestTag
if [ $latestTag != $versionConstant ]
then
echo "The latest published tag \"${latestTag}\" is different from the version constant \"${versionConstant}\".\nDid you forget to add the tag to the release or did you forget to update the Constant?"
exit 1
fi
echo "All checks are passed, ready to release to CocoaPods"
echo "Do you wish to publish to CocoaPods?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "Ok, running \"pod trunk push\" now."; pod trunk push; break;;
No ) echo "Ok, skip the release for now."; exit;;
esac
done