Skip to content

Commit da89154

Browse files
authored
CI: Updated Action for auto build and deploy web builds (builtree#189)
* Added Github actions for autobuild * Removed autogenerated files * web: Added web build * actions: fixed typo and removed Java setup
1 parent b2d6876 commit da89154

8 files changed

+131
-35
lines changed

.github/workflows/docs.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docs
1+
name: Build docs with Simulate for Web
22
on:
33
workflow_dispatch:
44
jobs:
@@ -11,6 +11,11 @@ jobs:
1111
with:
1212
python-version: '3.7'
1313
architecture: 'x64'
14+
- uses: subosito/flutter-action@v1
15+
with:
16+
channel: 'stable'
17+
- run: flutter pub get
18+
- run: flutter build web --release
1419
- name: Install dependencies
1520
run: |
1621
python3 -m pip install --upgrade pip
@@ -26,6 +31,5 @@ jobs:
2631
run: mkdocs build
2732
- name: Add latest web build and deploy
2833
run: |
29-
git clone -b web https://github.com/cod-ed/simulate web
30-
mv web/web/ site/
34+
mv build/web/ site/
3135
mkdocs gh-deploy --dirty

ios/Flutter/flutter_export_environment.sh

-15
This file was deleted.

lib/generated_plugin_registrant.dart

-17
This file was deleted.

web/favicon.png

917 Bytes
Loading

web/icons/Icon-192.png

5.17 KB
Loading

web/icons/Icon-512.png

8.06 KB
Loading

web/index.html

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!--
5+
If you are serving your web app in a path other than the root, change the
6+
href value below to reflect the base path you are serving from.
7+
8+
The path provided below has to start and end with a slash "/" in order for
9+
it to work correctly.
10+
11+
For more details:
12+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
13+
14+
This is a placeholder for base href that will be replaced by the value of
15+
the `--base-href` argument provided to `flutter build`.
16+
-->
17+
<base href="$FLUTTER_BASE_HREF">
18+
19+
<meta charset="UTF-8">
20+
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
21+
<meta name="description" content="A new Flutter project.">
22+
23+
<!-- iOS meta tags & icons -->
24+
<meta name="apple-mobile-web-app-capable" content="yes">
25+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
26+
<meta name="apple-mobile-web-app-title" content="simulate">
27+
<link rel="apple-touch-icon" href="icons/Icon-192.png">
28+
29+
<title>simulate</title>
30+
<link rel="manifest" href="manifest.json">
31+
</head>
32+
<body>
33+
<!-- This script installs service_worker.js to provide PWA functionality to
34+
application. For more information, see:
35+
https://developers.google.com/web/fundamentals/primers/service-workers -->
36+
<script>
37+
var serviceWorkerVersion = null;
38+
var scriptLoaded = false;
39+
function loadMainDartJs() {
40+
if (scriptLoaded) {
41+
return;
42+
}
43+
scriptLoaded = true;
44+
var scriptTag = document.createElement('script');
45+
scriptTag.src = 'main.dart.js';
46+
scriptTag.type = 'application/javascript';
47+
document.body.append(scriptTag);
48+
}
49+
50+
if ('serviceWorker' in navigator) {
51+
// Service workers are supported. Use them.
52+
window.addEventListener('load', function () {
53+
// Wait for registration to finish before dropping the <script> tag.
54+
// Otherwise, the browser will load the script multiple times,
55+
// potentially different versions.
56+
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
57+
navigator.serviceWorker.register(serviceWorkerUrl)
58+
.then((reg) => {
59+
function waitForActivation(serviceWorker) {
60+
serviceWorker.addEventListener('statechange', () => {
61+
if (serviceWorker.state == 'activated') {
62+
console.log('Installed new service worker.');
63+
loadMainDartJs();
64+
}
65+
});
66+
}
67+
if (!reg.active && (reg.installing || reg.waiting)) {
68+
// No active web worker and we have installed or are installing
69+
// one for the first time. Simply wait for it to activate.
70+
waitForActivation(reg.installing || reg.waiting);
71+
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
72+
// When the app updates the serviceWorkerVersion changes, so we
73+
// need to ask the service worker to update.
74+
console.log('New service worker available.');
75+
reg.update();
76+
waitForActivation(reg.installing);
77+
} else {
78+
// Existing service worker is still good.
79+
console.log('Loading app from service worker.');
80+
loadMainDartJs();
81+
}
82+
});
83+
84+
// If service worker doesn't succeed in a reasonable amount of time,
85+
// fallback to plaint <script> tag.
86+
setTimeout(() => {
87+
if (!scriptLoaded) {
88+
console.warn(
89+
'Failed to load app from service worker. Falling back to plain <script> tag.',
90+
);
91+
loadMainDartJs();
92+
}
93+
}, 4000);
94+
});
95+
} else {
96+
// Service workers not supported. Just drop the <script> tag.
97+
loadMainDartJs();
98+
}
99+
</script>
100+
</body>
101+
</html>

web/manifest.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "simulate",
3+
"short_name": "simulate",
4+
"start_url": ".",
5+
"display": "standalone",
6+
"background_color": "#0175C2",
7+
"theme_color": "#0175C2",
8+
"description": "A new Flutter project.",
9+
"orientation": "portrait-primary",
10+
"prefer_related_applications": false,
11+
"icons": [
12+
{
13+
"src": "icons/Icon-192.png",
14+
"sizes": "192x192",
15+
"type": "image/png"
16+
},
17+
{
18+
"src": "icons/Icon-512.png",
19+
"sizes": "512x512",
20+
"type": "image/png"
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)