forked from appventure-nush/builder-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-sdk-version
executable file
·69 lines (45 loc) · 1.75 KB
/
bump-sdk-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
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
#!/bin/sh
echo "+ Scraping SDK website for version number"
ANDROID_SDK_VERSION=$(curl --silent https://developer.android.com/studio/ | grep -m 1 -oE 'commandlinetools-linux-[0-9]+' | cut -d - -f 3)
if [ -z "$ANDROID_SDK_VERSION" ]; then
echo "Version not found"
exit 1
fi
echo "+ Found version $ANDROID_SDK_VERSION"
echo "+ Scraping Android repository-12.xml for build tools"
BUILD_TOOLS_VERSION=$(curl --silent https://dl.google.com/android/repository/repository-12.xml | grep -oE "build-tools_r[0-9]+\.[0-9]+\.[0-9]+" | cut -f 2 -d r | sort -r | head -n 1)
if [ -z "$BUILD_TOOLS_VERSION" ]; then
echo "Version not found"
exit 1
fi
echo "+ Found version $BUILD_TOOLS_VERSION"
PLATFORM_VERSION=$(echo $BUILD_TOOLS_VERSION | cut -f 1 -d .)
echo "+ Assuming platform version $PLATFORM_VERSION"
echo "+ Replacing ANDROID_SDK_VERSION in Dockerfile"
sed -i "s/ENV ANDROID_SDK_VERSION .*/ENV ANDROID_SDK_VERSION $ANDROID_SDK_VERSION/" \
Dockerfile \
ndk/Dockerfile
echo "+ Replacing BUILD_TOOLS_VERSION in Dockerfile"
sed -i "s/ENV BUILD_TOOLS_VERSION .*/ENV BUILD_TOOLS_VERSION $BUILD_TOOLS_VERSION/" \
Dockerfile \
ndk/Dockerfile
echo "+ Replacing PLATFORM_VERSION in Dockerfile"
sed -i "s/ENV PLATFORM_VERSION .*/ENV PLATFORM_VERSION $PLATFORM_VERSION/" \
Dockerfile \
ndk/Dockerfile
echo "+ Done!"
echo
echo "+ Adding changed files"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add Dockerfile ndk/Dockerfile
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
echo "+ Committing"
git commit -m "Bump SDK version to $ANDROID_SDK_VERSION"
echo "+ Tagging"
git tag -f $ANDROID_SDK_VERSION
echo "+ Pushing"
git push -f
git push --tags -f
echo "+ Done!"
fi