Skip to content

Commit

Permalink
Merge pull request #79 from ZeroGachis/task/add-code-push
Browse files Browse the repository at this point in the history
✨ add codepush
  • Loading branch information
ulricden authored Sep 14, 2023
2 parents 8e3027d + bae76f6 commit 7e8660b
Show file tree
Hide file tree
Showing 9 changed files with 1,019 additions and 59 deletions.
File renamed without changes.
55 changes: 55 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Production'

on:
push:
branches:
- 'main'

jobs:
format-version-code:
uses: ZeroGachis/.github/.github/workflows/android-format-version-code.yml@v3

create-apk:
uses: ZeroGachis/.github/.github/workflows/create-apk-artifact.yml@v3
needs: [format-version-code]
with:
version-code: ${{ needs.format-version-code.outputs.version-code }}
s3-path: storybook-react-native-design-system
java-version: 11
node-version: 18
package-name: com.storybook
working-directory: ./Storybook
configuration: release
vault-path: GH-Storybook-design-system
vault-url: ${{ vars.VAULT_URL }}
is-library-package: true
secrets: inherit
publish-bundle:
uses: ZeroGachis/.github/.github/workflows/publish-bundle-codepush.yml@v3
needs: [create-apk]
with:
node-version: 18
codepush-app: smartway-ai/storybook-smartapp
vault-path: GH-Storybook-design-system
vault-url: ${{ vars.VAULT_URL }}
is-library-package: true
apk-version: ${{ needs.create-apk.outputs.apk-version}}
secrets: inherit
publish-s3:
uses: ZeroGachis/.github/.github/workflows/publish-apk-s3.yml@v3
needs: [create-apk]
with:
apk-artifact-name: ${{ needs.create-apk.outputs.apk-artifact-name }}
apk-name: ${{ needs.create-apk.outputs.apk-name }}
apk-version: ${{ needs.create-apk.outputs.apk-version}}
vault-path: GH-Storybook-design-system
vault-url: ${{ vars.VAULT_URL }}
s3-path: storybook-react-native-design-system
secrets: inherit
publish-soti:
needs: [create-apk]
uses: ZeroGachis/.github/.github/workflows/publish-apk-soti.yml@v3
with:
apk-name: ${{ needs.create-apk.outputs.apk-name }}
apk-artifact-name: ${{ needs.create-apk.outputs.apk-artifact-name}}
secrets: inherit
20 changes: 20 additions & 0 deletions Storybook/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ react {
// hermesFlags = ["-O", "-output-source-map"]
}

apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"


/**
* Set this to true to create four separate APKs instead of one,
* one for each native architecture. This is useful if you don't
Expand Down Expand Up @@ -102,6 +105,16 @@ android {
versionName "1.0"
}

def keystore_path = System.getenv("SMARTWAY_KEYSTORE_NAME") ?: "debug.keystore"
def key_alias = System.getenv("SMARTWAY_KEY_ALIAS")
def key_password = System.getenv('SMARTWAY_KEY_PASSWORD')
def keystore_password = System.getenv('SMARTWAY_KEYSTORE_PASSWORD')

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

splits {
abi {
reset()
Expand All @@ -110,13 +123,20 @@ android {
include (*reactNativeArchitectures())
}
}

signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file(keystore_path)
storePassword keystore_password
keyAlias key_alias
keyPassword key_password
}
}
buildTypes {
debug {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,49 @@
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import com.microsoft.codepush.react.CodePush;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}

@Override
protected boolean isNewArchEnabled() {
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}

@Override
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// example:
// packages.add(new MyReactNativePackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}

// Let the CodePush runtime determine where to get the JS
// bundle location from on each app start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}

@Override
protected boolean isNewArchEnabled() {
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}

@Override
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};

@Override
public ReactNativeHost getReactNativeHost() {
Expand All @@ -54,7 +62,8 @@ public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
// If you opted-in for the New Architecture, we load the native entry point for
// this app.
DefaultNewArchitectureEntryPoint.load();
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
Expand Down
3 changes: 3 additions & 0 deletions Storybook/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">Storybook</string>
<string moduleConfig="true" name="CodePushDeploymentKey">WZbqfR_OAKyvlNeuzKZG5cjd8PGT_fpk9I1kw</string>
<string name="appCenterCrashes_whenToSendCrashes" moduleConfig="true" translatable="false">DO_NOT_ASK_JAVASCRIPT</string>
<string name="appCenterAnalytics_whenToEnableAnalytics" moduleConfig="true" translatable="false">ALWAYS_SEND</string>
</resources>
3 changes: 2 additions & 1 deletion Storybook/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rootProject.name = 'Storybook'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
12 changes: 12 additions & 0 deletions Storybook/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import CodePush from 'react-native-code-push';
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';

AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));

const CodePushApp = CodePush({
checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
installMode: CodePush.InstallMode.ON_NEXT_RESUME,
minimumBackgroundDuration: 30,
rollbackRetryOptions: { maxRetryAttempts: 10 }
})(() => {
return <App />;
});

AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(CodePushApp));
Loading

0 comments on commit 7e8660b

Please sign in to comment.