Skip to content

Commit

Permalink
feat: improve workflows dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
razinj committed Jun 26, 2024
1 parent 5765679 commit 018491f
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 110 deletions.
79 changes: 62 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 4 additions & 6 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,6 +17,7 @@ jobs:

- name: Install Dependencies
run: npm ci

- name: Check Formatting
run: npm run format:ci

Expand Down
67 changes: 0 additions & 67 deletions .github/workflows/common-build.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 6 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 1 addition & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 018491f

Please sign in to comment.