diff --git a/.github/workflows/mt-dependency-update-baseline.yml b/.github/workflows/mt-dependency-update-baseline.yml index 17ac5d72..d524c3a2 100644 --- a/.github/workflows/mt-dependency-update-baseline.yml +++ b/.github/workflows/mt-dependency-update-baseline.yml @@ -55,21 +55,21 @@ jobs: fetch-depth: 0 # fetch all (not required util release build) - name: MT check out submodules run: ./checkout_submodules.sh - - name: MT check out all git submodule closest branch + - name: MT switch all git submodule closest branch if: github.event_name == 'pull_request' run: | - echo "[MT] > Checking out submodules closest branch, '$MT_BRANCH_NAME' or '$MT_TARGET_BRANCH_NAME' or '$MT_DEFAULT_BRANCH_NAME':" - git submodule foreach 'git checkout $MT_BRANCH_NAME || git checkout $MT_TARGET_BRANCH_NAME || git checkout $MT_DEFAULT_BRANCH_NAME' + echo "[MT] > Switching submodules closest branch, '$MT_BRANCH_NAME' or '$MT_TARGET_BRANCH_NAME' or '$MT_DEFAULT_BRANCH_NAME':" + git submodule foreach 'git switch $MT_BRANCH_NAME || git switch $MT_TARGET_BRANCH_NAME || git switch $MT_DEFAULT_BRANCH_NAME' echo "[MT] > Showing submodules current branch:" git submodule foreach 'git branch --show-current' - - name: MT check out this module repo build branch + - name: MT switch this module repo build branch run: | REPOSITORY_OWNER_AND_NAME=${{ github.repository }}; REPOSITORY_NAME=$(basename $REPOSITORY_OWNER_AND_NAME); echo "Repository name: '$REPOSITORY_NAME'." echo "Fetching from repo '$REPOSITORY_NAME':" git -C $REPOSITORY_NAME fetch -v --all; - echo "Checking our this repo '$REPOSITORY_NAME' workflow branch '$MT_BRANCH_NAME':" + echo "Switching this repo '$REPOSITORY_NAME' workflow branch '$MT_BRANCH_NAME':" git -C $REPOSITORY_NAME switch $MT_BRANCH_NAME; echo "Pulling from repo '$REPOSITORY_NAME':" git -C $REPOSITORY_NAME pull -v; diff --git a/cleanup.sh b/cleanup.sh index 6b62fd07..bdcf7711 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -118,9 +118,9 @@ function cleanupDirectory() { continue; fi local S_FILE_NAME_DEST=${S_FILE_NAME#"MT"}; # MT+filename used to ignore ".gitignore" - if [[ "$S_FILE_NAME_DEST" == *MTSTAR ]]; then - S_FILE_NAME_DEST_STARTS_WITH=${S_FILE_NAME_DEST%MTSTAR}; - S_FILE_NAME_DEST_LIST=$(find ${DEST_FILE_PATH}/ -mindepth 1 -maxdepth 1 -name "$S_FILE_NAME_DEST_STARTS_WITH*" -exec basename {} \; | xargs); + if [[ "$S_FILE_NAME_DEST" == *MTSTAR* ]]; then + S_FILE_NAME_DEST_REGEX=${S_FILE_NAME_DEST//MTSTAR*/*}; + S_FILE_NAME_DEST_LIST=$(find ${DEST_FILE_PATH}/ -mindepth 1 -maxdepth 1 -name "$S_FILE_NAME_DEST_REGEX" -exec basename {} \; | xargs); else # just use file name S_FILE_NAME_DEST_LIST="$S_FILE_NAME_DEST"; fi diff --git a/code_sync.sh b/code_sync.sh index 4af93988..c3a31da8 100755 --- a/code_sync.sh +++ b/code_sync.sh @@ -31,7 +31,7 @@ echo "-------------------------------------------------------------------------- echo "> Checkout branch '$GIT_BRANCH'..."; git submodule foreach git fetch -v --all; git submodule foreach git branch -v -a; -git submodule foreach git checkout $GIT_BRANCH; +git submodule foreach git switch $GIT_BRANCH; # git submodule foreach git switch --guess $GIT_BRANCH; # EXPERIMENTAL RESULT=$?; if [[ ${RESULT} -ne 0 ]]; then diff --git a/commons.sh b/commons.sh index 53f3a77a..b6eeba37 100644 --- a/commons.sh +++ b/commons.sh @@ -255,6 +255,7 @@ function printGitStatus() { echo "> [GIT STATUS & LOG]..."; echo "'$(basename $PWD)'" git config --get remote.origin.url; + echo "> status:"; git status -sb; STAGED_DIFF=$(git diff --cached | head -n $DIFF_LIMIT); if [ -n "$STAGED_DIFF" ]; then @@ -276,6 +277,7 @@ function printGitStatus() { echo "$LOG"; echo "--------------------------------------------------"; git submodule foreach " + echo \"> status:\"; git status -sb; git config --get remote.origin.url; STAGED_DIFF=\$(git diff --cached | head -n $DIFF_LIMIT); diff --git a/shared-modules/app-android/src/main/play/listings/en-US/graphics/feature-graphic/MT1.png.MT.sh b/shared-modules/app-android/src/main/play/listings/en-US/graphics/feature-graphic/MT1.png.MT.sh index 9f681913..e1d8def8 100755 --- a/shared-modules/app-android/src/main/play/listings/en-US/graphics/feature-graphic/MT1.png.MT.sh +++ b/shared-modules/app-android/src/main/play/listings/en-US/graphics/feature-graphic/MT1.png.MT.sh @@ -28,12 +28,11 @@ if [ -f "${FILE_1_PNG}" ]; then exit 0; # compat w/ manually created file else echo ">> File '$FILE_1_PNG' already exist: overriding image... (MT_GENERATE_IMAGES=$MT_GENERATE_IMAGES)"; + rm -f "${FILE_1_PNG}"; + checkResult $?; fi fi -rm -f "${FILE_1_PNG}"; -checkResult $?; - CONFIG_DIR="${ROOT_DIR}/config"; if [ ! -d "$CONFIG_DIR" ]; then echo "$CONFIG_DIR doesn't exist!"; diff --git a/shared-modules/app-android/src/main/play/listings/en-US/graphics/icon/MT1.png.MT.sh b/shared-modules/app-android/src/main/play/listings/en-US/graphics/icon/MT1.png.MT.sh index 9987833b..11056c7b 100755 --- a/shared-modules/app-android/src/main/play/listings/en-US/graphics/icon/MT1.png.MT.sh +++ b/shared-modules/app-android/src/main/play/listings/en-US/graphics/icon/MT1.png.MT.sh @@ -28,12 +28,11 @@ if [ -f "${FILE_1_PNG}" ]; then exit 0; # compat w/ manually created file else echo ">> File '$FILE_1_PNG' already exist: overriding image... (MT_GENERATE_IMAGES=$MT_GENERATE_IMAGES)"; + rm -f "${FILE_1_PNG}"; + checkResult $?; fi fi -rm -f "${FILE_1_PNG}"; -checkResult $?; - $ROOT_DIR/commons-android/pub/module-hi-res-app-icon.sh; # uses inkscape checkResult $?; diff --git a/shared-modules/app-android/src/main/res/MTmipmap-MTSTAR/MTmodule_app_icon.MTSTAR.MT.sh b/shared-modules/app-android/src/main/res/MTmipmap-MTSTAR/MTmodule_app_icon.MTSTAR.MT.sh new file mode 100755 index 00000000..9da9f829 --- /dev/null +++ b/shared-modules/app-android/src/main/res/MTmipmap-MTSTAR/MTmodule_app_icon.MTSTAR.MT.sh @@ -0,0 +1,139 @@ +#!/bin/bash +SCRIPT_DIR="$(dirname "$0")"; + +ROOT_DIR="$SCRIPT_DIR/../../../../../../.."; +COMMONS_DIR="${ROOT_DIR}/commons"; +source ${COMMONS_DIR}/commons.sh; + +setIsCI; + +setGitProjectName; + +echo ">> Generating mipmap-*/module_app_icon.[png|xml]..."; + +APP_ANDROID_DIR="${ROOT_DIR}/app-android"; +SRC_DIR="${APP_ANDROID_DIR}/src"; +MAIN_DIR="${SRC_DIR}/main"; +RES_DIR="${MAIN_DIR}/res"; +VALUES_DIR="${RES_DIR}/values" +mkdir -p "${VALUES_DIR}"; +checkResult $?; + +### values/module_app_icon_color.xml - START + +COLOR_FILE_NAME_XML="module_app_icon_color.xml" +COLOR_FILE_XML="${VALUES_DIR}/${COLOR_FILE_NAME_XML}"; +if [ -f "${COLOR_FILE_XML}" ]; then + echo ">> File '$COLOR_FILE_XML' already exist."; # compat with existing values/module_app_icon_color.xml +else + requireCommand "xmllint" "libxml2-utils"; + requireCommand "jq"; + GTFS_RDS_VALUES_GEN_FILE="$VALUES_DIR/gtfs_rts_values_gen.xml"; # do not change to avoid breaking compat w/ old modules + BIKE_STATION_VALUES_FILE="$VALUES_DIR/bike_station_values.xml"; + AGENCY_JSON_FILE="$ROOT_DIR/config/gtfs/agency.json"; + COLOR="" + if [ -f $GTFS_RDS_VALUES_GEN_FILE ]; then #1st because color computed + echo "> Agency file: '$GTFS_RDS_VALUES_GEN_FILE'." + COLOR=$(xmllint --xpath "//resources/string[@name='gtfs_rts_color']/text()" "$GTFS_RDS_VALUES_GEN_FILE") + elif [ -f $AGENCY_JSON_FILE ]; then + echo "> Agency file: '$AGENCY_JSON_FILE'." + COLOR=$(jq -r '.default_color // empty' "$AGENCY_JSON_FILE") + elif [ -f $BIKE_STATION_VALUES_FILE ]; then + echo "> Agency file: '$BIKE_STATION_VALUES_FILE'." + COLOR=$(xmllint --xpath "//resources/string[@name='bike_station_color']/text()" "$BIKE_STATION_VALUES_FILE") + else + echo "> No agency file! (rds:$GTFS_RDS_VALUES_GEN_FILE|json:$AGENCY_JSON_FILE|bike:$BIKE_STATION_VALUES_FILE)" + exit 1 # error + fi + echo " - color: $COLOR" + if [ -z "$COLOR" ]; then + echo " > No color found for agency type!" + exit 1 # error + fi + rm -f "${COLOR_FILE_XML}"; + checkResult $?; + touch "${COLOR_FILE_XML}"; + checkResult $?; + cat >>"${COLOR_FILE_XML}" < + + + #${COLOR} + +EOL + if [[ ${IS_CI} = true ]]; then + echo "---------------------------------------------------------------------------------------------------------------" + cat "${COLOR_FILE_XML}"; #DEBUG + echo "---------------------------------------------------------------------------------------------------------------" + fi +fi + +### values/module_app_icon_color.xml - END + +### mipmap-anydpi-v26/module_app_icon.xml - START + +FILE_NAME_XML="module_app_icon.xml" +MIPMAP_ANYDPI="${RES_DIR}/mipmap-anydpi-v26" +mkdir -p "${MIPMAP_ANYDPI}"; +checkResult $?; +FILE_XML="${MIPMAP_ANYDPI}/${FILE_NAME_XML}"; +if [ -f "${FILE_XML}" ]; then + echo ">> File '$FILE_XML' already exist."; # compat with existing mipmap-anydpi-v26/module_app_icon.xml +else + rm -f "${FILE_XML}"; + checkResult $?; + touch "${FILE_XML}"; + checkResult $?; + cat >>"${FILE_XML}" < + + + + + + +EOL + if [[ ${IS_CI} = true ]]; then + echo "---------------------------------------------------------------------------------------------------------------" + cat "${FILE_XML}"; #DEBUG + echo "---------------------------------------------------------------------------------------------------------------" + fi +fi + +$ROOT_DIR/commons-android/pub/module-res-mipmap-launcher-icon-adaptive.sh; +checkResult $?; + +### mipmap-anydpi-v26/module_app_icon.xml - END + +### mipmap-*/module_app_icon.png - START + +REQUIRED_ICON_FILE="${MAIN_DIR}/play/listings/en-US/graphics/icon/1.png"; +if [ ! -f "$REQUIRED_ICON_FILE" ]; then + $ROOT_DIR/commons/shared-modules/app-android/src/main/play/listings/en-US/graphics/icon/MT1.png.MT.sh; + checkResult $?; +fi + +FILE_NAME="module_app_icon.png"; +for DENSITY in mdpi hdpi xhdpi xxhdpi xxxhdpi; do + MIPMAP_DIR="${RES_DIR}/mipmap-${DENSITY}" + FILE_PNG="${MIPMAP_DIR}/${FILE_NAME}" + mkdir -p "${MIPMAP_DIR}" + checkResult $?; + if [ -f "${FILE_PNG}" ]; then + if [[ ${MT_GENERATE_IMAGES} != true ]]; then + echo ">> File '$FILE_PNG' already exist."; # compat with existing mipmap-*/module_app_icon.png + exit 0; # compat w/ manually created file + else + echo ">> File '$FILE_PNG' already exist: overriding image... (MT_GENERATE_IMAGES=$MT_GENERATE_IMAGES)"; + rm -f "${FILE_PNG}"; + checkResult $?; + fi + fi +done + +$ROOT_DIR/commons-android/pub/module-res-mipmap-launcher-icon.sh; +checkResult $?; + +### mipmap-*/module_app_icon.png - END + +echo ">> Generating mipmap-*/module_app_icon.[png|xml]... DONE"; diff --git a/shared-modules/app-android/src/main/res/MTmipmap-MTSTAR/MTmodule_app_icon.png.MT.sh b/shared-modules/app-android/src/main/res/MTmipmap-MTSTAR/MTmodule_app_icon.png.MT.sh deleted file mode 100755 index 90d4f4c0..00000000 --- a/shared-modules/app-android/src/main/res/MTmipmap-MTSTAR/MTmodule_app_icon.png.MT.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -SCRIPT_DIR="$(dirname "$0")"; - -ROOT_DIR="$SCRIPT_DIR/../../../../../../.."; -COMMONS_DIR="${ROOT_DIR}/commons"; -source ${COMMONS_DIR}/commons.sh; - -setIsCI; - -setGitProjectName; - -echo ">> Generating mipmap-*/module_app_icon.[png|xml]..."; - -APP_ANDROID_DIR="${ROOT_DIR}/app-android"; -SRC_DIR="${APP_ANDROID_DIR}/src"; -MAIN_DIR="${SRC_DIR}/main"; -RES_DIR="${MAIN_DIR}/res"; - -REQUIRED_ICON_FILE="${MAIN_DIR}/play/listings/en-US/graphics/icon/1.png"; -if [ ! -f "$REQUIRED_ICON_FILE" ]; then - $ROOT_DIR/commons/shared-modules/app-android/src/main/play/listings/en-US/graphics/icon/MT1.png.MT.sh; - checkResult $?; -fi - -FILE_NAME_XML="module_app_icon.xml" -MIPMAP_ANYDPI="${RES_DIR}/mipmap-anydpi-v26" -FILE_XML="${MIPMAP_ANYDPI}/${FILE_NAME_XML}"; -mkdir -p "${MIPMAP_ANYDPI}"; -checkResult $?; -if [ -f "${FILE_XML}" ]; then - echo ">> File '$FILE_XML' already exist."; # compat with existing mipmap-anydpi-v26/module_app_icon.xml -else - $ROOT_DIR/commons-android/pub/module-res-mipmap-launcher-icon-adaptive.sh; - checkResult $?; -fi - -FILE_NAME="module_app_icon.png"; - -MIPMAP_MDPI="${RES_DIR}/mipmap-mdpi"; -FILE_PNG="${MIPMAP_MDPI}/${FILE_NAME}"; -mkdir -p "${MIPMAP_MDPI}"; -checkResult $?; -if [ -f "${FILE_PNG}" ]; then - echo ">> File '$FILE_PNG' already exist."; # compat with existing mipmap-*/module_app_icon.png - exit 0; # compat w/ manually created file -fi -rm -f "${FILE_PNG}"; -checkResult $?; - -MIPMAP_HDPI="${RES_DIR}/mipmap-hdpi"; -FILE_PNG="${MIPMAP_HDPI}/${FILE_NAME}"; -mkdir -p "${MIPMAP_HDPI}"; -checkResult $?; -if [ -f "${FILE_PNG}" ]; then - echo ">> File '$FILE_PNG' already exist."; # compat with existing mipmap-*/module_app_icon.png - exit 0; # compat w/ manually created file -fi -rm -f "${FILE_PNG}"; -checkResult $?; - -MIPMAP_XHDPI="${RES_DIR}/mipmap-xhdpi"; -FILE_PNG="${MIPMAP_XHDPI}/${FILE_NAME}"; -mkdir -p "${MIPMAP_XHDPI}"; -checkResult $?; -if [ -f "${FILE_PNG}" ]; then - echo ">> File '$FILE_PNG' already exist."; # compat with existing mipmap-*/module_app_icon.png - exit 0; # compat w/ manually created file -fi -rm -f "${FILE_PNG}"; -checkResult $?; - -MIPMAP_XXHDPI="${RES_DIR}/mipmap-xxhdpi"; -FILE_PNG="${MIPMAP_XXHDPI}/${FILE_NAME}"; -mkdir -p "${MIPMAP_XXHDPI}"; -checkResult $?; -if [ -f "${FILE_PNG}" ]; then - echo ">> File '$FILE_PNG' already exist."; # compat with existing mipmap-*/module_app_icon.png - exit 0; # compat w/ manually created file -fi -rm -f "${FILE_PNG}"; -checkResult $?; - -MIPMAP_XXXHDPI="${RES_DIR}/mipmap-xxxhdpi"; -FILE_PNG="${MIPMAP_XXXHDPI}/${FILE_NAME}"; -mkdir -p "${MIPMAP_XXXHDPI}"; -checkResult $?; -if [ -f "${FILE_PNG}" ]; then - echo ">> File '$FILE_PNG' already exist."; # compat with existing mipmap-*/module_app_icon.png - exit 0; # compat w/ manually created file -fi -rm -f "${FILE_PNG}"; -checkResult $?; - -$ROOT_DIR/commons-android/pub/module-res-mipmap-launcher-icon.sh; -checkResult $?; - -echo ">> Generating mipmap-*/module_app_icon.[png|xml]... DONE"; \ No newline at end of file diff --git a/shared-overwrite/.github/workflows/mt-download-data.yml b/shared-overwrite/.github/workflows/mt-download-data.yml index f344d0ee..2ac7bc17 100644 --- a/shared-overwrite/.github/workflows/mt-download-data.yml +++ b/shared-overwrite/.github/workflows/mt-download-data.yml @@ -55,7 +55,7 @@ jobs: - name: MT setup if: steps.check-input-url.outputs.has_input_url == 'true' id: mt-setup - uses: mtransitapps/gh-actions/.github/actions/setup@v1.0.1 + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 with: code-sync: ${{ github.ref == format('refs/heads/{0}', env.MT_DEFAULT_BRANCH_NAME) }} diff --git a/shared-overwrite/.github/workflows/mt-image-gen.yml b/shared-overwrite/.github/workflows/mt-image-gen.yml new file mode 100644 index 00000000..cc5530d7 --- /dev/null +++ b/shared-overwrite/.github/workflows/mt-image-gen.yml @@ -0,0 +1,127 @@ +# ORIGINAL FILE: https://github.com/mtransitapps/commons/tree/master/shared-overwrite +name: MT generate images +on: + push: + branches: + - master + paths: + - 'app-android/src/main/res/values/gtfs_rts_values_gen.xml' # gtfs_rts_color | gtfs_rts_agency_type + - 'app-android/src/main/res/values/bike_station_values.xml' # bike_station_color | bike_station_agency_type + - 'config/gtfs/agency.json' # target_route_type_id | default_color + - 'config/agency_name' # feature graphic + - 'config/cities' # feature graphic + - 'config/state' # feature graphic + workflow_dispatch: # manual + inputs: + commitDirectly: + description: 'Commit directly to current branch (without PR)' + required: false + default: false + type: boolean +# gh workflow run mt-image-gen.yml --ref $(git rev-parse --abbrev-ref HEAD) +# gh workflow run mt-image-gen.yml --ref $(git rev-parse --abbrev-ref HEAD) -f commitDirectly=true +# gh run list --workflow=mt-image-gen.yml +# gh run watch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +env: + MT_BOT_USER_NAME: ${{ vars.MT_BOT_USER_NAME }} + MT_BOT_USER_EMAIL: ${{ vars.MT_BOT_USER_EMAIL }} + # git branches & sha + MT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + MT_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + MT_TARGET_BRANCH_NAME: ${{ github.base_ref || github.ref_name }} + MT_DEFAULT_BRANCH_NAME: ${{ github.event.repository.default_branch }} + # repo type + MT_IS_SUBMODULE: ${{ contains(fromJSON('["mtransitapps/commons", "mtransitapps/commons-java", "mtransitapps/parser", "mtransitapps/commons-android"]'), github.repository) }} + MT_IS_MAIN_REPO: ${{ endsWith(github.repository, '/mtransit-for-android') }} + MT_IS_AGENCY_REPO: ${{ ! contains(fromJSON('["mtransitapps/commons", "mtransitapps/commons-java", "mtransitapps/parser", "mtransitapps/commons-android"]'), github.repository) && ! endsWith(github.repository, '/mtransit-for-android')}} + MT_IS_AGENCY_RDS: ${{ ! contains(github.repository, '-bike-') }} + MT_IS_AGENCY_BIKE: ${{ contains(github.repository, '-bike-') }} + # git commit & push + MT_ORG_GIT_COMMIT_ON: ${{ secrets.MT_ORG_GIT_COMMIT_ON }} + MT_ORG_GIT_COMMIT_OFF: ${{ secrets.MT_ORG_GIT_COMMIT_OFF }} + MT_GIT_COMMIT_ON: ${{ secrets.MT_GIT_COMMIT_ON }} + MT_GIT_COMMIT_OFF: ${{ secrets.MT_GIT_COMMIT_OFF }} +jobs: + MT-GENERATE-IMAGES-JOB: + name: "MT generate images" + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - name: MT check out main repository code + uses: actions/checkout@v6 + with: + token: ${{ secrets.MT_PAT }} + + - name: MT setup + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 + with: + image-gen: true + + - name: MT commit images + continue-on-error: true + id: mt-commit-images + run: | + # Check if images were generated + IMAGE_COUNT=$(git status --porcelain -- ':(glob)**/*.png' | wc -l) + if [ "$IMAGE_COUNT" -gt 0 ]; then + echo "Found $IMAGE_COUNT changed PNG file(s)." + git add -v -A -- ':(glob)**/*.png' + if git diff --staged --quiet; then + echo "No new images to commit." + exit 1 # fail == no PR needed + fi + git config user.name "$MT_BOT_USER_NAME" + git config user.email "$MT_BOT_USER_EMAIL" + if [ "${{ github.event.inputs.commitDirectly }}" = "true" ]; then + echo "Committing directly to current branch: ${MT_BRANCH_NAME}" + git commit -m "Update images in \`${MT_BRANCH_NAME}\`" + git push origin "${MT_BRANCH_NAME}" + exit 1 # fail == no PR needed + else + echo "Creating new branch and preparing for PR: ${MT_BRANCH_NAME}_update_images" + git switch -C "${MT_BRANCH_NAME}_update_images" + git commit -m "Update images in \`${MT_BRANCH_NAME}\`" + git push -u origin "${MT_BRANCH_NAME}_update_images" --force + fi + exit 0 # success == PR needed + else + echo "No PNG changes found." + exit 1 # fail == no PR needed + fi + + - name: MT check if PR exists + id: mt-check-pr-exists + if: ${{ steps.mt-commit-images.outcome == 'success' }} + continue-on-error: true + run: | + # Fetch the branch to ensure it exists in the remote tracking + git fetch origin "${MT_BRANCH_NAME}_update_images" || true + PR_COUNT=$(gh pr list --state open --head "${MT_BRANCH_NAME}_update_images" | wc -l) + echo "Pull requests found: $PR_COUNT." + if [[ $PR_COUNT -eq 0 ]]; then + exit 1 # fail == PR need to be created + else + exit 0 # success == PR need to be updated + fi + env: + GH_TOKEN: ${{ secrets.MT_PAT }} + + - name: MT create pull request (if necessary) + if: ${{ steps.mt-commit-images.outcome == 'success' && steps.mt-check-pr-exists.outcome == 'failure' }} + run: | + COMMIT_MSG=$(git log -1 --pretty=%B) + gh pr create --base "${MT_BRANCH_NAME}" --title "$COMMIT_MSG" --body "$COMMIT_MSG" --assignee montransit + gh pr comment --body "@mtransitapps/reviewers please review" # --reviewer mtransitapps/reviewers + env: + GH_TOKEN: ${{ secrets.MT_PAT }} + + - name: MT update pull request (if necessary) + if: ${{ steps.mt-commit-images.outcome == 'success' && steps.mt-check-pr-exists.outcome == 'success' }} + run: | + gh pr edit --add-assignee montransit --title "Update images in \`${MT_BRANCH_NAME}\`" + gh pr comment --body "@mtransitapps/reviewers please review" # --reviewer mtransitapps/reviewers + env: + GH_TOKEN: ${{ secrets.MT_PAT }} diff --git a/shared-overwrite/.github/workflows/mt-record-screenshots.yml b/shared-overwrite/.github/workflows/mt-record-screenshots.yml index c2243574..f6095197 100644 --- a/shared-overwrite/.github/workflows/mt-record-screenshots.yml +++ b/shared-overwrite/.github/workflows/mt-record-screenshots.yml @@ -52,7 +52,7 @@ jobs: token: ${{ secrets.MT_PAT }} - name: MT setup - uses: mtransitapps/gh-actions/.github/actions/setup@v1.0.1 + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 - name: MT read sdk-target from gradle/libs.versions.toml id: sdk-target @@ -203,7 +203,7 @@ jobs: exit 1 # fail == no PR needed else echo "Creating new branch and preparing for PR: ${MT_BRANCH_NAME}_update_screenshots" - git checkout -B "${MT_BRANCH_NAME}_update_screenshots" + git switch -C "${MT_BRANCH_NAME}_update_screenshots" git commit -m "Update screenshots in \`${MT_BRANCH_NAME}\`" git push -u origin "${MT_BRANCH_NAME}_update_screenshots" --force fi diff --git a/shared-overwrite/.github/workflows/mt-release.yml b/shared-overwrite/.github/workflows/mt-release.yml index 41a7b799..1d53f83f 100644 --- a/shared-overwrite/.github/workflows/mt-release.yml +++ b/shared-overwrite/.github/workflows/mt-release.yml @@ -90,7 +90,7 @@ jobs: - name: MT setup id: mt-setup - uses: mtransitapps/gh-actions/.github/actions/setup@v1.0.1 + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 - name: MT enable app release run: | diff --git a/shared-overwrite/.github/workflows/mt-store-channels.yml b/shared-overwrite/.github/workflows/mt-store-channels.yml index 5621d36d..315f9927 100644 --- a/shared-overwrite/.github/workflows/mt-store-channels.yml +++ b/shared-overwrite/.github/workflows/mt-store-channels.yml @@ -105,7 +105,7 @@ jobs: echo "No changes to commit." exit 1 # fail fi - git checkout -B "${MT_BRANCH_NAME}_update_store_channels" + git switch -C "${MT_BRANCH_NAME}_update_store_channels" git config user.name "$MT_BOT_USER_NAME" git config user.email "$MT_BOT_USER_EMAIL" git commit -m "Update store channels in \`${MT_BRANCH_NAME}\`" diff --git a/shared-overwrite/.github/workflows/mt-store-listing-pull.yml b/shared-overwrite/.github/workflows/mt-store-listing-pull.yml index 6010112c..3653bf38 100644 --- a/shared-overwrite/.github/workflows/mt-store-listing-pull.yml +++ b/shared-overwrite/.github/workflows/mt-store-listing-pull.yml @@ -39,7 +39,7 @@ jobs: token: ${{ secrets.MT_PAT }} - name: MT setup - uses: mtransitapps/gh-actions/.github/actions/setup@v1.0.1 + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 - name: MT pull store listings env: @@ -55,7 +55,7 @@ jobs: echo "No changes to commit." exit 1 # fail == no PR needed fi - git checkout -B "${MT_BRANCH_NAME}_update_store_listings" + git switch -C "${MT_BRANCH_NAME}_update_store_listings" git config user.name "$MT_BOT_USER_NAME" git config user.email "$MT_BOT_USER_EMAIL" git commit -m "Update store listings in \`${MT_BRANCH_NAME}\`" diff --git a/shared-overwrite/.github/workflows/mt-store-listing-push.yml b/shared-overwrite/.github/workflows/mt-store-listing-push.yml index 9ee6b01b..dacaa099 100644 --- a/shared-overwrite/.github/workflows/mt-store-listing-push.yml +++ b/shared-overwrite/.github/workflows/mt-store-listing-push.yml @@ -51,7 +51,7 @@ jobs: - name: MT setup id: mt-setup - uses: mtransitapps/gh-actions/.github/actions/setup@v1.0.1 + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 - name: MT push store listing run: ./app-android/listing_push.sh diff --git a/shared-overwrite/.github/workflows/mt-sync-code-data.yml b/shared-overwrite/.github/workflows/mt-sync-code-data.yml index ffc02b25..ce79e81e 100644 --- a/shared-overwrite/.github/workflows/mt-sync-code-data.yml +++ b/shared-overwrite/.github/workflows/mt-sync-code-data.yml @@ -52,6 +52,8 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: + MT_BOT_USER_NAME: ${{ vars.MT_BOT_USER_NAME }} + MT_BOT_USER_EMAIL: ${{ vars.MT_BOT_USER_EMAIL }} # git branches & sha MT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} MT_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} @@ -106,7 +108,7 @@ jobs: - name: MT setup id: mt-setup - uses: mtransitapps/gh-actions/.github/actions/setup@v1.0.1 + uses: mtransitapps/gh-actions/.github/actions/setup@v1.1.2 with: code-sync: ${{ github.ref == format('refs/heads/{0}', env.MT_DEFAULT_BRANCH_NAME) }} @@ -117,6 +119,7 @@ jobs: # DOWNLOAD (not PR) AND PARSE (NOT main repo/bike) - name: MT download data (& archive) if: ${{ github.event_name != 'pull_request' && env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' && github.event.inputs.skip-download-data != 'true' }} + id: mt-download-data timeout-minutes: 10 continue-on-error: true # optional (continue with archive data) run: ./download_only.sh @@ -146,12 +149,26 @@ jobs: if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} run: ./parse_list_change.sh + - name: MT check if image generation required + id: mt-check-image-gen-required + continue-on-error: true + if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} + run: | + RESULT=$(git status --porcelain -- "app-android/src/main/res/values/gtfs_rts_values_gen.xml" | wc -l) + if [ "$RESULT" -gt 0 ]; then + echo "Image generation required."; + exit 0 # success + else + echo "No image generation required."; + exit 1 # fail + fi + - name: MT push commits if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} run: ./push_commits.sh - name: MT artifact > GTFS files - if: ${{ !cancelled() && env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} # even if tests fails + if: ${{ !cancelled() && env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' && steps.mt-download-data.conclusion != 'skipped' }} # even if tests fails uses: actions/upload-artifact@v7 with: name: gtfs @@ -161,7 +178,7 @@ jobs: retention-days: 31 - name: MT artifact > GTFS validator results - if: ${{ !cancelled() && env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} # even if tests fails + if: ${{ !cancelled() && env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' && steps.mt-download-data.conclusion != 'skipped' }} # even if tests fails uses: actions/upload-artifact@v7 with: name: gtfs-validator-results @@ -174,6 +191,26 @@ jobs: run: ./commit_data_change.sh # ---------- + - name: MT generate images if required + if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' && steps.mt-check-image-gen-required.outcome == 'success' }} + run: | + ./commons/code_setup.sh; + env: + MT_GENERATE_IMAGES: true + + - name: MT commit image change (if added/updated) + if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} + run: | + git add -v -A -- ':(glob)**/*.png' + if git diff --staged --quiet; then + echo "No new images to commit." + else + echo "Committing generated images."; + git config user.name "$MT_BOT_USER_NAME" + git config user.email "$MT_BOT_USER_EMAIL" + git commit -m "CI: update generated images" + fi + - name: MT set app release required (or not) if: ${{ github.event_name != 'pull_request' && github.event.inputs.skip-app-release != 'true' }} run: ./set_app_release_required.sh diff --git a/shared/app-android/MT.gitignore b/shared/app-android/MT.gitignore index 656aa033..f57259e5 100644 --- a/shared/app-android/MT.gitignore +++ b/shared/app-android/MT.gitignore @@ -68,7 +68,8 @@ proguard/ /src/main/play/listings/fr-FR/title.txt /src/main/play/listings/fr-FR/short-description.txt /src/main/play/listings/fr-FR/full-description.txt -/src/main/res/mipmap-*/module_app_icon* +# /src/main/res/mipmap-*/module_app_icon*.png # generated images optional +/src/main/res/mipmap-anydpi-v26/module_app_icon.xml /src/main/res/values/bike_station_strings.xml /src/main/res/values/strings.xml /src/main/res/values/gtfs_rts_strings.xml diff --git a/shared/build.sh b/shared/build.sh index 575a4f23..ca92955c 100755 --- a/shared/build.sh +++ b/shared/build.sh @@ -49,7 +49,7 @@ if [[ $CIRCLECI != "true" ]]; then echo "> GIT repo up-to-date in '$DIRECTORY' (local:$GIT_REV_PARSE_HEAD|origin/$GIT_BRANCH:$GIT_REV_PARSE_REMOTE_BRANCH)."; fi - git checkout ${GIT_BRANCH}; + git switch ${GIT_BRANCH}; checkResult $? ${CONFIRM}; echo "> GIT cleaning in '$DIRECTORY'... DONE"; cd ..; diff --git a/sync.sh b/sync.sh index 118cca9d..fab3df85 100755 --- a/sync.sh +++ b/sync.sh @@ -123,7 +123,7 @@ for S in "${!SUBMODULES[@]}"; do echo " DONE ✓"; fi echo "> Setting submodule branch '$GIT_BRANCH' in '$SUBMODULE'..."; - git checkout $GIT_BRANCH; + git switch $GIT_BRANCH; RESULT=$?; if [[ ${RESULT} -ne 0 ]]; then echo "> Error while checking out '$GIT_BRANCH' in '$SUBMODULE_REPO' submodule in '$SUBMODULE'!";