Skip to content

Commit

Permalink
- feature: android cicd (#58)
Browse files Browse the repository at this point in the history
* - feature: added cicd for chrome

* - feature: added cicd for android

* - fix: typo in env var

* - fix: keystore path

* - fix: added draft status to android ci

* - feature: added local dev tooling for android

* - fix: typos in ci

* - fix: added manual dispatch and nightly builds
  • Loading branch information
agallardol authored Oct 30, 2023
1 parent dc618ef commit 9dfcf27
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 37 deletions.
79 changes: 62 additions & 17 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: Release dev

on:
push:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
# push:
# branches: [main]

defaults:
run:
working-directory: ./

jobs:
release:
release-shinkai-visor:
runs-on: ubuntu-latest
environment: development
steps:
Expand All @@ -27,17 +30,16 @@ jobs:
node-version: 18
check-latest: false
registry-url: https://registry.npmjs.org
cache: "npm"
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
# shinkai-visor
- name: Run NX build on shinkai-visor
run: npx nx build shinkai-visor --skip-nx-cache --verbose
run: npx nx build shinkai-visor --skip-nx-cache
env:
VERSION: 0.0.0.${{github.run_number}}
NAME_PREFIX: '[Dev] '
Expand All @@ -55,7 +57,40 @@ jobs:
client-id: ${{ secrets.CHROME_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
publish: true
publish: false

- uses: actions/upload-artifact@v3
with:
name: shinkai-visor
path: dist/apps/shinkai-visor
if-no-files-found: error
retention-days: 5

release-shinkai-app-android:
runs-on: ubuntu-latest
environment: development
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use nx set shas
uses: nrwl/nx-set-shas@v3

- name: Setup Node version
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: false
registry-url: https://registry.npmjs.org
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
- uses: actions/upload-artifact@v3
with:
Expand All @@ -64,32 +99,42 @@ jobs:
if-no-files-found: error
retention-days: 5

# shinkai-app-android
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Run NX build on shinkai-app-android
- name: Set mobile apps version
run: |
npx capacitor-set-version -v $VERSION -b $BUILD $APP_PATH
env:
VERSION: 0.0.0
BUILD: ${{github.run_number}}
BUILD: ${{ github.run_number }}
APP_PATH: ./apps/shinkai-app

- name: Mount shinkai android keystore from secret
run: |
echo $KEYSTORE_BASE_64_STRING > $KEYSTORE_BASE_64_FILE_NAME
base64 -d $KEYSTORE_BASE_64_FILE_NAME > $KEYSTORE_FILE_PATH
env:
KEYSTORE_BASE_64_STRING: ${{ secrets.ANDROID_KEYSTORE_BASE_64 }}
KEYSTORE_BASE_64_FILE_NAME: shinkai-keystore-android-upload-base-64
KEYSTORE_FILE_PATH: ./apps/shinkai-app/android/shinkai-keystore-android

- name: Run NX build on shinkai-app-android
run: |
npx nx build:android shinkai-app --verbose
npx nx build:android shinkai-app
env:
ANDROID_KEYSTORE_FILE_PATH: ${{ secrets.ANDROID_KEYSTORE_FILE_PATH }}
ANDROID_KEYSTORE_FILE_PATH: shinkai-keystore-android
ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
ANDROID_KEYSTORE_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
ANDROID_KEYSTORE_ALIAS_PASS: ${{ secrets.ANDROID_KEYSTORE_ALIAS_PASS }}

- uses: actions/upload-artifact@v3
- name: Upload signed android .AAB file to Google Play Store
uses: r0adkll/upload-google-play@v1
with:
name: shinkai-app-android
path: dist/apps/shinkai-app-android
if-no-files-found: error
retention-days: 5
serviceAccountJsonPlainText: ${{ secrets.ANDROID_SERVICE_ACCOUNT_JSON }}
packageName: com.shinkai.app
releaseFiles: ./dist/apps/shinkai-app-android/app-release-signed.aab
track: internal
status: draft
6 changes: 3 additions & 3 deletions apps/shinkai-app/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
namespace "io.dcspark.shinkai"
namespace "com.shinkai.app"
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "io.dcspark.shinkai"
applicationId "com.shinkai.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
versionName "0.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.dcspark.shinkai;
package com.shinkai.app;

import com.getcapacitor.BridgeActivity;

Expand Down
8 changes: 4 additions & 4 deletions apps/shinkai-app/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">ShinkaiApp</string>
<string name="title_activity_main">ShinkaiApp</string>
<string name="package_name">io.dcspark.shinkai</string>
<string name="custom_url_scheme">io.dcspark.shinkai</string>
<string name="app_name">Shinkai</string>
<string name="title_activity_main">Shinkai</string>
<string name="package_name">com.shinkai.app</string>
<string name="custom_url_scheme">com.shinkai.app</string>
</resources>
8 changes: 5 additions & 3 deletions apps/shinkai-app/capacitor.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
appId: 'io.dcspark.shinkai',
appName: 'ShinkaiApp',
appId: 'com.shinkai.app',
appName: 'Shinkai',
webDir: '../../dist/apps/shinkai-app',
server: {
androidScheme: 'https'
androidScheme: 'https',
url: process.env.SERVE ? 'http://10.0.2.2:9000' : undefined,
cleartext: process.env.SERVE ? true : false,
}
};

Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/ionic.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ShinkaiApp",
"name": "Shinkai",
"integrations": {
"capacitor": {}
},
Expand Down
8 changes: 4 additions & 4 deletions apps/shinkai-app/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.0.1;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = io.dcspark.shinkai;
PRODUCT_BUNDLE_IDENTIFIER = com.shinkai.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
Expand All @@ -370,8 +370,8 @@
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = io.dcspark.shinkai;
MARKETING_VERSION = 0.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.shinkai.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>ShinkaiApp</string>
<string>Shinkai</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down
5 changes: 4 additions & 1 deletion apps/shinkai-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"private": true,
"version": "0.0.1",
"type": "module",
"description": "Shinkai Multiplatform App"
"description": "Shinkai Multiplatform App",
"scripts": {
"serve:android": "SERVE=true npx cap run android"
}
}
15 changes: 14 additions & 1 deletion apps/shinkai-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"executor": "@nx/vite:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "shinkai-app:build"
"buildTarget": "shinkai-app:build",
"port": 9000
},
"configurations": {
"development": {
Expand All @@ -70,6 +71,18 @@
}
}
},
"serve:android": {
"executor": "nx:run-script",
"defaultConfiguration": "development",
"options": {
"cwd": "apps/shinkai-app",
"script": "serve:android"
},
"configurations": {
"development": {},
"production": {}
}
},
"preview": {
"executor": "@nx/vite:preview-server",
"defaultConfiguration": "development",
Expand Down
2 changes: 1 addition & 1 deletion apps/shinkai-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({

server: {
port: 4200,
host: 'localhost',
host: true,
fs: {
// Important to server files two levels ahead of the project folder
allow: ['../../'],
Expand Down

0 comments on commit 9dfcf27

Please sign in to comment.