Scripts: add build step to build a censored android version for Google

This commit is contained in:
Pieter Vander Vennet 2025-07-08 03:43:39 +02:00
parent e3bd18ba52
commit 9419022d59

View file

@ -81,3 +81,84 @@ jobs:
git tag "${{ github.ref_name }}"
git push origin refs/heads/main --verbose
git push origin --tags
build_android_safe:
runs-on: hetzner-access
steps:
- uses: https://source.mapcomplete.org/actions/checkout@v4
with:
persist-credentials: true
- name: Set up Node.js
uses: https://source.mapcomplete.org/actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: package-lock.json
- name: clone submodule
shell: bash
run: |
echo -e "[submodule \"android\"]\n\tpath = android\n\turl = https://source.mapcomplete.org/MapComplete/android-wrapper" > .gitmodules
cat .gitmodules
git submodule init
git submodule update --init --recursive
cd android
git config --global --add safe.directory $(pwd)
git remote -v
git pull origin main
- name: install deps
run: npm ci
- run: |
npm run init
npm run generate:layeroverview --force --exclude-labels=nsfw
- name: Move dependency (@capacitor) into android repo
run: |
cd android
cp -r ../node_modules/@capacitor ./
sed "s/..\/node_modules\///g" -i capacitor.settings.gradle
cat capacitor.settings.gradle
git add capacitor.settings.gradle
- name: set android version number
run: |
cd android/app
version_code=$(grep versionCode "build.gradle" | grep -o '[0-9]\+')
new_version_code=$((version_code + 1))
versionname="${{ github.ref_name }}"
versionname="${versionname:1}"
sed -i "s/versionCode $version_code/versionCode $new_version_code/" "build.gradle"
sed -i "s/versionName \".*\"/versionName \"$versionname\"/" "build.gradle"
cat build.gradle | grep "versionName"
cat build.gradle | grep "versionCode"
if grep -q 'versionName ""' build.gradle; then
echo "Error: Empty versionName found in build.gradle"
exit 1
fi
git add build.gradle
- name: Run tests
run: npm run test
- name: prepare android build
run: npm run android:prepare
- name: Update android repo
run: |
cd android
git remote set-url origin "https://Bot:${{ secrets.BOT_PASSWORD }}@source.mapcomplete.org/MapComplete/android-wrapper"
git config user.name "Bot"
git config user.email "info@mapcomplete.org"
git add -f app/src/main/assets/public/*
git add capacitor.settings.gradle
git commit -am "Add files for release ${{ github.ref_name }}"
git tag "${{ github.ref_name }}-sfw"
git push origin refs/heads/main --verbose
git push origin --tags