Skip to content

Commit

Permalink
Show git hash instead of version in web version
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 13, 2024
1 parent 38878a7 commit 9142010
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -411,3 +412,10 @@ const isNightly =
const shortApplicationName = isNightly ? 'Butterfly Nightly' : 'Butterfly';
const applicationName = 'Linwood $shortApplicationName';
const applicationMinorVersion = '2.2';

Future<String> getCurrentVersion() async {
const envVersion = String.fromEnvironment('version');
if (envVersion.isNotEmpty) return envVersion;
final info = await PackageInfo.fromPlatform();
return info.version;
}
7 changes: 4 additions & 3 deletions app/lib/settings/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -38,6 +38,7 @@ class GeneralSettingsPage extends StatefulWidget {

class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
Future<Meta>? _metaFuture;
final Future<String> _currentVersion = getCurrentVersion();

void loadMeta() => setState(() {
_metaFuture = _fetchMeta();
Expand All @@ -59,9 +60,9 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
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),
Expand Down
1 change: 1 addition & 0 deletions metadata/en-US/changelogs/124.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9142010

Please sign in to comment.