|
| 1 | +# This is workflow to build Android app for testing |
| 2 | + |
| 3 | +name: The latest Android build from main-branch |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Triggers the workflow on push or pull request events but only for the "main" branch |
| 8 | + push: |
| 9 | + branches: [ "main" ] |
| 10 | + |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 15 | +# Build job needs test ! |
| 16 | +jobs: |
| 17 | + |
| 18 | + # Run React Native Eslint and Jest tests |
| 19 | + test: |
| 20 | + if: ${{ false }} |
| 21 | + name: Test |
| 22 | + # Setup Ubuntu version |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + # Node version matrix |
| 26 | + matrix: |
| 27 | + node-version: [20.11.1] |
| 28 | + # Steps |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + - name: Use Node.js ${{ matrix.node-version }} |
| 32 | + # Setup node |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: ${{ matrix.node-version }} |
| 36 | + cache: 'yarn' |
| 37 | + # Install dependencies |
| 38 | + - name: Install dependencies |
| 39 | + run: yarn install |
| 40 | + # Get defaultConfig |
| 41 | + - name: Get defaultConfig |
| 42 | + env: |
| 43 | + defaultConfig: ${{ secrets.DEFAULTCONFIG }} |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + touch defaultConfig.ts |
| 47 | + echo "$defaultConfig" >> defaultConfig.ts |
| 48 | +
|
| 49 | + # Run lint -tests |
| 50 | + - name: Run Eslint tests |
| 51 | + if: ${{ false }} |
| 52 | + run: yarn lint --fix |
| 53 | + # Run Jest -tests |
| 54 | + - name: Run Jest tests |
| 55 | + if: ${{ false }} |
| 56 | + run: yarn test |
| 57 | + |
| 58 | +# Decode, Build and sign Android application |
| 59 | + build: |
| 60 | + # needs: test |
| 61 | + name: Android-build |
| 62 | + # Set Ubuntu version |
| 63 | + runs-on: ubuntu-latest |
| 64 | + # Node version matrix |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + node-version: [20.11.1] |
| 68 | + # Steps |
| 69 | + steps: |
| 70 | + - name: Checkout to git repository |
| 71 | + uses: actions/checkout@v4 |
| 72 | + # Setup Node |
| 73 | + - uses: actions/setup-node@v4 |
| 74 | + with: |
| 75 | + node-version: ${{ matrix.node-version }} |
| 76 | + cache: 'yarn' |
| 77 | + - name: Install dependencies |
| 78 | + run: | |
| 79 | + yarn install |
| 80 | +
|
| 81 | + # Get defaultConfig |
| 82 | + - name: Get defaultConfig |
| 83 | + env: |
| 84 | + defaultConfig: ${{ secrets.DEFAULTCONFIG }} |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + touch defaultConfig.ts |
| 88 | + echo "$defaultConfig" >> defaultConfig.ts |
| 89 | +
|
| 90 | + # Set up Java 17 |
| 91 | + - name: Set up Java 17 |
| 92 | + uses: actions/setup-java@v3 |
| 93 | + with: |
| 94 | + java-version: '17' |
| 95 | + distribution: 'temurin' # You can use 'adopt', 'zulu', or another distribution if needed |
| 96 | + |
| 97 | + # Install Ruby |
| 98 | + - name: Install Ruby |
| 99 | + uses: ruby/setup-ruby@v1 |
| 100 | + with: |
| 101 | + ruby-version: '3.3.0' |
| 102 | + |
| 103 | + # Update bundler |
| 104 | + - name: Update bundler |
| 105 | + run: bundle update --bundler |
| 106 | + working-directory: android |
| 107 | + |
| 108 | + # Bundle install |
| 109 | + - name: Bundle install |
| 110 | + run: gem install bundler && bundle install |
| 111 | + working-directory: android |
| 112 | + |
| 113 | + # Decode upload keystore |
| 114 | + - name: Decode Keystore File |
| 115 | + uses: timheuer/base64-to-file@v1 |
| 116 | + id: android_keystore |
| 117 | + with: |
| 118 | + fileName: "android_keystore.keystore" |
| 119 | + encodedString: ${{ secrets.KEYSTORE }} |
| 120 | + |
| 121 | + # Build and sign |
| 122 | + - name: Build |
| 123 | + env: |
| 124 | + KEYSTORE: ${{ steps.android_keystore.outputs.filePath }} |
| 125 | + SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} |
| 126 | + SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} |
| 127 | + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} |
| 128 | + # SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }} |
| 129 | + run: | |
| 130 | + echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" > .env |
| 131 | + chmod +x ./gradlew |
| 132 | + bundle exec fastlane android build_apk |
| 133 | + working-directory: android |
| 134 | + |
| 135 | + - name: Rename APK |
| 136 | + run: |
| 137 | + mv "./app/build/outputs/apk/release/app-release.apk" "./app/build/outputs/apk/release/latest.apk" |
| 138 | + working-directory: android |
| 139 | + |
| 140 | + # Upload artifact |
| 141 | + - name: Upload build artifacts |
| 142 | + uses: actions/upload-artifact@v4 |
| 143 | + with: |
| 144 | + name: latest.apk |
| 145 | + path: | |
| 146 | + ${{ github.workspace }}/android/app/build/outputs/apk/release/latest.apk |
| 147 | + retention-days: 7 |
| 148 | + overwrite: true |
0 commit comments