From fd422171b7332a6239dc73077c3442c6ead75f55 Mon Sep 17 00:00:00 2001 From: Ignacio Santise Date: Tue, 9 Apr 2024 16:09:15 -0300 Subject: [PATCH] chore: deploy actions (#141) --- .github/actions/ci-setup/action.yml | 26 ++++++ .github/workflows/release-android.yaml | 83 ++++++++++++++++++++ .github/workflows/release-dapp-internal.yaml | 18 +++++ dapps/W3MWagmi/package.json | 1 + 4 files changed, 128 insertions(+) create mode 100644 .github/actions/ci-setup/action.yml create mode 100644 .github/workflows/release-android.yaml create mode 100644 .github/workflows/release-dapp-internal.yaml diff --git a/.github/actions/ci-setup/action.yml b/.github/actions/ci-setup/action.yml new file mode 100644 index 00000000..1ad7e290 --- /dev/null +++ b/.github/actions/ci-setup/action.yml @@ -0,0 +1,26 @@ +name: CI Setup +description: Setup Node.js and install dependencies + +runs: + using: composite + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Cache dependencies + id: yarn-cache + uses: actions/cache@v3 + with: + path: | + **/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: | + yarn install --immutable + shell: bash diff --git a/.github/workflows/release-android.yaml b/.github/workflows/release-android.yaml new file mode 100644 index 00000000..647b7462 --- /dev/null +++ b/.github/workflows/release-android.yaml @@ -0,0 +1,83 @@ +on: + workflow_call: + inputs: + name: + description: 'Name of the project to be released' + required: true + type: string + path: + description: 'Path of the project to be released' + required: true + type: string + type: + description: 'Release type of the project (debug/internal/production)' + default: 'internal' + type: string + output-path: + description: 'Path to get the APK file' + required: true + type: string + secrets: + project-id: + description: 'WalletConnect Cloud ID' + required: true + type: string + firebase-app-id: + required: true + type: string + firebase-token: + required: true + type: string + relay-url: + description: 'WalletConnect Relay URL' + required: false + type: string + sentry-dns: + required: true + type: string + sentry-file: + required: true + type: string + secrets-file: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/ci-setup + + - name: Cache Gradle + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - run: touch ${{ inputs.path }}/.env.${{ inputs.type }} && echo "ENV_PROJECT_ID=${{ secrets.project-id }}\nENV_RELAY_URL=${{ secrets.relay-url }}\nENV_SENTRY_DSN=${{ secrets.sentry-dns }}\nENV_SENTRY_TAG=${{ inputs.type }}" >> ${{ inputs.path }}/.env.${{ inputs.type }} + - run: touch ${{ inputs.path }}/android/sentry.properties && echo "${{ secrets.sentry-file }}" >> ${{ inputs.path }}/android/sentry.properties + - run: touch ${{ inputs.path }}/android/secrets.properties && echo "${{ secrets.secrets-file }}" >> ${{ inputs.path }}/android/secrets.properties + + - name: Build APK + run: cd ${{ inputs.path }} && yarn install && yarn run android:build:internal + + - name: Setup Firebase + uses: w9jds/setup-firebase@main + with: + tools-version: 13.0.1 + firebase_token: ${{ secrets.firebase-token }} + + - name: Upload APK + env: + APP_ID: ${{ secrets.firebase-app-id }} + run: | + firebase appdistribution:distribute ./android/app/build/outputs/apk/${{ inputs.output-path }} --app $APP_ID --release-notes "${{ inputs.name }} ${{ inputs.type }} release" + \ No newline at end of file diff --git a/.github/workflows/release-dapp-internal.yaml b/.github/workflows/release-dapp-internal.yaml new file mode 100644 index 00000000..bfcdf852 --- /dev/null +++ b/.github/workflows/release-dapp-internal.yaml @@ -0,0 +1,18 @@ +name: Release Web3Modal Android Internal +on: workflow_dispatch + +jobs: + release-internal: + name: Release Web3Modal Android Internal + uses: ./.github/workflows/release-android.yaml + with: + path: 'dapps/W3MWagmi' + type: 'internal' + output-path: 'dapps/W3MWagmi/android/app/build/outputs/apk/internal/app-internal.apk' + secrets: + project-id: ${{ secrets.ENV_PROJECT_ID }} + sentry-dns: ${{ secrets.W3M_WAGMI_SENTRY_DSN }} + sentry-file: ${{ secrets.W3M_WAGMI_SENTRY_FILE }} + secrets-file: ${{ secrets.W3M_WAGMI_ANDROID_SECRETS }} + firebase-token: ${{ secrets.FIREBASE_TOKEN }} + firebase-app-id: ${{ secrets.W3M_WAGMI_ANDROID_INTERNAL_FIREBASE_APP_ID }} diff --git a/dapps/W3MWagmi/package.json b/dapps/W3MWagmi/package.json index 5ccb2f59..15b04d6a 100644 --- a/dapps/W3MWagmi/package.json +++ b/dapps/W3MWagmi/package.json @@ -5,6 +5,7 @@ "scripts": { "android": "react-native run-android", "android:build": "cd android && ./gradlew clean && ./gradlew assembleRelease", + "android:build:internal": "cd android && ./gradlew clean && ./gradlew assembleInternal", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start",