1
0
Fork 0
android-builder/bump-sdk-version

70 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2018-09-23 10:37:56 +08:00
#!/bin/sh
2018-09-23 10:41:50 +08:00
echo "+ Scraping SDK website for version number"
2018-09-23 10:37:56 +08:00
2020-05-16 13:44:01 +08:00
ANDROID_SDK_VERSION=$(curl --silent https://developer.android.com/studio/ | grep -m 1 -oE 'commandlinetools-linux-[0-9]+' | cut -d - -f 3)
2018-09-23 10:37:56 +08:00
if [ -z "$ANDROID_SDK_VERSION" ]; then
echo "Version not found"
exit 1
fi
2018-09-23 10:41:50 +08:00
echo "+ Found version $ANDROID_SDK_VERSION"
2018-09-23 10:37:56 +08:00
2018-09-23 10:41:50 +08:00
echo "+ Scraping Android repository-12.xml for build tools"
2018-09-23 10:37:56 +08:00
2020-05-16 13:44:01 +08:00
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)
2018-09-23 10:37:56 +08:00
if [ -z "$BUILD_TOOLS_VERSION" ]; then
echo "Version not found"
exit 1
fi
2018-09-23 10:41:50 +08:00
echo "+ Found version $BUILD_TOOLS_VERSION"
2018-09-23 10:37:56 +08:00
PLATFORM_VERSION=$(echo $BUILD_TOOLS_VERSION | cut -f 1 -d .)
2018-09-23 10:41:50 +08:00
echo "+ Assuming platform version $PLATFORM_VERSION"
2018-09-23 10:37:56 +08:00
2018-09-23 10:41:50 +08:00
echo "+ Replacing ANDROID_SDK_VERSION in Dockerfile"
2018-09-23 10:37:56 +08:00
2020-05-16 14:07:00 +08:00
sed -i "s/ENV ANDROID_SDK_VERSION .*/ENV ANDROID_SDK_VERSION $ANDROID_SDK_VERSION/" \
2018-09-23 19:28:08 +08:00
Dockerfile \
ndk/Dockerfile
2018-09-23 10:37:56 +08:00
2018-09-23 10:41:50 +08:00
echo "+ Replacing BUILD_TOOLS_VERSION in Dockerfile"
2018-09-23 10:37:56 +08:00
2020-05-16 14:07:00 +08:00
sed -i "s/ENV BUILD_TOOLS_VERSION .*/ENV BUILD_TOOLS_VERSION $BUILD_TOOLS_VERSION/" \
2018-09-23 19:28:08 +08:00
Dockerfile \
ndk/Dockerfile
2018-09-23 10:37:56 +08:00
2018-09-23 10:41:50 +08:00
echo "+ Replacing PLATFORM_VERSION in Dockerfile"
2018-09-23 10:37:56 +08:00
2020-05-16 14:07:00 +08:00
sed -i "s/ENV PLATFORM_VERSION .*/ENV PLATFORM_VERSION $PLATFORM_VERSION/" \
2018-09-23 19:28:08 +08:00
Dockerfile \
ndk/Dockerfile
2018-09-23 10:37:56 +08:00
2018-09-23 10:41:50 +08:00
echo "+ Done!"
echo
2020-05-16 14:29:53 +08:00
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
2018-09-23 10:41:50 +08:00
echo "+ Committing"
2020-05-16 14:29:53 +08:00
git commit -m "Bump SDK version to $ANDROID_SDK_VERSION"
2018-09-23 10:41:50 +08:00
echo "+ Tagging"
2020-05-16 14:29:53 +08:00
git tag -f $ANDROID_SDK_VERSION
2018-09-23 10:41:50 +08:00
echo "+ Pushing"
2020-05-16 14:29:53 +08:00
git push -f
git push --tags -f
2018-09-23 10:41:50 +08:00
echo "+ Done!"
2020-05-16 14:29:53 +08:00
fi