diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e18e66cee240..5b58f5f28d3f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,6 +56,8 @@ jobs: - name: Install dependencies run: | flutter pub get + - name: Get Git Commit Hash + run: echo "GIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV - name: Set flavor if: github.ref != 'refs/heads/main' run: | @@ -67,7 +69,7 @@ jobs: echo "SETONIX_FLAVOR=stable" >> $GITHUB_ENV echo "WEB_DIR=web" >> $GITHUB_ENV - name: Build - run: flutter build web --wasm --release --no-web-resources-cdn --dart-define=flavor=$SETONIX_FLAVOR + run: flutter build web --wasm --release --no-web-resources-cdn --dart-define=flavor=$SETONIX_FLAVOR --dart-define=version=$GIT_HASH - name: Deploy to SFTP if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' env: diff --git a/app/lib/main.dart b/app/lib/main.dart index 413838553148..224cfa4f0fa1 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -20,6 +20,7 @@ import 'package:lw_file_system/lw_file_system.dart'; import 'package:lw_sysapi/lw_sysapi.dart'; import 'package:material_leap/l10n/leap_localizations.dart'; import 'package:material_leap/material_leap.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:window_manager/window_manager.dart'; import 'package:flutter_localized_locales/flutter_localized_locales.dart'; @@ -411,3 +412,10 @@ const isNightly = const shortApplicationName = isNightly ? 'Butterfly Nightly' : 'Butterfly'; const applicationName = 'Linwood $shortApplicationName'; const applicationMinorVersion = '2.2'; + +Future getCurrentVersion() async { + const envVersion = String.fromEnvironment('version'); + if (envVersion.isNotEmpty) return envVersion; + final info = await PackageInfo.fromPlatform(); + return info.version; +} diff --git a/app/lib/settings/general.dart b/app/lib/settings/general.dart index 298478f31283..51963eb6162d 100644 --- a/app/lib/settings/general.dart +++ b/app/lib/settings/general.dart @@ -2,10 +2,10 @@ import 'dart:convert'; import 'package:butterfly/api/open.dart'; import 'package:butterfly/cubits/settings.dart'; +import 'package:butterfly/main.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:material_leap/material_leap.dart'; -import 'package:package_info_plus/package_info_plus.dart'; import 'package:phosphor_flutter/phosphor_flutter.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -38,6 +38,7 @@ class GeneralSettingsPage extends StatefulWidget { class _GeneralSettingsPageState extends State { Future? _metaFuture; + final Future _currentVersion = getCurrentVersion(); void loadMeta() => setState(() { _metaFuture = _fetchMeta(); @@ -59,9 +60,9 @@ class _GeneralSettingsPageState extends State { inView: widget.inView, ), body: FutureBuilder( - future: PackageInfo.fromPlatform(), + future: _currentVersion, builder: (context, snapshot) { - final currentVersion = snapshot.data?.version ?? '?'; + final currentVersion = snapshot.data ?? '?'; return ListView(children: [ Card( margin: const EdgeInsets.all(8), diff --git a/metadata/en-US/changelogs/124.txt b/metadata/en-US/changelogs/124.txt index b5389bf73ef4..368cf29650e5 100644 --- a/metadata/en-US/changelogs/124.txt +++ b/metadata/en-US/changelogs/124.txt @@ -15,6 +15,7 @@ * Fix temporary import handler does not get removed after clicking * Fix asset hash not correctly working with filenames * Fix duplicated asset importing +* Show git hash instead of version in web version * Upgrade to flutter 3.27 Read more here: https://linwood.dev/butterfly/2.2.3-rc.1 \ No newline at end of file