Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WPILib build #112

Merged
merged 8 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion .github/workflows/elastic-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
if: ${{ matrix.build-option == 'macos' }}
run: |
cd build/macos/Build/Products/Release
zip -r Elastic-macOS.zip elastic_dashboard.app --symlinks
zip -r ${{ matrix.artifact-name }}.zip elastic_dashboard.app --symlinks

- name: Upload artifact
if: ${{ matrix.build-option != 'windows' }}
Expand All @@ -157,3 +157,64 @@ jobs:
name: ${{ matrix.artifact-name }}_installer
path: "build/windows/x64/installer"
if-no-files-found: error

build-wpilib:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
build-option: "windows"
artifact-path: "build/windows/x64/runner/Release"
artifact-name: Elastic-WPILib-Windows
- os: macos-latest
build-option: "macos"
artifact-path: "build/macos/Build/Products/Release/Elastic-WPILib-macOS.zip"
artifact-name: Elastic-WPILib-macOS
- os: ubuntu-22.04
build-option: "linux"
artifact-path: "build/linux/x64/release/bundle"
artifact-name: Elastic-WPILib-Linux

name: "Build - ${{ matrix.artifact-name }}"
needs: [formatting-analysis, test]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install flutter build dependencies
if: ${{ matrix.build-option == 'linux' }}
run: |
sudo apt-get update -y
sudo apt-get install -y libglu1-mesa ninja-build libgtk-3-dev liblzma-dev

- name: Setup flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
cache-path: ${{ runner.tool_cache }}/flutter/${{ matrix.build-option }}

- name: Install dependencies
run: flutter pub get

- name: Generate icons
run: dart run flutter_launcher_icons -f wpilib_icon_config.yaml

- name: Build app
run: flutter build ${{ matrix.build-option }} --dart-define=ELASTIC_WPILIB=true

- name: Zip release
if: ${{ matrix.build-option == 'macos' }}
run: |
cd build/macos/Build/Products/Release
zip -r ${{ matrix.artifact-name }}.zip elastic_dashboard.app --symlinks

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error
Binary file added assets/logos/wpilib_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wpilib-icon.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart';

import 'package:elastic_dashboard/pages/dashboard_page.dart';
import 'package:elastic_dashboard/services/app_distributor.dart';
import 'package:elastic_dashboard/services/field_images.dart';
import 'package:elastic_dashboard/services/log.dart';
import 'package:elastic_dashboard/services/nt_connection.dart';
Expand Down Expand Up @@ -209,7 +210,7 @@ class _ElasticState extends State<Elastic> {
);
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Elastic',
title: appTitle,
theme: theme,
home: DashboardPage(
ntConnection: widget.ntConnection,
Expand Down
42 changes: 24 additions & 18 deletions lib/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:window_manager/window_manager.dart';

import 'package:elastic_dashboard/services/app_distributor.dart';
import 'package:elastic_dashboard/services/hotkey_manager.dart';
import 'package:elastic_dashboard/services/ip_address_util.dart';
import 'package:elastic_dashboard/services/log.dart';
Expand Down Expand Up @@ -226,7 +227,10 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
apiListener.initializeListeners();
});

Future(() => _checkForUpdates(notifyIfLatest: false, notifyIfError: false));
if (!isWPILib) {
Future(
() => _checkForUpdates(notifyIfLatest: false, notifyIfError: false));
}

_robotNotificationListener = RobotNotificationsListener(
ntConnection: widget.ntConnection,
Expand Down Expand Up @@ -882,10 +886,10 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

showAboutDialog(
context: context,
applicationName: 'Elastic',
applicationName: appTitle,
applicationVersion: widget.version,
applicationIcon: Image.asset(
'assets/logos/logo.png',
logoPath,
width: iconTheme.size,
height: iconTheme.size,
),
Expand Down Expand Up @@ -1357,7 +1361,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
children: [
Center(
child: Image.asset(
'assets/logos/logo.png',
logoPath,
width: 24.0,
height: 24.0,
),
Expand Down Expand Up @@ -1487,21 +1491,22 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
],
),
),
// Check for Updates
MenuItemButton(
style: menuButtonStyle,
onPressed: () {
_checkForUpdates();
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.update_outlined),
SizedBox(width: 8),
Text('Check for updates'),
],
// Check for Updates (not for WPILib distribution)
if (!isWPILib)
MenuItemButton(
style: menuButtonStyle,
onPressed: () {
_checkForUpdates();
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.update_outlined),
SizedBox(width: 8),
Text('Check for Updates'),
],
),
),
),
],
child: const Text(
'Help',
Expand Down Expand Up @@ -1554,6 +1559,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

return Scaffold(
appBar: CustomAppBar(
titleText: appTitle,
onWindowClose: onWindowClose,
menuBar: menuBar,
),
Expand Down
5 changes: 5 additions & 0 deletions lib/services/app_distributor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bool get isWPILib => const bool.fromEnvironment('ELASTIC_WPILIB');

String logoPath = 'assets/logos/logo.png';

String get appTitle => (!isWPILib) ? 'Elastic' : 'Elastic (WPILib)';
12 changes: 12 additions & 0 deletions wpilib_icon_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
flutter_launcher_icons:
image_path: "assets/logos/wpilib_logo.png"
windows:
generate: true
image_path: "assets/logos/wpilib_logo.png"
icon_size: 256
macos:
generate: true
image_path: "assets/logos/wpilib_logo.png"
linux:
generate: true
image_path: "assets/logos/wpilib_logo.png"
Loading