integrate shorebird

This commit is contained in:
Jonas Bark
2025-10-12 11:05:13 +02:00
parent a8b2ae47d0
commit 6756772a04
8 changed files with 232 additions and 112 deletions

View File

@@ -12,6 +12,10 @@ on:
- 'keypress_simulator/**'
- 'pubspec.yaml'
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
FLUTTER_VERSION: 3.35.5
jobs:
build:
name: Build & Release
@@ -69,20 +73,22 @@ jobs:
cp $PP_PATH_IOS_DEV ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_MACOS ~/Library/MobileDevice/Provisioning\ Profiles
#3 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
channel: 'stable'
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
- name: 🚀 Shorebird Release macOS
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: macos
#8 Build app ( macos Build )
- name: Build macOS App
run: flutter build macos --release
- name: 🚀 Shorebird Release macOS
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: macos
- name: Code Signing
run: /usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --entitlements ../../../../../macos/Runner/Release.entitlements --options runtime SwiftControl.app -v
@@ -90,17 +96,32 @@ jobs:
env:
DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY: ${{ secrets.DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY }}
- name: Prepare App Store authentication key
env:
API_KEY_BASE64: ${{ secrets.APPSTORE_API_KEY_FILE_BASE64 }}
run: |
mkdir -p ./private_keys;
printf %s "$API_KEY_BASE64" | base64 -D > "./private_keys/AuthKey_${APPSTORE_API_KEY}.p8";
- name: Upload to macOS App Store
env:
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
APPSTORE_API_ISSUER_ID: ${{ secrets.APPSTORE_API_ISSUER_ID }}
run: |
productbuild --component "build/macos/Build/Products/Release/SwiftControl.app" /Applications "SwiftControl.pkg" --sign "3rd Party Mac Developer Installer: JONAS TASSILO BARK (UZRHKPVWN9)";
xcrun altool --upload-app -f SwiftControl.pkg -t osx --apiKey "$APPSTORE_API_KEY" --apiIssuer "$APPSTORE_API_ISSUER_ID";
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/android.keystore;
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties;
- name: Build APK
if: github.ref == 'refs/heads/main'
run: flutter build apk --release
- name: Build Bundle
run: flutter build appbundle --release
- name: 🚀 Shorebird Release Android
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: android
args: "--artifact=apk"
- name: Build Web
if: github.ref == 'refs/heads/main'
@@ -191,27 +212,20 @@ jobs:
track: production
whatsNewDirectory: whatsnew
- name: Build iOS app and release
env:
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
APPSTORE_API_ISSUER_ID: ${{ secrets.APPSTORE_API_ISSUER_ID }}
API_KEY_BASE64: ${{ secrets.APPSTORE_API_KEY_FILE_BASE64 }}
run: |
mkdir -p ./private_keys;
printf %s "$API_KEY_BASE64" | base64 -D > "./private_keys/AuthKey_${APPSTORE_API_KEY}.p8";
flutter build ipa --release --export-options-plist=ios/ExportOptions.plist;
xcrun altool --upload-app -f build/ios/ipa/swift_play.ipa -t ios --apiKey "$APPSTORE_API_KEY" --apiIssuer "$APPSTORE_API_ISSUER_ID";
- name: 🚀 Shorebird Release iOS
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: ios
args: "--export-options-plist ios/ExportOptions.plist"
- name: Release macOS app
- name: Upload to iOS App Store
env:
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
APPSTORE_API_ISSUER_ID: ${{ secrets.APPSTORE_API_ISSUER_ID }}
API_KEY_BASE64: ${{ secrets.APPSTORE_API_KEY_FILE_BASE64 }}
run: |
mkdir -p ./private_keys;
printf %s "$API_KEY_BASE64" | base64 -D > "./private_keys/AuthKey_${APPSTORE_API_KEY}.p8";
productbuild --component "build/macos/Build/Products/Release/SwiftControl.app" /Applications "SwiftControl.pkg" --sign "3rd Party Mac Developer Installer: JONAS TASSILO BARK (UZRHKPVWN9)";
xcrun altool --upload-app -f SwiftControl.pkg -t osx --apiKey "$APPSTORE_API_KEY" --apiIssuer "$APPSTORE_API_ISSUER_ID";
xcrun altool --upload-app -f build/ios/ipa/swift_play.ipa -t ios --apiKey "$APPSTORE_API_KEY" --apiIssuer "$APPSTORE_API_ISSUER_ID";
windows:
@@ -232,18 +246,16 @@ jobs:
distribution: 'oracle'
java-version: '17'
#3 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
channel: 'stable'
cache: true
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
- name: Build App
run: flutter build windows
- name: 🚀 Shorebird Release macOS
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: windows
- name: Zip directory (Windows)
shell: pwsh

View File

