mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 02:01:36 +03:00
Specify version with set-version.py.
This commit is contained in:
parent
e86c50fb64
commit
0132cad725
5
.github/workflows/linux.yml
vendored
5
.github/workflows/linux.yml
vendored
@ -18,6 +18,11 @@ jobs:
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Check app versions
|
||||
run: |
|
||||
python set-version.py
|
||||
git diff --exit-code
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
5
.github/workflows/macos.yml
vendored
5
.github/workflows/macos.yml
vendored
@ -15,6 +15,11 @@ jobs:
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Check app versions
|
||||
run: |
|
||||
python set-version.py
|
||||
git diff --exit-code
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
brew update
|
||||
|
5
.github/workflows/windows.yml
vendored
5
.github/workflows/windows.yml
vendored
@ -15,6 +15,11 @@ jobs:
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Check app versions
|
||||
run: |
|
||||
python set-version.py
|
||||
git diff --exit-code
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
choco install swig
|
||||
|
@ -23,9 +23,6 @@ if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
def authenticatorVersionCode = 59900
|
||||
def authenticatorVersionName = '6.0.0-alpha.2'
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
@ -52,8 +49,8 @@ android {
|
||||
applicationId "com.yubico.yubioath"
|
||||
minSdkVersion project.minSdkVersion
|
||||
targetSdkVersion project.targetSdkVersion
|
||||
versionCode authenticatorVersionCode
|
||||
versionName authenticatorVersionName
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,8 +6,8 @@ VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
||||
# Set not needed items to zero 0.
|
||||
filevers=(4, 1, 0, 0),
|
||||
prodvers=(4, 1, 0, 0),
|
||||
filevers=(6, 0, 0, 0),
|
||||
prodvers=(6, 0, 0, 0),
|
||||
# Contains a bitmask that specifies the valid bits 'flags'r
|
||||
mask=0x3f,
|
||||
# Contains a bitmask that specifies the Boolean attributes of the file.
|
||||
|
@ -7,6 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:yubico_authenticator/app/state.dart';
|
||||
|
||||
import 'version.dart';
|
||||
import 'app/logging.dart';
|
||||
import 'app/message.dart';
|
||||
import 'core/state.dart';
|
||||
@ -26,8 +27,7 @@ class AboutPage extends ConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// TODO: Store the version number elsewhere
|
||||
const Text('Yubico Authenticator: 6.0.0-alpha.2'),
|
||||
const Text('Yubico Authenticator: $version'),
|
||||
if (isDesktop)
|
||||
Text('ykman version: ${ref.watch(rpcStateProvider).version}'),
|
||||
Text('Dart version: ${Platform.version}'),
|
||||
|
5
lib/version.dart
Executable file
5
lib/version.dart
Executable file
@ -0,0 +1,5 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// This file is generated by running ./set-version.py <version> <build>
|
||||
|
||||
const String version = '6.0.0-dev1';
|
||||
const int build = 59900;
|
@ -15,7 +15,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.0.0+1
|
||||
|
||||
# This field is updated by running ./set-version.py <version>
|
||||
# DO NOT MANUALLY EDIT THIS!
|
||||
version: 6.0.0+59900
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
|
131
set-version.py
Executable file
131
set-version.py
Executable file
@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import sys
|
||||
|
||||
"""
|
||||
This script updates version numbers in various files.
|
||||
"""
|
||||
|
||||
version_pattern = r"(\d+)\.(\d+)\.(\d+)(-[^\s+]+)?"
|
||||
lib_version_pattern = rf"const\s+String\s+version\s+=\s+'({version_pattern})';"
|
||||
lib_build_pattern = rf"const\s+int\s+build\s+=\s+(\d+);"
|
||||
|
||||
|
||||
def update_file(fname, func):
|
||||
with open(fname) as f:
|
||||
orig = f.read()
|
||||
|
||||
buf = func(orig)
|
||||
|
||||
if buf != orig:
|
||||
with open(fname, "w") as f:
|
||||
f.write(buf)
|
||||
print("Updated", fname)
|
||||
|
||||
def read_lib_version():
|
||||
with open("lib/version.dart") as f:
|
||||
buf = f.read()
|
||||
|
||||
m = re.search(
|
||||
lib_version_pattern,
|
||||
buf,
|
||||
re.MULTILINE,
|
||||
)
|
||||
version = m.group(1)
|
||||
m = re.search(
|
||||
lib_build_pattern,
|
||||
buf,
|
||||
re.MULTILINE,
|
||||
)
|
||||
build = int(m.group(1))
|
||||
return version, build
|
||||
|
||||
|
||||
def update_lib(buf):
|
||||
buf = re.sub(
|
||||
lib_version_pattern,
|
||||
f"const String version = '{version}';",
|
||||
buf,
|
||||
)
|
||||
|
||||
buf = re.sub(
|
||||
lib_build_pattern,
|
||||
f"const int build = {build};",
|
||||
buf,
|
||||
)
|
||||
|
||||
return buf
|
||||
|
||||
# Handle invocation
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
version, build = read_lib_version()
|
||||
print(f"Using version: {version}, build: {build}...")
|
||||
elif len(args) == 2:
|
||||
version = args[0]
|
||||
if not re.fullmatch(version_pattern, version):
|
||||
print("Version is not a valid semver string!")
|
||||
sys.exit(1)
|
||||
build = int(args[1])
|
||||
print(f"Setting new version: {version}, build: {build}...")
|
||||
update_file("lib/version.dart", update_lib)
|
||||
else:
|
||||
print("Usage: set-version.py <version> <build>")
|
||||
sys.exit(1)
|
||||
|
||||
# x.y.z without trailing part
|
||||
short_version = re.search("(\d+\.\d+\.\d+)", version).group()
|
||||
|
||||
# pubspec.yaml
|
||||
def update_pubspec(buf):
|
||||
return re.sub(
|
||||
r'version:\s+\d+\.\d+\.\d+\+\d+',
|
||||
f'version: {short_version}+{build}',
|
||||
buf,
|
||||
)
|
||||
|
||||
# Windows Runner.rc
|
||||
def update_runner_rc(buf):
|
||||
buf = re.sub(
|
||||
rf'#define VERSION_AS_STRING "{version_pattern}"',
|
||||
f'#define VERSION_AS_STRING "{version}"',
|
||||
buf,
|
||||
)
|
||||
|
||||
version_as_number = short_version.replace(".", ",")
|
||||
buf = re.sub(
|
||||
r"#define VERSION_AS_NUMBER \d+,\d+,\d+",
|
||||
f"#define VERSION_AS_NUMBER {version_as_number}",
|
||||
buf,
|
||||
)
|
||||
return buf
|
||||
|
||||
# Helper version_info
|
||||
def update_helper_version(buf):
|
||||
version_tuple = repr(tuple(int(d) for d in short_version.split(".")) + (0,))
|
||||
buf = re.sub(
|
||||
rf'filevers=\(\d+, \d+, \d+, \d+\)',
|
||||
f'filevers={version_tuple}',
|
||||
buf,
|
||||
)
|
||||
buf = re.sub(
|
||||
rf'prodvers=\(\d+, \d+, \d+, \d+\)',
|
||||
f'prodvers={version_tuple}',
|
||||
buf,
|
||||
)
|
||||
buf = re.sub(
|
||||
rf"'FileVersion', '{version_pattern}'",
|
||||
f"'FileVersion', '{version}'",
|
||||
buf,
|
||||
)
|
||||
buf = re.sub(
|
||||
rf"'ProductVersion', '{version_pattern}'",
|
||||
f"'ProductVersion', '{version}'",
|
||||
buf,
|
||||
)
|
||||
return buf
|
||||
|
||||
|
||||
update_file("pubspec.yaml", update_pubspec)
|
||||
update_file("windows/runner/Runner.rc", update_runner_rc)
|
||||
update_file("helper/version_info.txt", update_helper_version)
|
@ -63,13 +63,13 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
|
||||
#ifdef FLUTTER_BUILD_NUMBER
|
||||
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
|
||||
#else
|
||||
#define VERSION_AS_NUMBER 1,0,0
|
||||
#define VERSION_AS_NUMBER 6,0,0
|
||||
#endif
|
||||
|
||||
#ifdef FLUTTER_BUILD_NAME
|
||||
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
|
||||
#else
|
||||
#define VERSION_AS_STRING "1.0.0"
|
||||
#define VERSION_AS_STRING "6.0.0-dev1"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
|
Loading…
Reference in New Issue
Block a user