chore(sample-app): update workflow and fix flutter web for deployment

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-04-08 02:48:30 +05:30
committed by xsahil03x
parent 72f322c2b3
commit c77221a61e
3 changed files with 122 additions and 69 deletions
+37 -23
View File
@@ -17,21 +17,26 @@ concurrency:
jobs: jobs:
build_and_deploy_ios: build_and_deploy_ios:
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 40
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- run: sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer uses: actions/checkout@v3
- name: Install RubyGems
run: | - name: Setup Flutter
cd ios uses: subosito/flutter-action@v2
bundle install
- uses: subosito/flutter-action@v2
with: with:
channel: 'stable' channel: stable
- name: Flutter setup cache: true
run: |
flutter pub get - name: Setup Ruby and Gems
uses: ruby/setup-ruby@v1
with:
working-directory: ios
bundler-cache: true
- name: Copy production config - name: Copy production config
run: echo "${{ secrets.PRODUCTION_CONFIG }}" > lib/app_config.dart run: echo "${{ secrets.PRODUCTION_CONFIG }}" > lib/app_config.dart
- name: Build and release - name: Build and release
env: env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
@@ -41,39 +46,48 @@ jobs:
FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }} FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }} FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
run: | run: |
flutter build ios --release --no-codesign flutter build ios --no-codesign
cd ios cd ios
bundle exec fastlane deploy_to_testflight bundle exec fastlane deploy_to_testflight
build_and_deploy_android: build_and_deploy_android:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- uses: actions/setup-java@v1 uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Setup Java
uses: actions/setup-java@v1
with: with:
java-version: '12.x' java-version: '12.x'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: |
flutter pub get
- name: Copy production config - name: Copy production config
run: echo "${{ secrets.PRODUCTION_CONFIG }}" > lib/app_config.dart run: echo "${{ secrets.PRODUCTION_CONFIG }}" > lib/app_config.dart
- name: Build - name: Build
run: | run: flutter build apk
flutter build apk
- name: upload apk - name: Upload Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: android-stream-chat-v1 name: android-stream-chat-v1
path: packages/stream_chat_v1/build/app/outputs/apk/release/app-release.apk path: packages/stream_chat_v1/build/app/outputs/apk/release/app-release.apk
- name: Configure AWS credentials - name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2 uses: aws-actions/configure-aws-credentials@v2
with: with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 aws-region: us-east-1
- name: Upload APK
- name: Upload to S3
run: | run: |
cp build/app/outputs/apk/release/app-release.apk flutter-sample-app.apk cp build/app/outputs/apk/release/app-release.apk flutter-sample-app.apk
aws s3 cp flutter-sample-app.apk s3://${{ secrets.AWS_S3_BUCKET }} --sse AES256 aws s3 cp flutter-sample-app.apk s3://${{ secrets.AWS_S3_BUCKET }} --sse AES256
+46 -33
View File
@@ -15,55 +15,59 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_and_deploy_ios: build_and_deploy_ios:
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 40
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- run: sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer uses: actions/checkout@v3
- name: Install RubyGems
run: | - name: Setup Flutter
cd ios uses: subosito/flutter-action@v2
bundle install
- uses: subosito/flutter-action@v2
with: with:
channel: 'stable' channel: stable
cache: true
- name: Setup Ruby and Gems
uses: ruby/setup-ruby@v1
with:
working-directory: ios
bundler-cache: true
- name: Install firebase-tools - name: Install firebase-tools
run: npm install -g firebase-tools run: npm install -g firebase-tools
- name: Flutter setup
run: |
flutter pub get
- name: Build and release - name: Build and release
env: env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }} MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: | run: |
flutter build ios --release --no-codesign flutter build ios --no-codesign
cd ios cd ios
bundle exec fastlane deploy_to_firebase bundle exec fastlane deploy_to_firebase
build_and_deploy_android: build_and_deploy_android:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- uses: actions/setup-java@v1 uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v1
with: with:
java-version: '12.x' java-version: '12.x'
- uses: subosito/flutter-action@v2
- name: Setup Flutter
uses: subosito/flutter-action@v2
with: with:
channel: 'stable' channel: stable
- run: | cache: true
flutter pub get
- name: Build - name: Build
run: | run: flutter build apk
flutter build apk
- name: Deploy - name: Deploy
uses: wzieba/Firebase-Distribution-Github-Action@v1 uses: wzieba/Firebase-Distribution-Github-Action@v1
with: with:
@@ -72,7 +76,8 @@ jobs:
groups: stream-testers groups: stream-testers
debug: true debug: true
file: packages/stream_chat_v1/build/app/outputs/apk/release/app-release.apk file: packages/stream_chat_v1/build/app/outputs/apk/release/app-release.apk
- name: upload apk
- name: Upload APK
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: android-stream-chat-v1 name: android-stream-chat-v1
@@ -80,20 +85,28 @@ jobs:
build_and_deploy_web: build_and_deploy_web:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
uses: actions/checkout@v3
- name: config git - name: config git
run: | run: |
git config --global user.email "$(git log --format='%ae' HEAD^!)" git config --global user.email "$(git log --format='%ae' HEAD^!)"
git config --global user.name "$(git log --format='%an' HEAD^!)" git config --global user.name "$(git log --format='%an' HEAD^!)"
git fetch origin gh-pages:gh-pages git fetch origin gh-pages:gh-pages
- uses: subosito/flutter-action@v2
- name: Setup Flutter
uses: subosito/flutter-action@v2
with: with:
channel: 'stable' channel: stable
- run: flutter pub get cache: true
- name: Copy production config - name: Copy production config
run: echo "${{ secrets.PRODUCTION_CONFIG }}" > lib/app_config.dart run: echo "${{ secrets.PRODUCTION_CONFIG }}" > lib/app_config.dart
- uses: bluefireteam/flutter-gh-pages@v7
- name: Build and Deploy
uses: bluefireteam/flutter-gh-pages@v7
with: with:
webRenderer: canvaskit webRenderer: canvaskit
workingDir: packages/stream_chat_v1 workingDir: packages/stream_chat_v1
+39 -13
View File
@@ -1,34 +1,60 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project."> <meta name="description" content="Sample app for the Stream Chat Flutter SDK.">
<!-- iOS meta tags & icons --> <!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="example"> <meta name="apple-mobile-web-app-title" content="Stream Chat V1">
<link rel="apple-touch-icon" href="icons/Icon-192.png"> <link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/> <link rel="icon" type="image/png" href="favicon.png"/>
<title>example</title> <title>Stream Chat V1</title>
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script defer src="flutter.js"></script>
<script defer src="sql-wasm.js"></script>
</head> </head>
<body> <body>
<!-- This script installs service_worker.js to provide PWA functionality to <script>
application. For more information, see: window.addEventListener('load', function(ev) {
https://developers.google.com/web/fundamentals/primers/service-workers --> // Download main.dart.js
<script> _flutter.loader.loadEntrypoint({
if ('serviceWorker' in navigator) { serviceWorker: {
window.addEventListener('load', function () { serviceWorkerVersion: serviceWorkerVersion,
navigator.serviceWorker.register('flutter_service_worker.js'); }
}).then(function(engineInitializer) {
return engineInitializer.initializeEngine();
}).then(function(appRunner) {
return appRunner.runApp();
}); });
} });
</script> </script>
<script defer src="sql-wasm.js"></script>
<script src="main.dart.js" type="application/javascript"></script>
</body> </body>
</html> </html>