diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0f76b7b..fb87f060 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -279,7 +279,8 @@ jobs: - name: Build iOS (unsigned) run: | # Build Flutter iOS without codesigning - flutter build ios --release --no-codesign --config-only + flutter build ios --release --no-codesign --config-only \ + --dart-define="GIT_COMMIT=$(git rev-parse --short=8 HEAD)" # Use xcodebuild with code signing disabled cd ios diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d715357..b83915d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,12 +73,17 @@ exact Flutter version declared in `.fvmrc` and replace `fvm flutter` with 4. Run the app: ```bash - fvm flutter run + fvm flutter run --dart-define="GIT_COMMIT=$(git rev-parse --short=8 HEAD)" ``` For iOS, run `scripts/build_ios.sh` on macOS before opening `ios/Runner.xcworkspace`. +The About footer shows the short commit supplied through `GIT_COMMIT` at +compile time. The Android build script and iOS release workflow supply it +automatically. Include the same `--dart-define` when running Flutter build +commands directly; without it, the footer shows only the copyright. + ## Project Boundaries ```text diff --git a/lib/constants/app_info.dart b/lib/constants/app_info.dart index dd9e742b..81715371 100644 --- a/lib/constants/app_info.dart +++ b/lib/constants/app_info.dart @@ -5,6 +5,10 @@ class AppInfo { static const String buildNumber = '143'; static const String fullVersion = '$version+$buildNumber'; + static const String gitCommit = String.fromEnvironment('GIT_COMMIT'); + static String get shortGitCommit => + gitCommit.length > 8 ? gitCommit.substring(0, 8) : gitCommit; + static String get displayVersion => kDebugMode ? 'Internal' : version; static const String appName = 'SpotiFLAC Mobile'; diff --git a/lib/screens/settings/about_page.dart b/lib/screens/settings/about_page.dart index 104227ed..20efcae5 100644 --- a/lib/screens/settings/about_page.dart +++ b/lib/screens/settings/about_page.dart @@ -223,7 +223,10 @@ class AboutPage extends StatelessWidget { padding: const EdgeInsets.all(24), child: Center( child: Text( - AppInfo.copyright, + AppInfo.shortGitCommit.isEmpty + ? AppInfo.copyright + : '${AppInfo.copyright} ยท ${AppInfo.shortGitCommit}', + textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodySmall?.copyWith( color: colorScheme.onSurfaceVariant, ), diff --git a/scripts/build_android.sh b/scripts/build_android.sh index eb17e940..ed4f74e3 100644 --- a/scripts/build_android.sh +++ b/scripts/build_android.sh @@ -8,10 +8,12 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")" OUTPUT_DIR="$PROJECT_DIR/build/app/outputs/flutter-apk" cd "$PROJECT_DIR" +BUILD_GIT_COMMIT="$(git rev-parse --short=8 HEAD)" flutter build apk \ --release \ --split-per-abi \ --target-platform android-arm,android-arm64 \ + --dart-define="GIT_COMMIT=$BUILD_GIT_COMMIT" \ "$@" for apk in app-armeabi-v7a-release.apk app-arm64-v8a-release.apk; do