From 018491f688aa6b664f8288fe5f24dd3b551bf9b6 Mon Sep 17 00:00:00 2001 From: razinj Date: Wed, 26 Jun 2024 01:12:28 +0200 Subject: [PATCH] feat: improve workflows dependencies --- .github/workflows/build.yml | 79 +++++++++++++++++++++++------- .github/workflows/code-style.yml | 10 ++-- .github/workflows/common-build.yml | 67 ------------------------- .github/workflows/main.yml | 23 +++++++++ .github/workflows/release.yml | 18 +++---- .github/workflows/tests.yml | 9 +--- 6 files changed, 96 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/common-build.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d4b829..22d36b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,67 @@ name: build on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_run: - workflows: [tests] - types: - - completed - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + workflow_call: jobs: - prepare-artifacts: - uses: ./.github/workflows/common-build.yml - secrets: inherit + build-and-upload-artifacts: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - name: Install Node.js Dependencies + run: npm ci + + - name: Use Java 17 + uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "microsoft" + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Decode and save the keystore file + run: | + # Upload store file was encoded: base64 -i upload.keystore -o ~/upload.keystore.base64 + echo ${{ secrets.CONTEXT_LAUNCHER_UPLOAD_STORE_FILE }} | base64 --decode > $GITHUB_WORKSPACE/android/app/upload.keystore + + - name: Prepare local.properties file + run: | + # Since the password contains a dollar sign ($) I had to encode it and decode it here. + STORE_PASSWORD=$(echo "${{ secrets.CONTEXT_LAUNCHER_UPLOAD_STORE_PASSWORD_BASE64 }}" | base64 --decode) + KEY_PASSWORD=$(echo "${{ secrets.CONTEXT_LAUNCHER_UPLOAD_KEY_PASSWORD_BASE64 }}" | base64 --decode) + echo "sdk.dir=$ANDROID_SDK_ROOT" > $GITHUB_WORKSPACE/android/local.properties + echo "CONTEXT_LAUNCHER_UPLOAD_STORE_FILE=$GITHUB_WORKSPACE/android/app/upload.keystore" >> $GITHUB_WORKSPACE/android/local.properties + echo "CONTEXT_LAUNCHER_UPLOAD_STORE_PASSWORD=$STORE_PASSWORD" >> $GITHUB_WORKSPACE/android/local.properties + echo "CONTEXT_LAUNCHER_UPLOAD_KEY_ALIAS=${{ secrets.CONTEXT_LAUNCHER_UPLOAD_KEY_ALIAS }}" >> $GITHUB_WORKSPACE/android/local.properties + echo "CONTEXT_LAUNCHER_UPLOAD_KEY_PASSWORD=$KEY_PASSWORD" >> $GITHUB_WORKSPACE/android/local.properties + + - name: Build + working-directory: ./android + run: ./gradlew --no-daemon build + + - name: Build Debug - APK + working-directory: ./android + run: ./gradlew --no-daemon assembleDebug + + - name: Build Release - APK & AAB + working-directory: ./android + run: | + ./gradlew --no-daemon assembleRelease + ./gradlew --no-daemon bundleRelease + + - name: Upload Debug & Release Binaries + uses: actions/upload-artifact@v4 + with: + name: context-launcher-debug-and-release-apk-and-aab + path: | + android/app/build/outputs/apk/debug/*.apk + android/app/build/outputs/apk/release/*.apk + android/app/build/outputs/bundle/release/*.aab diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 3acca76..f60ff26 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -1,13 +1,10 @@ name: code-style -on: [push] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true +on: + workflow_call: jobs: - check-formatting: + formatting: runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -20,6 +17,7 @@ jobs: - name: Install Dependencies run: npm ci + - name: Check Formatting run: npm run format:ci diff --git a/.github/workflows/common-build.yml b/.github/workflows/common-build.yml deleted file mode 100644 index 903c6d7..0000000 --- a/.github/workflows/common-build.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: common-build - -on: - workflow_call: - -jobs: - build-and-upload-artifacts: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: "20.x" - - - name: Install Node.js Dependencies - run: npm ci - - - name: Use Java 17 - uses: actions/setup-java@v4 - with: - java-version: "17" - distribution: "microsoft" - - - name: Setup Android SDK - uses: android-actions/setup-android@v3 - - - name: Decode and save the keystore file - run: | - # Upload store file was encoded: base64 -i upload.keystore -o ~/upload.keystore.base64 - echo ${{ secrets.CONTEXT_LAUNCHER_UPLOAD_STORE_FILE }} | base64 --decode > $GITHUB_WORKSPACE/android/app/upload.keystore - - - name: Prepare local.properties file - run: | - # Since the password contains a dollar sign ($) I had to encode it and decode it here. - STORE_PASSWORD=$(echo "${{ secrets.CONTEXT_LAUNCHER_UPLOAD_STORE_PASSWORD_BASE64 }}" | base64 --decode) - KEY_PASSWORD=$(echo "${{ secrets.CONTEXT_LAUNCHER_UPLOAD_KEY_PASSWORD_BASE64 }}" | base64 --decode) - echo "sdk.dir=$ANDROID_SDK_ROOT" > $GITHUB_WORKSPACE/android/local.properties - echo "CONTEXT_LAUNCHER_UPLOAD_STORE_FILE=$GITHUB_WORKSPACE/android/app/upload.keystore" >> $GITHUB_WORKSPACE/android/local.properties - echo "CONTEXT_LAUNCHER_UPLOAD_STORE_PASSWORD=$STORE_PASSWORD" >> $GITHUB_WORKSPACE/android/local.properties - echo "CONTEXT_LAUNCHER_UPLOAD_KEY_ALIAS=${{ secrets.CONTEXT_LAUNCHER_UPLOAD_KEY_ALIAS }}" >> $GITHUB_WORKSPACE/android/local.properties - echo "CONTEXT_LAUNCHER_UPLOAD_KEY_PASSWORD=$KEY_PASSWORD" >> $GITHUB_WORKSPACE/android/local.properties - - - name: Build - working-directory: ./android - run: ./gradlew --no-daemon build - - - name: Build Debug - APK - working-directory: ./android - run: ./gradlew --no-daemon assembleDebug - - - name: Build Release - APK & AAB - working-directory: ./android - run: | - ./gradlew --no-daemon assembleRelease - ./gradlew --no-daemon bundleRelease - - - name: Upload Debug & Release Binaries - uses: actions/upload-artifact@v4 - with: - name: context-launcher-debug-and-release-apk-and-aab - path: | - android/app/build/outputs/apk/debug/*.apk - android/app/build/outputs/apk/release/*.apk - android/app/build/outputs/bundle/release/*.aab diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..673d82d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,23 @@ +name: main + +on: + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + code-style-checks: + uses: ./.github/workflows/code-style.yml + unit-tests: + uses: ./.github/workflows/tests.yml + needs: + - code-style-checks + build: + uses: ./.github/workflows/build.yml + secrets: inherit + needs: + - unit-tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee3dcf2..81eed7a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,17 +4,15 @@ on: push: tags: - "*" - workflow_run: - workflows: [tests] - types: - - completed jobs: - build-artifacts: - uses: ./.github/workflows/common-build.yml + prepare-artifacts: + uses: ./.github/workflows/build.yml secrets: inherit create-release: runs-on: ubuntu-latest + needs: + - prepare-artifacts steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -24,15 +22,11 @@ jobs: with: name: context-launcher-debug-and-release-apk-and-aab - - name: list files - run: ls -Rali - - name: Create Release id: create_release uses: softprops/action-gh-release@v1 with: - make_latest: "true" generate_release_notes: true files: | - *.apk - *.aab + ./apk/**/*.apk + ./bundle/**/*.aab diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4ae84b1..6b41455 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,14 +1,7 @@ name: tests on: - workflow_run: - workflows: [code-style] - types: - - completed - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + workflow_call: jobs: jest: