Compare commits
3 Commits
202bdab666
...
d157673aac
Author | SHA1 | Date | |
---|---|---|---|
d157673aac | |||
027eb0b7d1 | |||
53116080e4 |
61
Jenkinsfile
vendored
61
Jenkinsfile
vendored
|
@ -7,17 +7,28 @@ pipeline {
|
|||
buildDiscarder(logRotator(numToKeepStr: '10'))
|
||||
}
|
||||
parameters {
|
||||
string(name: 'APP_PACKAGE_ID', defaultValue: 'com.charlyghislain.embedded_webview', description: 'Application package id used as android identifier')
|
||||
string(name: 'APP_BUNDLE_ID', defaultValue: 'com.charlyghislain.embedded_webview', description: 'Application bundle id used as ios identifier')
|
||||
string(name: 'APP_TITLE', defaultValue: 'Embedded Webview', description: 'Application title')
|
||||
string(name: 'APP_URI', defaultValue: 'https://www.charlyghislain.com', description: 'Application uri')
|
||||
string(name: 'APP_URI', defaultValue: 'https://www.charlyghislain.com', description: 'Application initial uri')
|
||||
string(name: 'APP_COLOR', defaultValue: 'red', description: 'Application color (blue, teal, ...)')
|
||||
string(name: 'BUILD_MODE', defaultValue: 'debug', description: 'Flutter build mode (debug/release)')
|
||||
string(name: 'UPLOAD_TRACK', defaultValue: 'alpha', description: 'Upload track')
|
||||
string(name: 'RELEASE_MESSAGE', defaultValue: 'Nouvelle version', description: 'A release message')
|
||||
string(name: 'RELEASE_STATUS', defaultValue: 'completed', description: 'draft/completed')
|
||||
string(name: 'ANDROID_SIGNING_KEYSTORE_CREDENTIAL', defaultValue: 'jenkins-gestemps-android-service-secret-keystore',
|
||||
string(name: 'ANDROID_SIGNING_KEYSTORE_PASSWORD_CREDENTIAL', defaultValue: 'jenkins-gestemps-android-service-secret-keystore-password',
|
||||
string(name: 'ANDROID_SIGNING_KEY_PASSWORD_CREDENTIAL', defaultValue: 'jenkins-gestemps-android-service-secret-key-password',
|
||||
string(name: 'ANDROID_SIGNING_KEY_ALIAS', defaultValue: 'comptaplan',
|
||||
description: 'The key alias to use within the keystore')
|
||||
booleanParam(name: 'SKIP_PUBLISH', defaultValue: 'true', description: 'Skip publishing apk')
|
||||
string(name: 'RELEASE_MESSAGE', defaultValue: 'Nouvelle version', description: 'A release message')
|
||||
string(name: 'ANDROID_UPLOAD_TRACK', defaultValue: 'alpha', description: 'Upload track')
|
||||
string(name: 'ANDROID_RELEASE_STATUS', defaultValue: 'completed', description: 'draft/completed')
|
||||
string(name: 'ANDROID_API_KEY_CREDENTIAL', defaultValue: 'jenkins-gestemps-android-service-secret-api-key', description: 'Api key to for the play store api')
|
||||
string(name: 'GIT_SSH_REMOTE_NAME', defaultValue: 'ssh://git@gitea.valuya.com:2022/Valuya/embedded_webview.git',
|
||||
description: 'We use ssh authentication, but gitea may use an http remotes by default. This is the remote to push the build number increment.')
|
||||
string(name: 'GIT_CREDENTIAL_ID', defaultValue: 'jenkins-jenkins-ssh-key', description: '')
|
||||
string(name: 'GIT_PUSH_BRANCH', defaultValue: 'android-releases', description: 'A branch to push the commit')
|
||||
string(name: 'GIT_TAG', defaultValue: '', description: 'An additional tag to push')
|
||||
string(name: 'SSH_KNOWN_HOSTS_FILE', defaultValue: '/var/run/ssh/known_hosts.gitea.valuya.com', description: 'Known hosts for ssh client (might be used to get flutter git dependencies and push commits)')
|
||||
booleanParam(name: 'SKIP_PUSH_TAG', defaultValue: 'true', description: 'Skip push tag')
|
||||
string(name: 'NODEJS_INSTALLATION', defaultValue: 'node14',description: 'Nodejs installation to use')
|
||||
}
|
||||
|
@ -25,18 +36,31 @@ pipeline {
|
|||
stage ('Build') {
|
||||
steps {
|
||||
script {
|
||||
env.APP_PACKAGE_ID= params.APP_PACKAGE_ID
|
||||
env.APP_BUNDLE_ID= params.APP_BUNDLE_ID
|
||||
env.APP_TITLE= params.APP_TITLE
|
||||
env.APP_URI= params.APP_URI
|
||||
env.APP_COLOR= params.APP_COLOR
|
||||
env.BUILD_MODE= params.BUILD_MODE
|
||||
env.SSH_KNOWN_HOSTS_FILE= params.SSH_KNOWN_HOSTS_FILE
|
||||
env.ANDROID_KEY_ALIAS= params.ANDROID_SIGNING_KEY_ALIAS
|
||||
}
|
||||
container ('flutter') {
|
||||
sshagent(["${params.GIT_CREDENTIAL_ID}"]) {
|
||||
sh 'flutter doctor'
|
||||
sh 'GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/var/run/ssh/known_hosts.gitea.fteamdev.valuya.be" flutter pub get'
|
||||
sh 'flutter clean'
|
||||
sh 'APP_TITLE="$APP_TITLE" APP_URI="$APP_URI" APP_COLOR="$APP_COLOR" BUILDMODE="$BUILD_MODEs" ./tools/jenkins-build-android.sh'
|
||||
stash(name: 'outputs', includes: 'build/app/outputs/**')
|
||||
withCredentials([
|
||||
file(credentialsId: params.ANDROID_SIGNING_KEYSTORE_CREDENTIAL, variable: 'ANDROID_KEYSTORE_FILE'),
|
||||
string(credentialsId: params.ANDROID_SIGNING_KEYSTORE_PASSWORD_CREDENTIAL, variable: 'ANDROID_KEYSTORE_PASSWORD')
|
||||
string(credentialsId: params.ANDROID_SIGNING_KEY_PASSWORD_CREDENTIAL, variable: 'ANDROID_KEY_PASSWORD')
|
||||
]) {
|
||||
sh 'flutter doctor'
|
||||
sh 'GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE" flutter pub get'
|
||||
sh 'flutter clean'
|
||||
sh './tools/set-bundle-identifier.sh "$APP_BUNDLE_ID"'
|
||||
sh './tools/set-package.sh "$APP_PACKAGE_ID"'
|
||||
sh './tools/set-title.sh "$APP_TITLE"'
|
||||
sh './tools/jenkins-build-android.sh'
|
||||
stash(name: 'outputs', includes: 'build/app/outputs/**')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,24 +75,31 @@ pipeline {
|
|||
env.SKIP_PUSH_TAG= params.SKIP_PUSH_TAG
|
||||
env.GIT_TAG= params.GIT_TAG
|
||||
env.GIT_PUSH_BRANCH = params.GIT_PUSH_BRANCH
|
||||
env.TRACK = params.UPLOAD_TRACK
|
||||
env.RELEASE_STATUS = params.RELEASE_STATUS
|
||||
env.ANDROID_UPLOAD_TRACK = params.ANDROID_UPLOAD_TRACK
|
||||
env.ANDROID_RELEASE_STATUS = params.ANDROID_RELEASE_STATUS
|
||||
env.RELEASE_MESSAGE = params.RELEASE_MESSAGE
|
||||
env.GIT_SSH_REMOTE_NAME = params.GIT_SSH_REMOTE_NAME
|
||||
env.SSH_KNOWN_HOSTS_FILE = params.SSH_KNOWN_HOSTS_FILE
|
||||
}
|
||||
unstash(name: 'outputs')
|
||||
sshagent(["${params.GIT_CREDENTIAL_ID}"]) {
|
||||
nodejs(nodeJSInstallationName: "${params.NODEJS_INSTALLATION}") {
|
||||
sh './tools/jenkins-publish-android.sh'
|
||||
withCredentials([
|
||||
file(credentialsId: params.ANDROID_API_KEY_CREDENTIAL, variable: 'GOOGLE_APPLICATION_CREDENTIALS')
|
||||
]) {
|
||||
sh './tools/jenkins-publish-android.sh'
|
||||
}
|
||||
|
||||
}
|
||||
sh '''
|
||||
VERSION_CODE=$(./tools/jenkins-increment-buildnumber.sh || echo $?)
|
||||
[ "$VERSION_CODE" == "0" ] && exit 1
|
||||
git config user.email "jenkins@valuya.be"
|
||||
git config user.email "jenkins@valuya.com"
|
||||
git config user.name "Jenkins release"
|
||||
git add pubspec.yaml
|
||||
git remote add ssh "ssh://git@gitea.fteamdev.valuya.be:2022/fiscalteam/nitro-trustee-mobile.git"
|
||||
git remote add ssh "$GIT_SSH_REMOTE_NAME"
|
||||
git commit -m "Bump to build $VERSION_CODE"
|
||||
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/var/run/ssh/known_hosts.gitea.fteamdev.valuya.be"
|
||||
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE"
|
||||
git push ssh HEAD:$GIT_PUSH_BRANCH
|
||||
if [ "$SKIP_PUSH_TAG" != "true" ] ; then
|
||||
git tag "$GIT_TAG"
|
||||
|
|
|
@ -41,6 +41,10 @@ android {
|
|||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "com.charlyghislain.embedded_webview"
|
||||
|
@ -49,12 +53,17 @@ android {
|
|||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.charlyghislain.embedded_webview">
|
||||
<application
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
<application
|
||||
android:label="embedded_webview"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:embedded_webview/webview_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
void main() {
|
||||
const title = String.fromEnvironment("APP_TITLE");
|
||||
|
@ -18,16 +18,8 @@ class MyApp extends StatelessWidget {
|
|||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MaterialColor materialColor = this._getMaterialColor(this._color);
|
||||
return MaterialApp(
|
||||
title: this._title,
|
||||
theme: ThemeData(primarySwatch: materialColor),
|
||||
home: WebView(
|
||||
initialUrl: this._uri,
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
zoomEnabled: true,
|
||||
allowsInlineMediaPlayback: true,
|
||||
));
|
||||
MaterialColor materialColor = _getMaterialColor(_color);
|
||||
return MaterialApp(title: _title, theme: ThemeData(primarySwatch: materialColor), home: WebViewWidget(_uri));
|
||||
}
|
||||
|
||||
MaterialColor _getMaterialColor(String colorString) {
|
||||
|
|
47
lib/webview_widget.dart
Normal file
47
lib/webview_widget.dart
Normal file
|
@ -0,0 +1,47 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_webview_pro/webview_flutter.dart';
|
||||
|
||||
class WebViewWidget extends StatefulWidget {
|
||||
final String _initialUrl;
|
||||
|
||||
const WebViewWidget(this._initialUrl, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
WebViewWidgetState createState() => WebViewWidgetState();
|
||||
}
|
||||
|
||||
class WebViewWidgetState extends State<WebViewWidget> {
|
||||
WebViewWidgetState();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Enable hybrid composition.
|
||||
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WebView(
|
||||
initialUrl: widget._initialUrl,
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
javascriptChannels: <JavascriptChannel>{
|
||||
_toasterJavascriptChannel(context),
|
||||
},
|
||||
gestureNavigationEnabled: true,
|
||||
);
|
||||
}
|
||||
|
||||
JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
|
||||
return JavascriptChannel(
|
||||
name: 'Toaster',
|
||||
onMessageReceived: (JavascriptMessage message) {
|
||||
// ignore: deprecated_member_use
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message.message)),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
46
pubspec.lock
46
pubspec.lock
|
@ -74,6 +74,13 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_webview_pro:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_webview_pro
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -102,13 +109,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -170,34 +170,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
webview_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: webview_flutter
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
webview_flutter_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
webview_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
webview_flutter_wkwebview:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
sdks:
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
dart: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=1.22.0"
|
||||
|
|
|
@ -34,7 +34,9 @@ dependencies:
|
|||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
webview_flutter: ^2.3.1
|
||||
#webview_flutter: ^2.3.1
|
||||
flutter_webview_pro: ^1.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
|
@ -13,7 +13,7 @@ import 'package:embedded_webview/main.dart';
|
|||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
await tester.pumpWidget(const MyApp('test', 'test', 'blue'));
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# debug/release
|
||||
BUILDMODE=${BUILDMODE:-debug}
|
||||
BUILD_MODE=${BUILD_MODE:-debug}
|
||||
# LOCAL/DEV/PROD
|
||||
APP_TITLE=${APP_TITLE:-}
|
||||
APP_URI=${APP_URI:-}
|
||||
APP_COLOR=${APP_COLOR:-}
|
||||
ANDROID_KEYSTORE_FILE=${ANDROID_KEYSTORE_FILE:-}
|
||||
ANDROID_KEY_ALIAS=${ANDROID_KEY_ALIAS:-}
|
||||
ANDROID_KEYSTORE_PASSWORD=${ANDROID_KEYSTORE_PASSWORD:-}
|
||||
ANDROID_KEY_PASSWORD=${ANDROID_KEY_PASSWORD:-}
|
||||
|
||||
|
||||
cat << EOF > android/local.properties
|
||||
flutter.sdk=/home/developer/flutter
|
||||
sdk.dir=/home/developer/android
|
||||
flutter.buildMode=${BUILDMODE}
|
||||
flutter.buildMode=${BUILD_MODE}
|
||||
flutter.versionName=
|
||||
flutter.versionCode=
|
||||
EOF
|
||||
|
||||
cat << EOF > android/key.properties
|
||||
storePassword=jenkins.fteamdev
|
||||
keyPassword=jenkins.fteamdev
|
||||
keyAlias=jenkins.fteamdev
|
||||
storeFile=/var/run/secrets/signing_keystore.jks
|
||||
storePassword=${ANDROID_KEYSTORE_PASSWORD}
|
||||
keyPassword=${ANDROID_KEY_PASSWORD}
|
||||
keyAlias=${ANDROID_SIGNING_KEY_ALIAS}
|
||||
storeFile=${ANDROID_KEYSTORE_FILE}
|
||||
EOF
|
||||
|
||||
pwd
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
TRACK=${TRACK:-alpha}
|
||||
RELEASE_STATUS=${RELEASE_STATUS:-completed}
|
||||
RELEASE_MESSAGE="${RELEASE_MESSAGE:-New version}"
|
||||
GOOGLE_APPLICATION_CREDENTIALS="${GOOGLE_APPLICATION_CREDENTIALS:-}"
|
||||
|
||||
|
||||
VERSION_AND_CODE="$(cat pubspec.yaml | grep 'version:' | sed 's/version: //')"
|
||||
|
@ -19,7 +20,6 @@ npm install
|
|||
./node_modules/.bin/tsc
|
||||
npm install -g --save googleapis
|
||||
|
||||
GOOGLE_APPLICATION_CREDENTIALS=/var/run/secrets/google_api.key.json \
|
||||
node ${WD}/publish-android-js/publish-app-store.js \
|
||||
"$TRACK" "$VERSION_CODE" "$RELEASE_STATUS" "$VERSION_CODE $VERISON_NAME" "$RELEASE_MESSAGE" ${WD}/../build/app/outputs/bundle/release/app-release.aab \
|
||||
|| exit 1
|
||||
|
|
7
tools/set-bundle-identifier.sh
Normal file
7
tools/set-bundle-identifier.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
BUNDLE_NAME="$1"
|
||||
|
||||
echo "Setting the ios bundle name to $BUNDLE_NAME"
|
||||
|
||||
sed -i "s/PRODUCT_BUNDLE_IDENTIFIER = .*;/PRODUCT_BUNDLE_IDENTIFIER = $BUNDLE_NAME;" ios/Runner.xcodeproj/project.pbxproj
|
14
tools/set-package.sh
Normal file
14
tools/set-package.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
PACKAGE="$1"
|
||||
|
||||
echo "Setting the application android package to $PACKAGE"
|
||||
|
||||
sed -i "s/package=\"[^\"]\+\"/package=\"$PACKAGE\"/" android/app/src/debug/AndroidManfest.xml
|
||||
sed -i "s/package=\"[^\"]\+\"/package=\"$PACKAGE\"/" android/app/src/main/AndroidManfest.xml
|
||||
sed -i "s/package=\"[^\"]\+\"/package=\"$PACKAGE\"/" android/app/src/profile/AndroidManfest.xml
|
||||
|
||||
sed -i "s/applicationId \"[^\"]\+\"/applicationId \"$PACKAGE\"/" android/app/build.gradle
|
||||
|
||||
sed -i "s/package .*/package $PACKAGE/" android/app/src/main/kotlin/com/charlyghislain/embedded_webview/MainActivity.kt
|
||||
|
18
tools/set-title.sh
Normal file
18
tools/set-title.sh
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
TITLE="$1"
|
||||
|
||||
echo "Setting the application title to $TITLE"
|
||||
|
||||
sed -i "s/android:label=\"[^\"]\+\"/android:label=\"$TITLE\"/" android/app/src/main/AndroidManfest.xml
|
||||
|
||||
NAME_LENGTH="${#TITLE}"
|
||||
LONG_NAME="$(( $NAME_LENGTH > 15))" # 1 if long name
|
||||
BUNDLE_NAME="$(cut -c -15 $TITLE)"
|
||||
|
||||
perl -0777 -i -pe "s/\t<key>CFBundleName</key>\n[^\n]+/\t<key>CFBundleName</key>\n\t<string>$BUNDLE_NAME</string>/igs"
|
||||
|
||||
if [ "$LONG_NAME" = "1" ] ; then
|
||||
# todo : set bundleDisplayName
|
||||
fi
|
||||
|
Reference in New Issue
Block a user