Skip to content

Commit

Permalink
core: bump version script
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Apr 7, 2024
1 parent 9b8d27f commit 3265b52
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
47 changes: 47 additions & 0 deletions bump_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// ignore_for_file: avoid_print

import 'dart:io';

void main(List<String> args) {
final pubspec = File('pubspec.yaml');
final pubspecLines = pubspec.readAsLinesSync();
const versionLinePrefix = 'version: ';
bool didUpdate = false;
for (int i = 0; i < pubspecLines.length; i++) {
final line = pubspecLines[i];
if (line.startsWith(versionLinePrefix)) {
final currentName = line.split(versionLinePrefix).last.split('+').first;
final currentVersion = currentName.split('-').first; // stripping `-beta`
if (args.isEmpty) {
print('please provide version name, current is: $currentVersion');
break;
}
final versionName = args[0];
if (currentVersion == versionName) {
print('you entered the same version name: $currentVersion, enter `y` to force bump');
final input = stdin.readLineSync();
if (input?.toLowerCase() != 'y') break;
}
final isRelease = args.contains('-r');
final suffix = isRelease ? '' : '-beta';
final newVersionName = "$versionName$suffix";

final date = DateTime.now().toUtc();
final year = date.year.toString();
String padLeft(int number) => number.toString().padLeft(2, '0');
final minutesPercentage = (date.minute / 60).toString().substring(2, 3);
final newBuildNumber = "${year.substring(2)}${padLeft(date.month)}${padLeft(date.day)}${padLeft(date.hour)}$minutesPercentage";
final newLine = '$versionLinePrefix$newVersionName+$newBuildNumber';
print("old $line");
pubspecLines[i] = newLine;
print("new $newLine");
didUpdate = true;
pubspec.writeAsStringSync("""${pubspecLines.join('\n')}
""");
break;
}
}
if (!didUpdate) {
print('couldnt bump version');
}
}
2 changes: 1 addition & 1 deletion lib/core/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class NamidaDeviceInfo {
hours = int.parse("${yyMMddHHP[6]}${yyMMddHHP[7]}");
minutes = (60 * double.parse("0.${yyMMddHHP[8]}")).round(); // 0.5, 0.8, 1.0, etc.
} catch (_) {}
buildDate = DateTime.utc(year, month, day, hours - 2, minutes);
buildDate = DateTime.utc(year, month, day, hours, minutes);
} catch (_) {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pages/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AboutPage extends StatelessWidget {
String _getDateDifferenceText() {
final buildDate = NamidaDeviceInfo.buildDate;
if (buildDate == null) return '';
final diff = DateTime.now().difference(buildDate.toLocal()).abs();
final diff = DateTime.now().toUtc().difference(buildDate).abs();
final diffDays = diff.inDays;
if (diffDays > 0) return "(${diffDays.displayDayKeyword})";
final diffHours = diff.inHours;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.0.6-beta+240407158
version: 2.0.6-beta+240407144

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit 3265b52

Please sign in to comment.