Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MT build (git submodule)
name: MT build
on:
workflow_dispatch: # manual
pull_request:
Expand All @@ -7,8 +7,8 @@ on:
# - '**' # ALL
- 'master'
# TODO 'develop', 'main'?
# gh workflow run mt-build-module.yml --ref <branch>
# gh run list --workflow=mt-build-module.yml
# gh workflow run mt-build.yml --ref <branch>
# gh run list --workflow=mt-build.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.head_ref }}
cancel-in-progress: true
Expand All @@ -18,31 +18,39 @@ env:
MT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
jobs:
MT-BUILD-JOB:
name: "MT Build (git submodule)"
name: "MT Build"
runs-on: ubuntu-latest
steps:

- name: MT select main repo checkout branch
id: mt-pick-main-repo-checkout-branch
env:
GH_TOKEN: ${{ github.token }} # GitHub CLI in a GitHub Actions workflow
run: |
MAIN_REPO_URL="https://github.com/mtransitapps/mtransit-for-android.git"
BRANCH_EXISTS=$(git ls-remote --heads $MAIN_REPO_URL $MT_BRANCH_NAME | wc -l);
if [ $BRANCH_EXISTS -eq 1 ]; then
CHECKOUT_BRANCH=$MT_BRANCH_NAME
REPOSITORY_OWNER_AND_NAME=${{ github.repository }};
REPOSITORY_NAME=$(basename $REPOSITORY_OWNER_AND_NAME);
if [ $REPOSITORY_OWNER_AND_NAME = "mtransitapps/mtransit-for-android" ]; then
CHECKOUT_BRANCH="" # defaults to the reference or SHA for that event
else
# Pull request target branch with same name?
BRANCH_EXISTS=$(git ls-remote --heads $MAIN_REPO_URL $MT_TARGET_BRANCH_NAME | wc -l);
MAIN_REPO_URL="https://github.com/mtransitapps/mtransit-for-android.git"
BRANCH_EXISTS=$(git ls-remote --heads $MAIN_REPO_URL $MT_BRANCH_NAME | wc -l);
if [ $BRANCH_EXISTS -eq 1 ]; then
CHECKOUT_BRANCH=$MT_TARGET_BRANCH_NAME
CHECKOUT_BRANCH=$MT_BRANCH_NAME
else
echo "WARNING: no match for current or target branch!!!"
DEFAULT_REPO_BRANCH=$(gh api repos/mtransitapps/mtransit-for-android --jq '.default_branch');
CHECKOUT_BRANCH=$DEFAULT_REPO_BRANCH
# Pull request target branch with same name?
BRANCH_EXISTS=$(git ls-remote --heads $MAIN_REPO_URL $MT_TARGET_BRANCH_NAME | wc -l);
if [ $BRANCH_EXISTS -eq 1 ]; then
CHECKOUT_BRANCH=$MT_TARGET_BRANCH_NAME
else
echo "WARNING: no match for current or target branch!!!"
DEFAULT_REPO_BRANCH=$(gh api repos/mtransitapps/mtransit-for-android --jq '.default_branch');
CHECKOUT_BRANCH=$DEFAULT_REPO_BRANCH
fi
fi
fi
echo "Checkout branch: '$CHECKOUT_BRANCH'."
echo "mt_checkout_branch=$CHECKOUT_BRANCH" >> "$GITHUB_OUTPUT"

- name: MT check out main repo
uses: actions/checkout@v5
with:
Expand All @@ -59,16 +67,23 @@ jobs:
git submodule foreach 'git checkout $MT_BRANCH_NAME || git checkout $MT_TARGET_BRANCH_NAME'
echo "Showing submodules current branch:"
git submodule foreach 'git branch --show-current'

- name: MT check out this module repo build SHA
if: github.repository != 'mtransitapps/mtransit-for-android'
run: |
REPOSITORY_OWNER_AND_NAME=${{ github.repository }};
REPOSITORY_NAME=$(basename $REPOSITORY_OWNER_AND_NAME);
echo "Checking our this repo '$REPOSITORY_NAME' workflow sha '$MT_SHA':"
git -C $REPOSITORY_NAME checkout $MT_SHA;

- name: MT setup MT_GIT_BRANCH env
if: github.event_name != 'pull_request'
if: github.repository == 'mtransitapps/mtransit-for-android' || github.event_name != 'pull_request'
run: |
echo "MT_GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
# MT_GIT_BRANCH=${GITHUB_REF##*/}"
MT_GIT_BRANCH=${{ github.head_ref || github.ref_name }}
# echo "MT_GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "MT_GIT_BRANCH=$MT_GIT_BRANCH" >> $GITHUB_ENV

- name: MT code setup
run: ./commons/code_setup.sh
- name: MT set up JDK 17
Expand All @@ -77,11 +92,12 @@ jobs:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v5

- name: MT test
run: ./test.sh
- name: MT artifact > unit tests XML results
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
if: ${{ always() }} # even if tests fails
with:
name: unit-test-xml-results
Expand All @@ -90,20 +106,21 @@ jobs:
*/build/test-results/*.xml
*/build/reports/*.xml
- name: MT artifact > HTML reports
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
if: ${{ always() }} # even if tests fails
with:
name: html-reports
path: |
*/build/reports/
!**/*.xml

- name: MT assemble release (APK & ABB)
if: github.event_name != 'pull_request'
run: ./assemble_release.sh
env:
MT_ENCRYPT_KEY: ${{ secrets.MT_ENCRYPT_KEY }}
- name: MT artifact > app-android > APK & ABB
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: app-android-apk-bundle
path: |
Expand Down
Loading