Skip to content

Commit fb1db78

Browse files
authored
Merge pull request #20 from xianshenglu/dev
2 parents 5e54ce1 + 52e9ad5 commit fb1db78

16 files changed

Lines changed: 1139 additions & 249 deletions

File tree

.github/workflows/android_build.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Android Build ## name of the workflow
22

33
on:
4+
workflow_dispatch:
45
push:
56
pull_request:
67

@@ -12,36 +13,47 @@ jobs:
1213

1314
steps:
1415
- name: Check out Git repository # clone the repo to local ci workspace
15-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1617

1718
- name: Set up our JDK environment # setup JDK environment: mandatory as we need to build android project
18-
uses: actions/setup-java@v1.4.3
19+
uses: actions/setup-java@v2
1920
with:
20-
java-version: 1.8
21+
distribution: 'zulu'
22+
java-version: 8
23+
24+
- name: Set up our Node version
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: 16.14
2128

2229
- name: Install dependencies
2330
run: npm ci
2431

2532
# configure cash for gradle : will help to reduce build time
2633
- name: Cache Gradle Wrapper
27-
uses: actions/cache@v2
34+
uses: actions/cache@v3
2835
with:
2936
path: ~/.gradle/wrapper
3037
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
3138

3239
- name: Cache Gradle Dependencies
33-
uses: actions/cache@v2
40+
uses: actions/cache@v3
3441
with:
3542
path: ~/.gradle/caches
3643
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
3744
restore-keys: |
3845
${{ runner.os }}-gradle-caches-
46+
3947
- name: Make Gradlew Executable
4048
run: cd android && chmod +x ./gradlew
4149

4250
- name: Generate App APK
4351
run: |
4452
npm run build:release
53+
env:
54+
APP_CENTER_SECRET: ${{ secrets.APP_CENTER_SECRET }}
55+
CODE_PUSH_DEPLOYMENT_KEY: ${{ secrets.CODE_PUSH_DEPLOYMENT_KEY }}
56+
NODE_ENV: ${{ secrets.NODE_ENV }}
4557

4658
## sign generated apk
4759
- name: Sign APK
@@ -55,6 +67,16 @@ jobs:
5567
keyPassword: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }}
5668
fileRegex: .*apk
5769

70+
- name: Upload artifact to App Center
71+
uses: wzieba/AppCenter-Github-Action@v1
72+
with:
73+
appName: xianshenglu/cloudflare-ip-tester-app
74+
token: ${{secrets.APP_CENTER_TOKEN}}
75+
group: Collaborators
76+
file: android/app/build/outputs/apk/release/app-universal-release.apk
77+
notifyTesters: true
78+
debug: false
79+
5880
- name: test
5981
id: test
6082
run: |

.github/workflows/android_release.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Android Release ## name of the workflow
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
types: [closed]
67

@@ -15,40 +16,51 @@ jobs:
1516

1617
steps:
1718
- name: Check out Git repository # clone the repo to local ci workspace
18-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
1920
with:
2021
token: ${{ secrets.PAT_BOT_RELEASE }}
2122
fetch-depth: 0 # for changeLog
2223

2324
- name: Set up our JDK environment # setup JDK environment: mandatory as we need to build android project
24-
uses: actions/setup-java@v1.4.3
25+
uses: actions/setup-java@v2
2526
with:
26-
java-version: 1.8
27+
distribution: 'zulu'
28+
java-version: 8
2729

30+
- name: Set up our Node version
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: 16.14
34+
2835
- name: Install dependencies
2936
run: npm ci
3037

3138
# configure cash for gradle : will help to reduce build time
3239
- name: Cache Gradle Wrapper
33-
uses: actions/cache@v2
40+
uses: actions/cache@v3
3441
with:
3542
path: ~/.gradle/wrapper
3643
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
3744

3845
- name: Cache Gradle Dependencies
39-
uses: actions/cache@v2
46+
uses: actions/cache@v3
4047
with:
4148
path: ~/.gradle/caches
4249
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
4350
restore-keys: |
4451
${{ runner.os }}-gradle-caches-
52+
4553
- name: Make Gradlew Executable
4654
run: cd android && chmod +x ./gradlew
4755

