-
Notifications
You must be signed in to change notification settings - Fork 6
/
publish.sh
executable file
·187 lines (157 loc) · 9.52 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/sh
setEnvVariable() {
EXPORT_TOKEN="\n# Created by bitmovin-analytics-collector-android publish script\nexport $1=$2"
if test -e ~/.bashrc; then
echo $EXPORT_TOKEN >>~/.bashrc
echo "Appending to '~/.bashrc' export of ENV variable '$1'"
fi
if test -e ~/.bash_profile; then
echo $EXPORT_TOKEN >>~/.bash_profile
echo "Appending to '~/.bash_profile' export of ENV variable '$1'"
fi
}
notifyApi() {
PLATFORM=$1
VERSION=$2
BUNDLE_NAME=$3
curl "https://api.bitmovin.com/v1/admin/analytics/releases/$PLATFORM/$VERSION" -H "X-Api-Key:$ANALYTICS_API_RELEASE_TOKEN" -H "Content-Type:application/json" \
--data-binary "{
\"group\": \"com.bitmovin.analytics\",
\"repositoryUrl\":\"http://bitmovin.bintray.com/maven\",
\"name\": \"$BUNDLE_NAME\"
}" >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Published Release $PLATFORM:$VERSION:$BUNDLE_NAME to Bitmovin API"
else
echo "Failed to publish release to Bitmovin API"
fi
}
if test -e ~/.bashrc; then
source ~/.bashrc
fi
if test -e ~/.bash_profile; then
source ~/.bash_profile
fi
if [ -z "$ANALYTICS_GH_TOKEN" ]; then
echo "ANALYTICS_GH_TOKEN not found in environment variables. You need to provide the Github Access Token (LastPass: 'bitAnalyticsCircleCi')"
echo "Enter the token:"
read ANALYTICS_GH_TOKEN
echo ""
setEnvVariable "ANALYTICS_GH_TOKEN" $ANALYTICS_GH_TOKEN
fi
if [ -z "$ANALYTICS_API_RELEASE_TOKEN" ]; then
echo "ANALYTICS_API_RELEASE_TOKEN not found in environment variables. You need to provide the bitmovin API Key for the user 'dhi+analytics-admin-user', starting with with 'bb2...' (admin.bitmovin.com/users/4c5d7ec9-6fc0-4c75-8534-532b3b2e7426)"
echo "Enter the token:"
read ANALYTICS_API_RELEASE_TOKEN
echo ""
setEnvVariable "ANALYTICS_API_RELEASE_TOKEN" $ANALYTICS_API_RELEASE_TOKEN
fi
echo "! Before publishing, make sure the version has been already bumped in the 'README.md' and 'CHANGELOG.md' and already merged as release PR into 'main' branch !"
read -p "(Press enter to continue)"
echo ""
echo "! Before publishing, make sure you have created 'bitmovin.properties' file with correct credentials (LastPass: 'bitmovin artifactory') !"
read -p "(Press enter to continue)"
echo ""
echo "! After publishing, change the 'developLocal' gradle property to 'false' manually and start all the examples locally to make sure that the outgoing payload doesn't include '-local' in the version string (and pull the right published artifacts from artifactory) !"
read -p "(Press enter to continue)"
echo ""
echo "! After publishing, Don't forget to update the changelog in readme.io !"
read -p "(Press enter to continue)"
echo ""
echo "Enter the version (without leading 'v')":
read VERSION
echo ""
echo "---------- Summary ----------"
echo 'ANALYTICS_GH_TOKEN='$ANALYTICS_GH_TOKEN
echo 'ANALYTICS_API_RELEASE_TOKEN='$ANALYTICS_API_RELEASE_TOKEN
echo 'VERSION='$VERSION
echo ""
echo "Artifacts to publish:"
echo " - com.bitmovin.analytics:collector:$VERSION (:collector project)"
echo " - com.bitmovin.analytics:collector-bitmovin-player:$VERSION (:collector-bitmovin-player project)"
echo " - com.bitmovin.analytics:collector-exoplayer:$VERSION (:collector-exoplayer project)"
echo " - com.bitmovin.analytics:collector-media3-exoplayer:$VERSION (:collector-media3-exoplayer project)"
echo " - com.bitmovin.analytics:collector-amazon-ivs:$VERSION (:collector-amazon-ivs project)"
echo "\nAre all tokens, artifacts and versions correct ?"
read -p "(Press enter to continue)"
echo "\nGit Checkout and pull 'main' branch..."
git checkout main
git pull
echo "\nCheck correct code style..."
if ! ./gradlew spotlessCheck --daemon; then
echo "Code style violations detected, please fix them first on main as otherwise the build will fail."
exit
fi
echo "\n:collector project build and publishing..."
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector:clean || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector:build || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector:assembleRelease || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector:artifactoryPublish || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector:publishToMavenLocal || exit
echo "\n:collector project built and published!"
echo "\n:collector-bitmovin-player project build and publishing..."
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-bitmovin-player:clean || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-bitmovin-player:build || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-bitmovin-player:assembleRelease || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-bitmovin-player:artifactoryPublish || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-bitmovin-player:publishToMavenLocal || exit
echo "\n:collector-bitmovin-player project built and published!"
echo "\n:collector-exoplayer project build and publishing..."
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-exoplayer:clean || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-exoplayer:build || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-exoplayer:assembleRelease || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-exoplayer:artifactoryPublish || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-exoplayer:publishToMavenLocal || exit
echo "\n:collector-exoplayer project built and published!"
echo "\n:collector-amazon-ivs project build and publishing..."
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-amazon-ivs:clean || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-amazon-ivs:build || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-amazon-ivs:assembleRelease || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-amazon-ivs:artifactoryPublish || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-amazon-ivs:publishToMavenLocal || exit
echo "\n:collector-amazon-ivs project built and published!"
echo "\n:collector-media3-exoplayer project build and publishing..."
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-media3-exoplayer:clean || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-media3-exoplayer:build || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-media3-exoplayer:assembleRelease || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-media3-exoplayer:artifactoryPublish || exit
./gradlew -DdevelopLocal=false -Dversion="$VERSION" :collector-media3-exoplayer:publishToMavenLocal || exit
echo "\n:collector-media3-exoplayer project built and published!"
echo "\nGit release"
echo "\nGit create tag 'v$VERSION' ..."
git tag -a v$VERSION -m "v$VERSION"
echo "\n Git push tag 'v$VERSION' to internal repo."
git push origin main v$VERSION
echo "\n Git push 'main' and tag 'v$VERSION' to public repo."
git push [email protected]:bitmovin/bitmovin-analytics-collector-android.git main v$VERSION
echo "Creating release in public repo."
curl \
-u bitAnalyticsCircleCi:$ANALYTICS_GH_TOKEN \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/bitmovin/bitmovin-analytics-collector-android/releases \
-d "{\"tag_name\":\"v$VERSION\", \"name\": \"v$VERSION\", \"draft\": false}"
file="./bitmovin.properties"
if [ -f "$file" ]; then
echo "$file found."
while IFS='=' read -r key value; do
key=$(echo $key | tr '.' '_')
eval ${key}=\${value}
done <"$file"
else
echo "$file not found."
fi
echo "Copying artifacts from libs-release-local to public-releases in jfrog ..."
curl -H "Content-Type: application/json" -X POST -u ${artifactoryUser}:${artifactoryPassword} "https://bitmovin.jfrog.io/bitmovin/api/copy/libs-release-local/com/bitmovin/analytics/collector/${VERSION}?to=/public-releases/com/bitmovin/analytics/collector/${VERSION}"
curl -H "Content-Type: application/json" -X POST -u ${artifactoryUser}:${artifactoryPassword} "https://bitmovin.jfrog.io/bitmovin/api/copy/libs-release-local/com/bitmovin/analytics/collector-bitmovin-player/${VERSION}?to=/public-releases/com/bitmovin/analytics/collector-bitmovin-player/${VERSION}"
curl -H "Content-Type: application/json" -X POST -u ${artifactoryUser}:${artifactoryPassword} "https://bitmovin.jfrog.io/bitmovin/api/copy/libs-release-local/com/bitmovin/analytics/collector-exoplayer/${VERSION}?to=/public-releases/com/bitmovin/analytics/collector-exoplayer/${VERSION}"
curl -H "Content-Type: application/json" -X POST -u ${artifactoryUser}:${artifactoryPassword} "https://bitmovin.jfrog.io/bitmovin/api/copy/libs-release-local/com/bitmovin/analytics/collector-amazon-ivs/${VERSION}?to=/public-releases/com/bitmovin/analytics/collector-amazon-ivs/${VERSION}"
curl -H "Content-Type: application/json" -X POST -u ${artifactoryUser}:${artifactoryPassword} "https://bitmovin.jfrog.io/bitmovin/api/copy/libs-release-local/com/bitmovin/analytics/collector-media3-exoplayer/${VERSION}?to=/public-releases/com/bitmovin/analytics/collector-media3-exoplayer/${VERSION}"
echo "\nCopied artifacts to public jfrog repo."
echo "\nNotifying bitmovin api about new release..."
notifyApi "android-bitmovin" $VERSION "collector-bitmovin-player"
notifyApi "android-exo" $VERSION "collector-exoplayer"
notifyApi "android-amazon-ivs" $VERSION "collector-amazon-ivs"
notifyApi "android-media3-exo" $VERSION "collector-media3-exoplayer"
echo "Don't forget to update the changelog in readme.io"
open "https://dash.readme.com/project/bitmovin-playback/v1/docs/analytics-collector-android-releases"