@@ -13,6 +13,10 @@ PODS:
- Flutter
- permission_handler_apple (9.3.0):
- Flutter
- restart (1.0.0):
- Flutter
- restart_app (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
@@ -32,6 +36,8 @@ DEPENDENCIES:
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- restart (from `.symlinks/plugins/restart/ios`)
- restart_app (from `.symlinks/plugins/restart_app/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- universal_ble (from `.symlinks/plugins/universal_ble/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
@@ -52,6 +58,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
restart:
:path: ".symlinks/plugins/restart/ios"
restart_app:
:path: ".symlinks/plugins/restart_app/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
universal_ble:
@@ -69,6 +79,8 @@ SPEC CHECKSUMS:
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
restart: b5fe16e6e038f0024b2f3af43768e9d2a1557554
restart_app: 806659942bf932f6ce51c5372f91ce5e81c8c14a
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
universal_ble: cf52a7b3fd2e7c14d6d7262e9fdadb72ab6b88a6
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

View File

@@ -29,7 +29,7 @@ List<Widget> buildMenuButtons() {
launchUrlString(link);
},
),
if (!kIsWeb && Platform.isAndroid && !isFromPlayStore)
if (!kIsWeb && Platform.isAndroid && isFromPlayStore == false)
PopupMenuItem(
child: Text('by buying the app from Play Store'),
onTap: () {
@@ -44,7 +44,10 @@ List<Widget> buildMenuButtons() {
),
];
},
icon: Text('Donate ♥', style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold)),
icon: Text(
'Donate ♥',
style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold),
),
),
SizedBox(width: 8),
],
@@ -59,72 +62,71 @@ class MenuButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PopupMenuButton(
itemBuilder:
(c) => [
if (kDebugMode) ...[
PopupMenuItem(
child: PopupMenuButton(
child: Text("Simulate buttons"),
itemBuilder: (_) {
return ZwiftButton.values
.map(
(e) => PopupMenuItem(
child: Text(e.name),
onTap: () {
Future.delayed(Duration(seconds: 2)).then((_) {
connection.signalNotification(
RideNotification(Uint8List(0), analogPaddleThreshold: 25)..buttonsClicked = [e],
);
});
},
),
)
.toList();
},
),
),
PopupMenuItem(
child: Text('Continue'),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (c) => DevicePage()));
},
),
PopupMenuItem(
child: Text('Reset'),
onTap: () async {
await settings.reset();
},
),
PopupMenuItem(child: PopupMenuDivider()),
],
PopupMenuItem(
child: Text('Changelog'),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: 'CHANGELOG.md')));
itemBuilder: (c) => [
if (kDebugMode) ...[
PopupMenuItem(
child: PopupMenuButton(
child: Text("Simulate buttons"),
itemBuilder: (_) {
return ZwiftButton.values
.map(
(e) => PopupMenuItem(
child: Text(e.name),
onTap: () {
Future.delayed(Duration(seconds: 2)).then((_) {
connection.signalNotification(
RideNotification(Uint8List(0), analogPaddleThreshold: 25)..buttonsClicked = [e],
);
});
},
),
)
.toList();
},
),
PopupMenuItem(
child: Text('Troubleshooting Guide'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md')),
);
},
),
PopupMenuItem(
child: Text('Feedback'),
onTap: () {
launchUrlString('https://github.com/jonasbark/swiftcontrol/issues');
},
),
PopupMenuItem(
child: Text('License'),
onTap: () {
showLicensePage(context: context);
},
),
],
),
PopupMenuItem(
child: Text('Continue'),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (c) => DevicePage()));
},
),
PopupMenuItem(
child: Text('Reset'),
onTap: () async {
await settings.reset();
},
),
PopupMenuItem(child: PopupMenuDivider()),
],
PopupMenuItem(
child: Text('Changelog'),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: 'CHANGELOG.md')));
},
),
PopupMenuItem(
child: Text('Troubleshooting Guide'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md')),
);
},
),
PopupMenuItem(
child: Text('Feedback'),
onTap: () {
launchUrlString('https://github.com/jonasbark/swiftcontrol/issues');
},
),
PopupMenuItem(
child: Text('License'),
onTap: () {
showLicensePage(context: context);
},
),
],
);
}
}

View File

