From fdcc815224fa57d63a9827371cc8388098206780 Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 25 Feb 2023 20:21:48 +0100 Subject: [PATCH] Added release workflow & removed githook --- .github/workflows/releaser.yml | 54 +++++++++++ .../0.5.3.0/Bostrot.WSLManager.installer.yaml | 18 ---- .../Bostrot.WSLManager.locale.en-US.yaml | 13 --- .../0.5.3.0/Bostrot.WSLManager.yaml | 9 -- .../1.3.4.0/Bostrot.WSLManager.installer.yaml | 18 ---- .../Bostrot.WSLManager.locale.en-US.yaml | 13 --- .../1.3.4.0/Bostrot.WSLManager.yaml | 9 -- build_script.ps1 => scripts/build_script.ps1 | 0 scripts/msix_download.ps1 | 97 +++++++++++++++++++ scripts/msix_links.ps1 | 71 ++++++++++++++ scripts/pre-push | 52 ++++++++++ 11 files changed, 274 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/releaser.yml delete mode 100644 manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.installer.yaml delete mode 100644 manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.locale.en-US.yaml delete mode 100644 manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.yaml delete mode 100644 manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.installer.yaml delete mode 100644 manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.locale.en-US.yaml delete mode 100644 manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.yaml rename build_script.ps1 => scripts/build_script.ps1 (100%) create mode 100644 scripts/msix_download.ps1 create mode 100644 scripts/msix_links.ps1 create mode 100644 scripts/pre-push diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml new file mode 100644 index 0000000..04e6bed --- /dev/null +++ b/.github/workflows/releaser.yml @@ -0,0 +1,54 @@ +$pattern = "version: (.*?) \#" +$string = Get-Content pubspec.yaml +$wsl2_manager_version = [regex]::match($string, $pattern).Groups[1].Value +Compress-Archive -Path ./build/windows/runner/Release/* -DestinationPath .\wsl2-distro-manager-v$wsl2_manager_version.zip +Write-Output 'gh release create v$wsl2_manager_version ./build/windows/runner/Release/wsl2-distro-manager-v$wsl2_manager_version.zip --notes "This is an automated release."' + +name: Releaser + +on: + push: + branches: + - main + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + # get version from pubspec.yaml + - name: Get version + id: get_version + run: | + $pattern = "version: (.*?) \#" + $string = Get-Content pubspec.yaml + $wsl2_manager_version = [regex]::match($string, $pattern).Groups[1].Value + Write-Output "::set-output name=version::$wsl2_manager_version" + # check if release already exists + - uses: cardinalby/git-get-release-action@v1 + name: Check if release exists + id: check_release + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tag: v${{ steps.get_version.outputs.version }} + # if check_release step fails build + - uses: subosito/flutter-action@v2 + if: ${{ steps.check_release.outcome == 'failure' }} + with: + channel: 'stable' + - run: flutter config --enable-windows-desktop + if: ${{ steps.check_release.outcome == 'failure' }} + - run: flutter build windows + if: ${{ steps.check_release.outcome == 'failure' }} + # create release + - name: Create release + if: ${{ steps.check_release.outcome == 'failure' }} + run: | + Copy-Item -Path ./windows-dlls/* -Destination ./build/windows/runner/Release/ + Compress-Archive -Path ./build/windows/runner/Release/* -DestinationPath .\wsl2-distro-manager-v${{ steps.get_version.outputs.version }}.zip + Write-Output 'gh release create v${{ steps.get_version.outputs.version }} ./build/windows/runner/Release/wsl2-distro-manager-v${{ steps.get_version.outputs.version }}.zip --generate-notes --notes "This is an automated release."' + shell: pwsh + env: + GITHUB_TOKEN: ${{ github.token }} + \ No newline at end of file diff --git a/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.installer.yaml b/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.installer.yaml deleted file mode 100644 index d4929b8..0000000 --- a/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.installer.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Created using wingetcreate 0.4.3.1 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.0.0.schema.json - -PackageIdentifier: Bostrot.WSLManager -PackageVersion: 0.5.3.0 -Installers: -- Platform: - - Windows.Desktop - MinimumOSVersion: 10.0.17763.0 - Architecture: x64 - InstallerType: msix - InstallerUrl: https://github.com/bostrot/wsl2-distro-manager/releases/download/v0.5.3%2B1/wsl2-distro-manager-v0.5.3+1.msix - InstallerSha256: 7008769A030C541F16698DA6AD8F8D422A6F7FEECE45B9BB0A1B8D9135D09F86 - SignatureSha256: EF10E43EB9A95EC4B79548A1195DD6DFC188CE87522813A04341982C14E251D2 - PackageFamilyName: 9891PhantomDevs.WSL2Manager_rqq3vyma0b55r -ManifestType: installer -ManifestVersion: 1.0.0 - diff --git a/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.locale.en-US.yaml b/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.locale.en-US.yaml deleted file mode 100644 index 471471c..0000000 --- a/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.locale.en-US.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Created using wingetcreate 0.4.3.1 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.0.0.schema.json - -PackageIdentifier: Bostrot.WSLManager -PackageVersion: 0.5.3.0 -PackageLocale: en-US -Publisher: Bostrot -PackageName: WSL Manager -License: GPL-3.0 -ShortDescription: A GUI to quickly manage your WSL2 instances. -ManifestType: defaultLocale -ManifestVersion: 1.0.0 - diff --git a/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.yaml b/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.yaml deleted file mode 100644 index 84cd459..0000000 --- a/manifests/b/Bostrot/WSLManager/0.5.3.0/Bostrot.WSLManager.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Created using wingetcreate 0.4.3.1 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.0.0.schema.json - -PackageIdentifier: Bostrot.WSLManager -PackageVersion: 0.5.3.0 -DefaultLocale: en-US -ManifestType: version -ManifestVersion: 1.0.0 - diff --git a/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.installer.yaml b/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.installer.yaml deleted file mode 100644 index b0deceb..0000000 --- a/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.installer.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Created using wingetcreate 1.1.2.0 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.2.0.schema.json - -PackageIdentifier: Bostrot.WSLManager -PackageVersion: 1.3.4.0 -Installers: -- Platform: - - Windows.Desktop - MinimumOSVersion: 10.0.17763.0 - Architecture: x64 - InstallerType: msix - InstallerUrl: https://github.com/bostrot/wsl2-distro-manager/releases/download/v1.3.4/wsl2-distro-manager-v1.3.4.msix - InstallerSha256: 98B702658C0A991A4999363C2942ACB34A6BF38C305F7A7BA72A5F4D1E64B6E3 - SignatureSha256: 02EE110C2DFA2E626C27F1EAB516520717EAC4CFC96391D590FDF898C05B80ED - PackageFamilyName: 9891PhantomDevs.WSL2Manager_rqq3vyma0b55r -ManifestType: installer -ManifestVersion: 1.1.0 - diff --git a/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.locale.en-US.yaml b/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.locale.en-US.yaml deleted file mode 100644 index 1d03c79..0000000 --- a/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.locale.en-US.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Created using wingetcreate 1.1.2.0 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.2.0.schema.json - -PackageIdentifier: Bostrot.WSLManager -PackageVersion: 1.3.4.0 -PackageLocale: en-US -Publisher: Bostrot -PackageName: WSL Manager -License: GPL-3.0 -ShortDescription: A GUI to quickly manage your WSL2 instances. -ManifestType: defaultLocale -ManifestVersion: 1.1.0 - diff --git a/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.yaml b/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.yaml deleted file mode 100644 index 353848b..0000000 --- a/manifests/b/Bostrot/WSLManager/1.3.4.0/Bostrot.WSLManager.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Created using wingetcreate 1.1.2.0 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.2.0.schema.json - -PackageIdentifier: Bostrot.WSLManager -PackageVersion: 1.3.4.0 -DefaultLocale: en-US -ManifestType: version -ManifestVersion: 1.1.0 - diff --git a/build_script.ps1 b/scripts/build_script.ps1 similarity index 100% rename from build_script.ps1 rename to scripts/build_script.ps1 diff --git a/scripts/msix_download.ps1 b/scripts/msix_download.ps1 new file mode 100644 index 0000000..7f76d0f --- /dev/null +++ b/scripts/msix_download.ps1 @@ -0,0 +1,97 @@ +<# + +Copyright https://github.com/MattiasC85/Scripts/blob/master/OSD/Download-AppxFromStore.ps1 + +#> + +Param ( + [Parameter(Mandatory=$True)] + [string] $StoreURL, + [Parameter(Mandatory=$False)] + $SavePathRoot="%tmp%" + ) + +# + +if ($StoreURL.EndsWith("/")) +{ + #write-host "Ends with '/'" + $StoreURL=$StoreURL.Remove($StoreUrl.Length-1,1) +} + +$wchttp=[System.Net.WebClient]::new() +$URI = "https://store.rg-adguard.net/api/GetFiles" +$myParameters = "type=url&url=$($StoreURL)" +#&ring=Retail&lang=sv-SE" + +$wchttp.Headers[[System.Net.HttpRequestHeader]::ContentType]="application/x-www-form-urlencoded" +$HtmlResult = $wchttp.UploadString($URI, $myParameters) + +$Start=$HtmlResult.IndexOf("

The links were successfully received from the Microsoft Store server.

") +#write-host $start + +if ($Start -eq -1) +{ + write-host "Could not get the links, please check the StoreURL." + exit +} + +$TableEnd=($HtmlResult.LastIndexOf("")+8) + + +$SemiCleaned=$HtmlResult.Substring($start,$TableEnd-$start) + +#https://stackoverflow.com/questions/46307976/unable-to-use-ihtmldocument2 +$newHtml=New-Object -ComObject "HTMLFile" +try { + # This works in PowerShell with Office installed + $newHtml.IHTMLDocument2_write($SemiCleaned) +} +catch { + # This works when Office is not installed + $src = [System.Text.Encoding]::Unicode.GetBytes($SemiCleaned) + $newHtml.write($src) +} + +$ToDownload=$newHtml.getElementsByTagName("a") | Select-Object textContent, href + +$SavePathRoot=$([System.Environment]::ExpandEnvironmentVariables("$SavePathRoot")) + +$LastFrontSlash=$StoreURL.LastIndexOf("/") +$ProductID=$StoreURL.Substring($LastFrontSlash+1,$StoreURL.Length-$LastFrontSlash-1) + +# OldRegEx Failed when the %tmp% started with a lowercase char +#if ([regex]::IsMatch("$SavePathRoot\$ProductID","([,!@?#$%^&*()\[\]]+|\\\.\.|\\\\\.|\.\.\\\|\.\\\|\.\.\/|\.\/|\/\.\.|\/\.|;|(? + +Param ( + [Parameter(Mandatory=$True)] + [string] $StoreURL + ) + +# + +if ($StoreURL.EndsWith("/")) +{ + #write-host "Ends with '/'" + $StoreURL=$StoreURL.Remove($StoreUrl.Length-1,1) +} + +$wchttp=[System.Net.WebClient]::new() +$URI = "https://store.rg-adguard.net/api/GetFiles" +$myParameters = "type=url&url=$($StoreURL)" +#&ring=Retail&lang=sv-SE" + +$wchttp.Headers[[System.Net.HttpRequestHeader]::ContentType]="application/x-www-form-urlencoded" +$HtmlResult = $wchttp.UploadString($URI, $myParameters) + +$Start=$HtmlResult.IndexOf("

The links were successfully received from the Microsoft Store server.

") +#write-host $start + +if ($Start -eq -1) +{ + write-host "Could not get the links, please check the StoreURL." + exit 1 +} + +$TableEnd=($HtmlResult.LastIndexOf("")+8) + + +$SemiCleaned=$HtmlResult.Substring($start,$TableEnd-$start) + +#https://stackoverflow.com/questions/46307976/unable-to-use-ihtmldocument2 +$newHtml=New-Object -ComObject "HTMLFile" +try { + # This works in PowerShell with Office installed + $newHtml.IHTMLDocument2_write($SemiCleaned) +} +catch { + # This works when Office is not installed + $src = [System.Text.Encoding]::Unicode.GetBytes($SemiCleaned) + $newHtml.write($src) +} + +$ToDownload=$newHtml.getElementsByTagName("a") | Select-Object textContent, href + +$SavePathRoot=$([System.Environment]::ExpandEnvironmentVariables("$SavePathRoot")) + +$LastFrontSlash=$StoreURL.LastIndexOf("/") +$ProductID=$StoreURL.Substring($LastFrontSlash+1,$StoreURL.Length-$LastFrontSlash-1) + +if ([regex]::IsMatch("$SavePathRoot\$ProductID","([,!@?#$%^&*()\[\]]+|\\\.\.|\\\\\.|\.\.\\\|\.\\\|\.\.\/|\.\/|\/\.\.|\/\.|;|(?> pubspec.yaml +fi + +# Replace msix_version in pubspec.yaml with the version number +sed -i "s/msix_version: .*\.0/msix_version: $version\.0/g" pubspec.yaml + +# Build msix package +flutter pub get +flutter pub run msix:create + +# Create release dir +# mkdir -p build/windows/runner/Release +# cp windows-dlls/*.dll build/windows/runner/Release + +# Remove the msix_config from pubspec.yaml +sed -i '/^# start git-block-ignore/,/^# end git-block-ignore/{/^123/!d}' pubspec.yaml + +# Add & commit the changes +git add -f pubspec.yaml +git add -f build/windows/runner/Release/desktop_window_plugin.dll +git add -f build/windows/runner/Release/flutter_acrylic_plugin.dll +git add -f build/windows/runner/Release/flutter_windows.dll +git add -f build/windows/runner/Release/window_manager_plugin.dll +git add -f build/windows/runner/Release/screen_retriever_plugin.dll +git add -f build/windows/runner/Release/system_theme_plugin.dll +git add -f build/windows/runner/Release/url_launcher_windows_plugin.dll +git add -f build/windows/runner/Release/wsl2distromanager.exe +git add -f build/windows/runner/Release/wsl2distromanager.msix +git add -f build/windows/runner/Release/data + +# git add -f build/windows/runner/Release/msvcp140.dll +# git add -f build/windows/runner/Release/vcruntime140_1.dll +# git add -f build/windows/runner/Release/vcruntime140.dll + +git commit -s -m "Update version number to $version" + +git push --no-verify \ No newline at end of file