Skip to content

Merge "Update addCustomAsset and addCustomSourceFolders to highlight"… #70

Merge "Update addCustomAsset and addCustomSourceFolders to highlight"…

Merge "Update addCustomAsset and addCustomSourceFolders to highlight"… #70

name: Convert recipes flow
on:
push:
workflow_dispatch:
schedule:
- cron: '0 8 * * 0' # Run every Sunday at 8:00 UTC
jobs:
build-gradle-project:
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v3
with:
path: main
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Initialize mandatory git config
run: |
cd main
git config user.name "GitHub Actions"
git config user.email [email protected]
- name: Checkout and run build converter tool
run: |
ls
cd main
git fetch --all --depth=1
cd convert-tool
./gradlew standaloneJar
echo "Built converter"
cd ..
- name: Convert recipes
run: |
cd main
RECIPES_CONVERTER_JAR="convert-tool/app/build/libs/recipes-converter-all.jar"
curl -o $RUNNER_TEMP/maven_metadata.xml \
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/maven-metadata.xml
grep -v "^#" version_mappings.txt | while read line
do
versions=(${line//;/ })
AGP_MAJOR_MINOR=${versions[0]}
GRADLE=${versions[1]}
echo "Converting for AGP $AGP_MAJOR_MINOR with Gradle $GRADLE"
BRANCH="agp-"
BRANCH+=$AGP_MAJOR_MINOR
BRANCH_DIR="../$BRANCH"
echo "Working on branch $BRANCH in $BRANCH_DIR"
mkdir $BRANCH_DIR
cp -r .git "$BRANCH_DIR/.git"
AGP_VERSION=$(java -cp "$RECIPES_CONVERTER_JAR" \
com.google.android.gradle_recipe.converter.versioning.LatestVersionFinderKt \
$RUNNER_TEMP/maven_metadata.xml $AGP_MAJOR_MINOR)
if [ "$AGP_VERSION" = "NA" ]; then
echo "No released version available for AGP $AGP_MAJOR_MINOR."
continue
fi
STANDALONE_JAR=true java -jar "$RECIPES_CONVERTER_JAR" \
convert --sourceAll recipes \
--destination "$BRANCH_DIR" \
--agpVersion "$AGP_VERSION" --gradleVersion "$GRADLE" --overwrite
echo "Converted recipes"
cd $BRANCH_DIR
find . -name gradlew | xargs chmod +x
git branch $BRANCH origin/${GITHUB_REF##*/} || git branch $BRANCH
git reset $BRANCH
git checkout $BRANCH
git add -A
echo "Ready for commit"
git commit --message "Prepare release" || echo "Nothing to commit"
git push -f --set-upstream origin $BRANCH
echo "Done for $BRANCH"
cd ../main
done
cd ..