MapComplete/.forgejo/workflows/on_release.yml

84 lines
2.7 KiB
YAML

on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
build_android:
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 -- --print-needed-assets
- 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
# We assign the version code simply based on the date
new_version_code=$(( ( $(date +%s) - $(date -d "2025-07-01" +%s) ) / 86400 ))
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: 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 }}"
git push origin refs/heads/main --verbose
git push origin --tags