From 1239add4d3d6e265f0a3fe01c98c212be46ea522 Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:22:03 +0800 Subject: [PATCH 1/7] inno setup dynamic use exe file version --- windows_inno_setup.iss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/windows_inno_setup.iss b/windows_inno_setup.iss index 641da4c56d..edd85d633a 100644 --- a/windows_inno_setup.iss +++ b/windows_inno_setup.iss @@ -2,10 +2,11 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Mixin" -#define MyAppVersion "0.37.8" #define MyAppPublisher "Mixin, Inc." #define MyAppURL "https://mixin.one/" #define MyAppExeName "mixin_desktop.exe" +#define MyAppPath ".\build\windows\runner\Release\" + MyAppExeName +#define MyAppVersion GetVersionNumbersString(MyAppPath) [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. From 912530d66cf4dd60300d5abbf6844c6d1aef4161 Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:43:33 +0800 Subject: [PATCH 2/7] auto update app version or build number by dart define. --- .github/workflows/manual-build.yml | 30 ++++++++++++++++++++++++------ lib/utils/system/package_info.dart | 10 +++++++--- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index bcd98d7b99..a315c1bfed 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -4,11 +4,11 @@ name: Manual Build App # or API. on: workflow_dispatch: - inputs: - flutter_channel: - description: "run with flutter channel, eg: master, beta, stable" - required: true - default: "master" + inputs: + flutter_channel: + description: "run with flutter channel, eg: master, beta, stable" + required: true + default: "master" push: tags: - 'v*' @@ -176,8 +176,26 @@ jobs: - name: Run tests run: flutter test + - name: Read App Version + id: read-app-version + uses: jbutcher5/read-yaml@1.6 + with: + path: pubspec.yaml + key: version + + - name: Split version and build number + id: app-version + run: | + set "version_str=${{ steps.read-app-version.outputs.value }}" + set "version=%version_str:+=" & set "build_number=%" + echo "::set-output name=version::%version%" + echo "::set-output name=build_number::%build_number%" + - name: Build APP - run: flutter build windows + run: | + set "version_str=${{ steps.read-app-version.outputs.value }}" + set "version=%version_str:+=" & set "build_number=%" + flutter build windows --dart-define="APP_VERSION=%version%" --dart-define="APP_BUILD_NUMBER=%build_number%" - name: Build Installer run: | diff --git a/lib/utils/system/package_info.dart b/lib/utils/system/package_info.dart index a59c291d8c..058686e7ff 100644 --- a/lib/utils/system/package_info.dart +++ b/lib/utils/system/package_info.dart @@ -5,13 +5,17 @@ import 'package:package_info_plus/package_info_plus.dart'; import '../logger.dart'; -const kMixinVersion = '0.37.8'; +// auto added by .github/workflows/manual-build.yml +const _kAppVersion = + String.fromEnvironment('APP_VERSION', defaultValue: '0.37.0'); +const _kAppBuildNumber = + String.fromEnvironment('APP_BUILD_NUMBER', defaultValue: '0'); final _packageInfo = PackageInfo( appName: 'mixin', packageName: 'mixin_desktop', - version: kMixinVersion, - buildNumber: '', + version: _kAppVersion, + buildNumber: _kAppBuildNumber, ); /// Returns the package info of the current app. From bb347538c5bd363a3dbb3ddfa5d93f0706c6c16b Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:52:12 +0800 Subject: [PATCH 3/7] fix key path --- .github/workflows/manual-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index a315c1bfed..0c2f8b9c76 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -181,7 +181,7 @@ jobs: uses: jbutcher5/read-yaml@1.6 with: path: pubspec.yaml - key: version + key-path: '["version"]' - name: Split version and build number id: app-version From 1af522e07ae56a09105fec7c283c622c13bda54b Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 18:00:40 +0800 Subject: [PATCH 4/7] fix file --- .github/workflows/manual-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 0c2f8b9c76..68c913e328 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -180,7 +180,7 @@ jobs: id: read-app-version uses: jbutcher5/read-yaml@1.6 with: - path: pubspec.yaml + file: './pubspec.yaml' key-path: '["version"]' - name: Split version and build number From 6a6e97060f667a70b0373a7b762c3f7169d43c05 Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 18:08:45 +0800 Subject: [PATCH 5/7] improve --- .github/workflows/manual-build.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 68c913e328..4cc5e51cd2 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -183,14 +183,6 @@ jobs: file: './pubspec.yaml' key-path: '["version"]' - - name: Split version and build number - id: app-version - run: | - set "version_str=${{ steps.read-app-version.outputs.value }}" - set "version=%version_str:+=" & set "build_number=%" - echo "::set-output name=version::%version%" - echo "::set-output name=build_number::%build_number%" - - name: Build APP run: | set "version_str=${{ steps.read-app-version.outputs.value }}" From 72f87b80cc50a5dd2244a4238c1a6fec165a6548 Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 18:40:07 +0800 Subject: [PATCH 6/7] migrate to powershell --- .github/workflows/manual-build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 4cc5e51cd2..6919b48754 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -185,9 +185,10 @@ jobs: - name: Build APP run: | - set "version_str=${{ steps.read-app-version.outputs.value }}" - set "version=%version_str:+=" & set "build_number=%" - flutter build windows --dart-define="APP_VERSION=%version%" --dart-define="APP_BUILD_NUMBER=%build_number%" + $version_str="${{ steps.read-app-version.outputs.value }}" + $version=$version_str.Split("+")[0] + $build_number=$version_str.Split("+")[1] + flutter build windows --dart-define="APP_VERSION=$version" --dart-define="APP_BUILD_NUMBER=$build_number" - name: Build Installer run: | From bf6bd250ccdaead7e6a04532a959237fc10072de Mon Sep 17 00:00:00 2001 From: boyan01 <17426470+boyan01@users.noreply.github.com> Date: Fri, 13 Jan 2023 18:54:11 +0800 Subject: [PATCH 7/7] read version by powershell --- .github/workflows/manual-build.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 6919b48754..476237a60d 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -176,16 +176,9 @@ jobs: - name: Run tests run: flutter test - - name: Read App Version - id: read-app-version - uses: jbutcher5/read-yaml@1.6 - with: - file: './pubspec.yaml' - key-path: '["version"]' - - name: Build APP run: | - $version_str="${{ steps.read-app-version.outputs.value }}" + $version_str=$(gc .\pubspec.yaml | select-string '(?<=^version: ).*' -AllMatches | Select-Object -Expand Matches | %{$_.Value}) $version=$version_str.Split("+")[0] $build_number=$version_str.Split("+")[1] flutter build windows --dart-define="APP_VERSION=$version" --dart-define="APP_BUILD_NUMBER=$build_number"