@@ -7,13 +7,16 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:in_app_update/in_app_update.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:restart/restart.dart';
import 'package:restart_app/restart_app.dart';
import 'package:shorebird_code_push/shorebird_code_push.dart';
import 'package:swift_control/widgets/small_progress_indicator.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:version/version.dart';
String? _latestVersionUrlValue;
PackageInfo? _packageInfoValue;
bool isFromPlayStore = true;
bool? isFromPlayStore;
class AppTitle extends StatefulWidget {
const AppTitle({super.key});
@@ -23,6 +26,9 @@ class AppTitle extends StatefulWidget {
}
class _AppTitleState extends State<AppTitle> {
final updater = ShorebirdUpdater();
Patch? _shorebirdPatch;
Future<String?> _getLatestVersionUrlIfNewer() async {
final response = await http.get(Uri.parse('https://api.github.com/repos/jonasbark/swiftcontrol/releases/latest'));
if (response.statusCode == 200) {
@@ -57,6 +63,15 @@ class _AppTitleState extends State<AppTitle> {
@override
void initState() {
super.initState();
if (updater.isAvailable) {
updater.readCurrentPatch().then((patch) {
setState(() {
_shorebirdPatch = patch;
});
});
}
if (_packageInfoValue == null) {
PackageInfo.fromPlatform().then((value) {
setState(() {
@@ -70,6 +85,28 @@ class _AppTitleState extends State<AppTitle> {
}
void _checkForUpdate() async {
if (updater.isAvailable) {
final updateStatus = await updater.checkForUpdate();
if (updateStatus == UpdateStatus.outdated) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('New version available'),
duration: Duration(seconds: 1337),
action: SnackBarAction(
label: 'Update',
onPressed: () {
updater.update().then((value) {
_showShorebirdRestartSnackbar();
});
},
),
),
);
} else if (updateStatus == UpdateStatus.restartRequired) {
_showShorebirdRestartSnackbar();
}
return null;
}
if (!kIsWeb && Platform.isAndroid) {
try {
final appUpdateInfo = await InAppUpdate.checkForUpdate();
@@ -87,11 +124,13 @@ class _AppTitleState extends State<AppTitle> {
),
);
}
isFromPlayStore = true;
return null;
} on Exception catch (e) {
isFromPlayStore = false;
print('Failed to check for update: $e');
}
setState(() {});
}
if (_latestVersionUrlValue == null && !kIsWeb && !Platform.isIOS) {
final url = await _getLatestVersionUrlIfNewer();
@@ -120,7 +159,7 @@ class _AppTitleState extends State<AppTitle> {
Text('SwiftControl', style: TextStyle(fontWeight: FontWeight.bold)),
if (_packageInfoValue != null)
Text(
'v${_packageInfoValue!.version}',
'v${_packageInfoValue!.version}${_shorebirdPatch != null ? '+${_shorebirdPatch!.number}' : ''}${kIsWeb || (Platform.isAndroid && isFromPlayStore == false) ? ' (sideloaded)' : ''}',
style: TextStyle(fontFamily: "monospace", fontFamilyFallback: <String>["Courier"], fontSize: 12),
)
else
@@ -128,4 +167,25 @@ class _AppTitleState extends State<AppTitle> {
],
);
}
void _showShorebirdRestartSnackbar() {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Restart the app to use the new version'),
duration: Duration(seconds: 10),
action: Platform.isIOS || Platform.isAndroid
? SnackBarAction(
label: 'Restart',
onPressed: () {
if (Platform.isAndroid) {
restart();
} else if (Platform.isIOS) {
Restart.restartApp();
}
},
)
: null,
),
);
}
}

View File

@@ -4,6 +4,8 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.device.bluetooth</key>
<true/>
<key>com.apple.security.network.client</key>

View File

@@ -723,6 +723,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.2.0"
restart:
dependency: "direct main"
description:
name: restart
sha256: "70c12d26900b7c451b99eb012dea7b0d5f229f93e705c3915df41c5ddd0b97cd"
url: "https://pub.dev"
source: hosted
version: "1.0.0+1"
restart_app:
dependency: "direct main"
description:
name: restart_app
sha256: "00d5ec3e9de871cedbe552fc41e615b042b5ec654385e090e0983f6d02f655ed"
url: "https://pub.dev"
source: hosted
version: "1.3.2"
screen_retriever:
dependency: transitive
description:
@@ -819,6 +835,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shorebird_code_push:
dependency: "direct main"
description:
name: shorebird_code_push
sha256: "82203f39a66c78548da944dbe4079c2aa2a60fa5bc1105ed707b144c94f04349"
url: "https://pub.dev"
source: hosted
version: "2.0.5"
sky_engine:
dependency: transitive
description: flutter

View File

@@ -29,10 +29,15 @@ dependencies:
path: keypress_simulator/packages/keypress_simulator
shared_preferences: ^2.5.3
flex_color_scheme: ^8.3.0
package_info_plus: ^9.0.0
in_app_update: ^4.2.5
accessibility:
path: accessibility
# shorebird related
shorebird_code_push: ^2.0.5
restart_app: ^1.3.2
restart: ^1.0.0+1
package_info_plus: ^9.0.0
in_app_update: ^4.2.5
http: ^1.3.0
dependency_overrides:
@@ -52,3 +57,4 @@ flutter:
assets:
- CHANGELOG.md
- TROUBLESHOOTING.md
- shorebird.yaml

2
shorebird.yaml Normal file
View File

@@ -0,0 +1,2 @@
app_id: 21d821f0-6795-4fca-aeb1-5a5dbe2d2b62
auto_update: false