blob: a5c96629744d77a787c1dac1de4fea6bc5847466 [file] [log] [blame]
Dustin Lam9dd12272021-08-06 18:45:48 -07001#!/bin/bash
Dustin Lame1f0ca12021-08-27 09:45:00 -07002MODE=${1:-s}
Dustin Lamec68c7f2022-04-04 13:36:16 -07003
4# Needed for compat between GNU sed (Linux default) and BSD sed (OSX default).
5# - GNU sed requires no space between value for -i
6# - BSD sed requires that a value be passed for -i.
7function fn_sed_inplace {
8 sed -i.bak "$@" && rm "${@: -1}.bak"
9}
10
Dustin Lame1f0ca12021-08-27 09:45:00 -070011function fn_update_snapshot {
12 BUILDID_ANDROIDX=`curl -s https://androidx.dev/snapshots/builds | sed -nr 's|.*snapshots/builds/([0-9]*).*|\1|gp' | head -n 1`
13 echo "Updating snapshot id: $BUILDID_ANDROIDX"
Dustin Lamec68c7f2022-04-04 13:36:16 -070014 fn_sed_inplace "s/androidx.playground.snapshotBuildId=.*/androidx.playground.snapshotBuildId=$BUILDID_ANDROIDX/g" playground-common/playground.properties
Dustin Lame1f0ca12021-08-27 09:45:00 -070015}
Dustin Lam9dd12272021-08-06 18:45:48 -070016
Dustin Lame1f0ca12021-08-27 09:45:00 -070017function fn_update_metalava {
18 BUILDID_METALAVA=`curl -s https://androidx.dev/metalava/builds | sed -nr 's|.*metalava/builds/([0-9]*).*|\1|gp' | head -n 1`
19 echo "Updating metalava id: $BUILDID_METALAVA"
Dustin Lamec68c7f2022-04-04 13:36:16 -070020 fn_sed_inplace "s/androidx.playground.metalavaBuildId=.*/androidx.playground.metalavaBuildId=$BUILDID_METALAVA/g" playground-common/playground.properties
Dustin Lame1f0ca12021-08-27 09:45:00 -070021}
Dustin Lam9dd12272021-08-06 18:45:48 -070022
Dustin Lame1f0ca12021-08-27 09:45:00 -070023if [ "$MODE" == "s" ]; then
24 fn_update_snapshot
25elif [ "$MODE" == "a" ]; then
26 fn_update_snapshot
27 fn_update_metalava
Dustin Lame1f0ca12021-08-27 09:45:00 -070028fi