4856
- name: Generate App APK
4957
run: |
5058
npm run build:release
51-
59+
env:
60+
APP_CENTER_SECRET: ${{ secrets.APP_CENTER_SECRET }}
61+
CODE_PUSH_DEPLOYMENT_KEY: ${{ secrets.CODE_PUSH_DEPLOYMENT_KEY }}
62+
NODE_ENV: ${{ secrets.NODE_ENV }}
63+
5264
## sign generated apk
5365
- name: Sign APK
5466
id: sign_app

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,9 @@ buck-out/
7272
web-build/
7373
dist/
7474

75-
# @end expo-cli
75+
# @end expo-cli
76+
77+
#secret
78+
android/app/src/main/assets/appcenter-config.json
79+
#env
80+
.env

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ project.ext.react = [
8585
]
8686

8787
apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
88+
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
8889

8990
/**
9091
* Set this to true to create two separate APKs instead of one:

android/app/src/main/java/com/xianshenglu/xyz/MainApplication.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.lang.reflect.InvocationTargetException;
2121
import java.util.List;
2222

23+
import com.microsoft.codepush.react.CodePush;
24+
2325
public class MainApplication extends Application implements ReactApplication {
2426
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
2527
this,
@@ -42,6 +44,11 @@ protected List<ReactPackage> getPackages() {
4244
protected String getJSMainModuleName() {
4345
return "index";
4446
}
47+
48+
@Override
49+
protected String getJSBundleFile() {
50+
return CodePush.getJSBundleFile();
51+
}
4552
});
4653

4754
@Override

android/app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
<string name="app_name">cloudflare-ip-tester-app</string>
33
<string name="expo_splash_screen_resize_mode" translatable="false">contain</string>
44
<string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
5+
<string name="appCenterCrashes_whenToSendCrashes" moduleConfig="true" translatable="false">DO_NOT_ASK_JAVASCRIPT</string>
6+
<string name="appCenterAnalytics_whenToEnableAnalytics" moduleConfig="true" translatable="false">ALWAYS_SEND</string>
7+
<string moduleConfig="true" name="CodePushDeploymentKey">DeploymentKey</string>
58
</resources>

android/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ buildscript {
66
minSdkVersion = 21
77
compileSdkVersion = 30
88
targetSdkVersion = 30
9+
// kotlinVersion = "1.6.0"
910
}
1011
repositories {
1112
google()
@@ -19,8 +20,14 @@ buildscript {
1920
// in the individual module build.gradle files
2021
}
2122
}
23+
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
2224

2325
allprojects {
26+
configurations.all {
27+
resolutionStrategy {
28+
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
29+
}
30+
}
2431
repositories {
2532
mavenLocal()
2633
maven {

android/settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ useExpoModules()
66
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
77
applyNativeModulesSettingsGradle(settings)
88

9-
include ':app'
9+
include ':app', ':react-native-code-push'
10+
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

babel.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ module.exports = function (api) {
1212
root: ["./"],
1313
},
1414
],
15+
[
16+
"module:react-native-dotenv",
17+
{
18+
moduleName: "@env",
19+
path: ".env",
20+
blocklist: null,
21+
allowlist: null,
22+
safe: false,
23+
allowUndefined: false,
24+
verbose: false,
25+
},
26+
],
1527
],
1628
};
1729
};

index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import { registerRootComponent } from 'expo';
2-
2+
import codePush from "react-native-code-push";
33
import App from './App';
4+
import { CODE_PUSH_DEPLOYMENT_KEY } from "@env";
5+
import { AppI18n } from './localize';
46

7+
const codePushOptions = {
8+
updateDialog: {
9+
optionalUpdateMessage : AppI18n.t('update.optionalUpdateMessage'),
10+
optionalInstallButtonLabel : AppI18n.t('update.optionalInstallButtonLabel'),
11+
optionalIgnoreButtonLabel : AppI18n.t('update.optionalIgnoreButtonLabel'),
12+
title: AppI18n.t('update.title'),
13+
},
14+
deploymentKey: CODE_PUSH_DEPLOYMENT_KEY,
15+
};
516
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
617
// It also ensures that whether you load the app in Expo Go or in a native build,
718
// the environment is set up appropriately
8-
registerRootComponent(App);
19+
registerRootComponent(codePush(codePushOptions)(App));

0 commit comments

Comments
 (0)