From da2bf5043e234eee6b8d81d469979d704c9b980e Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 14:16:31 +0200 Subject: [PATCH 01/37] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..748ec06 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" From c9cd134b8179470961c7e4ef4a45b9b074386e26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 11 May 2024 14:42:55 +0200 Subject: [PATCH 02/37] Bump actions/setup-python from 2 to 5 (#8) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/PackageCount.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PackageCount.yml b/.github/workflows/PackageCount.yml index 9c2a056..c2067bb 100644 --- a/.github/workflows/PackageCount.yml +++ b/.github/workflows/PackageCount.yml @@ -15,7 +15,7 @@ jobs: - name: Check out code uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies From d5bdf3bab2981345e186b3edc836cebadaed41bf Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 13:01:58 +0000 Subject: [PATCH 03/37] remove deprecated github output --- .github/workflows/PackageCount.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/PackageCount.yml b/.github/workflows/PackageCount.yml index c2067bb..9072e3e 100644 --- a/.github/workflows/PackageCount.yml +++ b/.github/workflows/PackageCount.yml @@ -23,8 +23,8 @@ jobs: - name: Count packages id: count run: | - echo "::set-output name=countgithub::$(python3 Scripts/package_count.py .github/workflows/GithubReleases.yml)" - echo "::set-output name=countscript::$(python3 Scripts/package_count.py .github/workflows/update-via-script.yml)" + echo "countgithub=$(python3 Scripts/package_count.py .github/workflows/GithubReleases.yml)" >> $GITHUB_OUTPUT + echo "countscript=$(python3 Scripts/package_count.py .github/workflows/update-via-script.yml)" >> $GITHUB_OUTPUT - name: Update README run: | countgithub=${{ steps.count.outputs.countgithub }} From 62c60b155a8586f4b77688592f96077bb2e99333 Mon Sep 17 00:00:00 2001 From: Klaus Dandl <76051010+Utesgui@users.noreply.github.com> Date: Sat, 11 May 2024 20:33:13 +0200 Subject: [PATCH 04/37] Reduce duplicate code (#9) * chore: Update package count badge * chore: Update Get-VersionAndUrl function to use WebsiteURL parameter instead of VersionInfoURL * chore: Update Update-WingetPackage function to use provided WebsiteURL parameter * Refactor Update-WingetPackage function to include WebsiteURL parameter * Refactor Update-WingetPackage function to include WebsiteURL parameter * Refactor Update-WingetPackage function to include WebsiteURL parameter * Refactor Update-SmartProjects.IsoBuster.ps1 to improve readability and error handling * Refactor Get-ProductVersionFromFile function to handle null version info --- .github/workflows/test.yml | 11 + .github/workflows/update-via-script.yml | 33 ++- Scripts/Update-Crucial.StorageExecutive.ps1 | 81 +----- Scripts/Update-FlipperDevicesInc.qFlipper.ps1 | 65 +---- Scripts/Update-Gitbutler.GitButler.ps1 | 74 +---- Scripts/Update-Glarysoft.GlaryUtilities.ps1 | 82 +----- Scripts/Update-Logitech.OptionsPlus.ps1 | 85 +----- Scripts/Update-Loupedeck.Loupedeck.ps1 | 74 +---- Scripts/Update-MongoDB.Compass.Full.ps1 | 17 ++ Scripts/Update-MongoDB.Compass.Isolated.ps1 | 17 ++ Scripts/Update-MongoDB.Compass.Readonly.ps1 | 17 ++ Scripts/Update-MongoDB.Compass.ps1 | 110 -------- Scripts/Update-MongoDB.DatabaseTools.ps1 | 108 +------- Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 | 98 +------ Scripts/Update-MongoDB.MongoDBCLI.ps1 | 100 +------ Scripts/Update-MongoDB.Server.ps1 | 76 +----- Scripts/Update-MongoDB.Shell.ps1 | 75 +---- Scripts/Update-SmartProjects.IsoBuster.ps1 | 88 +----- .../Update-StrawberryPerl.StrawberryPerl.ps1 | 84 +----- .../Update-Samsung.SamsungMagician.ps1 | 0 Scripts/common.ps1 | 258 ++++++++++++++++++ Scripts/generic.ps1 | 12 + 22 files changed, 415 insertions(+), 1150 deletions(-) create mode 100644 Scripts/Update-MongoDB.Compass.Full.ps1 create mode 100644 Scripts/Update-MongoDB.Compass.Isolated.ps1 create mode 100644 Scripts/Update-MongoDB.Compass.Readonly.ps1 delete mode 100644 Scripts/Update-MongoDB.Compass.ps1 rename Scripts/{ => _unused}/Update-Samsung.SamsungMagician.ps1 (100%) create mode 100644 Scripts/common.ps1 create mode 100644 Scripts/generic.ps1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76fd792..62fc94f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,3 +14,14 @@ jobs: run: Invoke-WebRequest -Uri https://raw.githubusercontent.com/microsoft/winget-pkgs/master/Tools/SandboxTest.ps1 -OutFile SandboxTest.ps1 - name: Run Sandbox Script run: .\SandboxTest.ps1 -WinGetVersion 1.7 -Script {winget install Git.Git --accept-source-agreements} + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Update package + # id: update_version + # env: + # GITHUB_TOKEN: ${{ secrets.WINGET_PAT }} + # WINGET_PKGS_FORK_REPO: ${{ vars.WINGET_PKGS_FORK_REPO }} + # WebsiteURL: "https://www.isobuster.com/downloads/isobuster/isobuster_install_64bit.exe https://www.isobuster.com/downloads/isobuster/isobuster_install.exe" + # PackageName: "SmartProjects.IsoBuster" + # With: "Komac" + # run: .\Scripts\generic.ps1 \ No newline at end of file diff --git a/.github/workflows/update-via-script.yml b/.github/workflows/update-via-script.yml index 0808438..ff9839d 100644 --- a/.github/workflows/update-via-script.yml +++ b/.github/workflows/update-via-script.yml @@ -15,31 +15,49 @@ jobs: matrix: include: - PackageName: "MongoDB.Server" - WebsiteURL: "https://www.mongodb.com/try/download/community" + WebsiteURL: "https://www.mongodb.com/try/download/community" + With: WinGetCreate - PackageName: "MongoDB.MongoDBCLI" WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate - PackageName: "MongoDB.Shell" - WebsiteURL: "https://www.mongodb.com/try/download/tools" + WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate - PackageName: "MongoDB.MongoDBAtlasCLI" WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate - PackageName: "MongoDB.DatabaseTools" - WebsiteURL: "https://www.mongodb.com/try/download/tools" - - PackageName: "MongoDB.Compass" + WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate + - PackageName: "MongoDB.Compass.Full" WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate + - PackageName: "MongoDB.Compass.Isolated" + WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate + - PackageName: "MongoDB.Compass.Readonly" + WebsiteURL: "https://www.mongodb.com/try/download/tools" + With: WinGetCreate - PackageName: "Logitech.OptionsPlus" - WebsiteURL: "https://download01.logi.com/web/ftp/pub/techsupport/optionsplus/logioptionsplus_installer.exe" + WebsiteURL: "https://download01.logi.com/web/ftp/pub/techsupport/optionsplus/logioptionsplus_installer.exe" + With: WinGetCreate - PackageName: "Glarysoft.GlaryUtilities" WebsiteURL: "https://download.glarysoft.com/gusetup.exe" + With: WinGetCreate - PackageName: "GitButler.GitButler" - WebsiteURL: "https://app.gitbutler.com/downloads/release/windows/x86_64/msi" + WebsiteURL: "https://app.gitbutler.com/downloads/release/windows/x86_64/msi" + With: WinGetCreate - PackageName: "FlipperDevicesInc.qFlipper" WebsiteURL: "https://update.flipperzero.one/qFlipper/directory.json" + With: WinGetCreate - PackageName: "Loupedeck.Loupedeck" WebsiteURL: "https://download.loupedeck.com/software/latest-win" + With: WinGetCreate - PackageName: "StrawberryPerl.StrawberryPerl" WebsiteURL: "https://github.com/StrawberryPerl/Perl-Dist-Strawberry" - PackageName: "Crucial.StorageExecutive" WebsiteURL: "https://www.crucial.com/content/dam/crucial/support/storage-executive-win-64.zip" + With: WinGetCreate - PackageName: "SmartProjects.IsoBuster" WebsiteURL: "https://www.isobuster.com/downloads/isobuster/isobuster_install_64bit.exe https://www.isobuster.com/downloads/isobuster/isobuster_install.exe" @@ -57,6 +75,7 @@ jobs: WINGET_PKGS_FORK_REPO: ${{ vars.WINGET_PKGS_FORK_REPO }} WebsiteURL: ${{ matrix.WebsiteURL }} PackageName: ${{ matrix.PackageName }} - run: .\Scripts\Update-${{ matrix.PackageName }}.ps1 + With: ${{ matrix.With }} + run: .\Scripts\generic.ps1 diff --git a/Scripts/Update-Crucial.StorageExecutive.ps1 b/Scripts/Update-Crucial.StorageExecutive.ps1 index 68e40af..922ed19 100644 --- a/Scripts/Update-Crucial.StorageExecutive.ps1 +++ b/Scripts/Update-Crucial.StorageExecutive.ps1 @@ -1,80 +1,7 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} +$latestVersionUrl = $WebsiteURL +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersion" -# download latest version from loupedeck.com and get version by filename -$latestVersionUrl = $url -#create directory downloads and change into it -$DownloadFileName = "storage-executive-win-64.zip" -Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName - -# Unzip the downloaded file -$UnzipPath = "." -Expand-Archive -Path $DownloadFileName -DestinationPath $UnzipPath - -$file = Get-ChildItem -Path . -Filter "*.exe" -$versionInfo = $file.VersionInfo.ProductVersion - -if ($null -eq $versionInfo) { - Write-Host "Could not find version info in file" - exit 1 -} - -Write-Host "Found latest version: $versionInfo" - -$latestVersion = $versionInfo - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" -$prMessage = "Update version: $wingetPackage version $latestVersion" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Output "Downloading wingetcreate and open PR for $wingetPackage Version $latestVersion" - # Invoke-WebRequest "https://github.com/russellbanks/Komac/releases/download/v2.2.1/KomacPortable-x64.exe" -OutFile komac.exe - # .\komac.exe update --identifier $wingetPackage --version $latestVersion --urls $latestVersionUrl -s -t $gitToken - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl|x64" --prtitle $prMessage -t $gitToken - - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return "$latestVersionUrl|x64", $versionInfo diff --git a/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 b/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 index 6bd8a45..6385229 100644 --- a/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 +++ b/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 @@ -1,67 +1,8 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$url = ${Env:WebsiteURL} -$wingetPackage = ${Env:PackageName} -$versionDirectoryUrl = $url -Write-Host "Try to update $wingetPackage" - - -$versionDirectory = Invoke-RestMethod -Uri $versionDirectoryUrl +$versionDirectory = Invoke-RestMethod -Uri $WebsiteURL $latestVersionDirectory = ($versionDirectory.channels | Where-Object id -eq "release").versions.version $latestVersionUrl = (($versionDirectory.channels | Where-Object id -eq "release").versions.files | Where-Object { ($_.target -eq "windows/amd64") -and ($_.type -eq "installer") }).url -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersionDirectory" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - Write-Host "Fetching existing PRs" - # Check for existing PRs - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersionDirectory -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $latestVersionDirectory, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Update-Gitbutler.GitButler.ps1 b/Scripts/Update-Gitbutler.GitButler.ps1 index 8435fdc..0408bf2 100644 --- a/Scripts/Update-Gitbutler.GitButler.ps1 +++ b/Scripts/Update-Gitbutler.GitButler.ps1 @@ -1,19 +1,8 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} +. .\Scripts\common.ps1 -Write-Host "Try to update $wingetPackage" # Follow redirect of https://app.gitbutler.com/downloads/release/windows/x86_64/msi -$website = $url +$website = $WebsiteURL $absolutURL=[System.Net.HttpWebRequest]::Create($website).GetResponse().ResponseUri.AbsoluteUri # regex to check if variable absolutURL is valid URL @@ -34,61 +23,4 @@ $fileName = $latestVersionUrl.Split("/")[-1] # Get Version via Regex. The version is the part betweet "GitButler_" and "_x64" $latestVersion = $fileName -replace ".*GitButler_(.*)_(x64|x86).*", '$1' -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $latestVersion, $latestVersionUrl diff --git a/Scripts/Update-Glarysoft.GlaryUtilities.ps1 b/Scripts/Update-Glarysoft.GlaryUtilities.ps1 index 08f9e6e..34c29fa 100644 --- a/Scripts/Update-Glarysoft.GlaryUtilities.ps1 +++ b/Scripts/Update-Glarysoft.GlaryUtilities.ps1 @@ -1,81 +1,7 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} - +. .\Scripts\common.ps1 +$latestVersionUrl = $WebsiteURL # download latest version from loupedeck.com and get version by filename -$latestVersionUrl = $url -#create directory downloads and change into it -$DownloadFileName = "gusetup.exe" -Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName -$file = Get-ChildItem -Path $DownloadFileName -$versionInfo = $file.VersionInfo.ProductVersionRaw - -if ($null -eq $versionInfo) { - Write-Host "Could not find version info in file" - exit 1 -} - -Write-Host "Found latest version: $versionInfo" -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$latestVersion = $versionInfo - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersionRaw" - if ($ExistingPRs.Count -gt 0) { - Write-Output "Version already in winget" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Output "Downloading wingetcreate and open PR for $wingetPackage Version $latestVersion" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $versionInfo, $latestVersionUrl diff --git a/Scripts/Update-Logitech.OptionsPlus.ps1 b/Scripts/Update-Logitech.OptionsPlus.ps1 index af49031..66588c7 100644 --- a/Scripts/Update-Logitech.OptionsPlus.ps1 +++ b/Scripts/Update-Logitech.OptionsPlus.ps1 @@ -1,84 +1,7 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} - +. .\Scripts\common.ps1 +$latestVersionUrl = $WebsiteURL # download latest version from loupedeck.com and get version by filename -$latestVersionUrl = $url -#create directory downloads and change into it -$DownloadFileName = "logioptionsplus_installer.exe" -Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName -$file = Get-ChildItem -Path $DownloadFileName -$versionInfo = $file.VersionInfo.ProductVersion - -if ($null -eq $versionInfo) { - Write-Host "Could not find version info in file" - exit 1 -} - -Write-Host "Found latest version: $versionInfo" - -$latestVersion = $versionInfo - -$fullDownloadURL = $latestVersionUrl - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersion" - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Output "Downloading wingetcreate and open PR for $wingetPackage Version $latestVersion" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $versionInfo, $latestVersionUrl diff --git a/Scripts/Update-Loupedeck.Loupedeck.ps1 b/Scripts/Update-Loupedeck.Loupedeck.ps1 index b506c2b..eb25db6 100644 --- a/Scripts/Update-Loupedeck.Loupedeck.ps1 +++ b/Scripts/Update-Loupedeck.Loupedeck.ps1 @@ -1,27 +1,10 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$url = ${Env:WebsiteURL} -$wingetPackage = ${Env:PackageName} +$latestVersionUrl = $WebsiteURL # download latest version from loupedeck.com and get version by filename -$latestVersionUrl = $url -#create directory downloads and change into it -$DownloadFileName = "latest-win.exe" -Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName -$file = Get-ChildItem -Path $DownloadFileName -$versionInfo = $file.VersionInfo.ProductVersion +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersion" -if ($null -eq $versionInfo) { - Write-Host "Could not find version info in file" - exit 1 -} Write-Host "Found latest version: $versionInfo" $latestversion = $versionInfo @@ -38,53 +21,4 @@ if ($fullDownloadURLResponse.StatusCode -ne 200) { exit 1 } -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "Version already in winget" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Output "Downloading wingetcreate and open PR for $wingetPackage Version $latestVersion" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $latestVersion, $fullDownloadURL diff --git a/Scripts/Update-MongoDB.Compass.Full.ps1 b/Scripts/Update-MongoDB.Compass.Full.ps1 new file mode 100644 index 0000000..81e15a6 --- /dev/null +++ b/Scripts/Update-MongoDB.Compass.Full.ps1 @@ -0,0 +1,17 @@ +. .\Scripts\common.ps1 + +$PackageFilter = "mongodb-compass" + +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL + +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url + +# Bring $latestVersion in correct format x.x.x.x +# Check if $latestVersion is in the x.x.x format +if ($latestVersion -match '^\d+\.\d+\.\d+$') { + # Append .0 to $latestVersion + $latestVersion = "$latestVersion.0" +} + +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Update-MongoDB.Compass.Isolated.ps1 b/Scripts/Update-MongoDB.Compass.Isolated.ps1 new file mode 100644 index 0000000..bffe2b1 --- /dev/null +++ b/Scripts/Update-MongoDB.Compass.Isolated.ps1 @@ -0,0 +1,17 @@ +. .\Scripts\common.ps1 + +$PackageFilter = "mongodb-compass-isolated" + +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL + +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url + +# Bring $latestVersion in correct format x.x.x.x +# Check if $latestVersion is in the x.x.x format +if ($latestVersion -match '^\d+\.\d+\.\d+$') { + # Append .0 to $latestVersion + $latestVersion = "$latestVersion.0" +} + +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Update-MongoDB.Compass.Readonly.ps1 b/Scripts/Update-MongoDB.Compass.Readonly.ps1 new file mode 100644 index 0000000..2d124f6 --- /dev/null +++ b/Scripts/Update-MongoDB.Compass.Readonly.ps1 @@ -0,0 +1,17 @@ +. .\Scripts\common.ps1 + +$PackageFilter = "mongodb-compass-readonly" + +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL + +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url + +# Bring $latestVersion in correct format x.x.x.x +# Check if $latestVersion is in the x.x.x format +if ($latestVersion -match '^\d+\.\d+\.\d+$') { + # Append .0 to $latestVersion + $latestVersion = "$latestVersion.0" +} + +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Update-MongoDB.Compass.ps1 b/Scripts/Update-MongoDB.Compass.ps1 deleted file mode 100644 index 5182799..0000000 --- a/Scripts/Update-MongoDB.Compass.ps1 +++ /dev/null @@ -1,110 +0,0 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -#$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} - -$PackageMapping = @{ - "MongoDB.Compass.Full" = "mongodb-compass" - "MongoDB.Compass.Isolated" = "mongodb-compass-isolated" - "MongoDB.Compass.Readonly" = "mongodb-compass-readonly" -} - -Write-Host "Try to update MongoDB Tools" - -# Download the webpage -$website = Invoke-WebRequest -Uri $url - -# Extract the content of the webpage -$content = $website.Content - -# Find all strings that look like links and end with .msi -$links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } -$msilinks = $links | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } - -foreach ($wingetPackage in $PackageMapping.Keys){ -$PackageFilter = $PackageMapping[$wingetPackage] -$Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }| Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } -# Extract versions from the links -$versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } - -# Exclude release candidates -$stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } - -# Sort the versions and get the latest one -$latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 -$latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } -Write-Host "Version found: $PackageFilter $latestVersion. URL: $latestVersionUrl" - -# Bring $latestVersion in correct format x.x.x.x -# Check if $latestVersion is in the x.x.x format -if ($latestVersion -match '^\d+\.\d+\.\d+$') { - # Append .0 to $latestVersion - $latestVersion = "$latestVersion.0" -} - -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} -} diff --git a/Scripts/Update-MongoDB.DatabaseTools.ps1 b/Scripts/Update-MongoDB.DatabaseTools.ps1 index c29170e..3b1b14b 100644 --- a/Scripts/Update-MongoDB.DatabaseTools.ps1 +++ b/Scripts/Update-MongoDB.DatabaseTools.ps1 @@ -1,106 +1,10 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} +$PackageFilter = "mongodb-database-tools" -# Placeholder for the release notes URL -$releaseNotesUrl = "https://www.mongodb.com/docs/database-tools/release-notes/database-tools-changelog/#{version}-changelog" +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL -$PackageMapping = @{ - "MongoDB.DatabaseTools" = "mongodb-database-tools" -} +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url -Write-Host "Try to update MongoDB Tools" - -# Download the webpage -$website = Invoke-WebRequest -Uri $url - -# Extract the content of the webpage -$content = $website.Content - -# Find all strings that look like links and end with .msi -$links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } -$msilinks = $links | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } - -foreach ($wingetPackage in $PackageMapping.Keys){ -$PackageFilter = $PackageMapping[$wingetPackage] -$Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }| Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } -# Extract versions from the links -$versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } - -# Exclude release candidates -$stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } - -# Sort the versions and get the latest one -$latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 -$latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } -Write-Host "Version found: $PackageFilter $latestVersion. URL: $latestVersionUrl" - - -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" -$actualReleaseNotesUrl = $releaseNotesUrl -replace "{version}", $latestVersion - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} -} +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 b/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 index 4ac2f35..72fc014 100644 --- a/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 +++ b/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 @@ -1,98 +1,10 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} +. .\Scripts\common.ps1 $PackageFilter = "mongodb-atlas-cli" -Write-Host "Try to update $wingetPackage" - -# Download the webpage -$website = Invoke-WebRequest -Uri $url - -# Extract the content of the webpage -$content = $website.Content - -# Find all strings that look like links and end with .msi -$links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } -$msilinks = $links | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } - -$Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }| Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } -# Extract versions from the links -$versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } - -# Exclude release candidates -$stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } - -# Sort the versions and get the latest one -$latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 -$latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } -Write-Host "Version found: $PackageFilter $latestVersion. URL: $latestVersionUrl" - - -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl|x64" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url +return $latestVersion, "$latestVersionUrl|x64" \ No newline at end of file diff --git a/Scripts/Update-MongoDB.MongoDBCLI.ps1 b/Scripts/Update-MongoDB.MongoDBCLI.ps1 index 389d095..90e77c5 100644 --- a/Scripts/Update-MongoDB.MongoDBCLI.ps1 +++ b/Scripts/Update-MongoDB.MongoDBCLI.ps1 @@ -1,100 +1,10 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} +. .\Scripts\common.ps1 $PackageFilter = "mongocli" -Write-Host "Try to update $wingetPackage" - -# Download the webpage -$website = Invoke-WebRequest -Uri $url - -# Extract the content of the webpage -$content = $website.Content - -# Find all strings that look like links and end with .msi -$links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } -$msilinks = $links | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } - - - -$Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }| Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } -# Extract versions from the links -$versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } - -# Exclude release candidates -$stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } - -# Sort the versions and get the latest one -$latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 -$latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } -Write-Host "Version found: $PackageFilter $latestVersion. URL: $latestVersionUrl" - - -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl|x64" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url +return $latestVersion, "$latestVersionUrl|x64" diff --git a/Scripts/Update-MongoDB.Server.ps1 b/Scripts/Update-MongoDB.Server.ps1 index e7b1f91..6bdf9d7 100644 --- a/Scripts/Update-MongoDB.Server.ps1 +++ b/Scripts/Update-MongoDB.Server.ps1 @@ -1,19 +1,9 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} -Write-Host "Try to update $wingetPackage" # Download the webpage -$website = Invoke-WebRequest -Uri $url +$website = Invoke-WebRequest -Uri $WebsiteURL # Extract the content of the webpage $content = $website.Content @@ -21,6 +11,8 @@ $content = $website.Content # Find all strings that look like links and end with .msi $links = $content | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } + + # Extract versions from the links $versions = $links | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*)?)' | Out-Null; $matches[1] } @@ -31,62 +23,4 @@ $stableVersions = $versions | Where-Object { $_ -notmatch '-rc' } $latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 $latestVersionUrl = $links | Where-Object { $_ -match $latestVersion } - -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Update-MongoDB.Shell.ps1 b/Scripts/Update-MongoDB.Shell.ps1 index d9ef543..eaf7528 100644 --- a/Scripts/Update-MongoDB.Shell.ps1 +++ b/Scripts/Update-MongoDB.Shell.ps1 @@ -1,19 +1,9 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} -Write-Host "Try to update $wingetPackage" # Download the webpage -$website = Invoke-WebRequest -Uri $url +$website = Invoke-WebRequest -Uri $WebsiteURL # Extract the content of the webpage $content = $website.Content @@ -21,6 +11,8 @@ $content = $website.Content # Find all strings that look like links and end with .msi $links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } $Packagelinks = $links | Select-String -Pattern 'https?://[^\s]*mongosh[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } + + # Extract versions from the links $versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } @@ -31,62 +23,5 @@ $stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } $latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 $latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } +return $latestVersion, $latestVersionUrl -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} diff --git a/Scripts/Update-SmartProjects.IsoBuster.ps1 b/Scripts/Update-SmartProjects.IsoBuster.ps1 index 4971e52..e0af14b 100644 --- a/Scripts/Update-SmartProjects.IsoBuster.ps1 +++ b/Scripts/Update-SmartProjects.IsoBuster.ps1 @@ -1,87 +1,7 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$wingetPackage = ${Env:PackageName} -$url = ${Env:WebsiteURL} +$latestVersionUrl = $WebsiteURL -split " " | Select-Object -First 1 -# download latest version from loupedeck.com and get version by filename -$latestVersionUrl = $url -split " " | Select-Object -First 1 -#create directory downloads and change into it -$DownloadFileName = "IsoBuster_installer.exe" -Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName -$file = Get-ChildItem -Path $DownloadFileName -$versionInfo = $file.VersionInfo.ProductVersion.trim() +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $latestVersionUrl -VersionInfoProperty "ProductVersion" -if ($null -eq $versionInfo) { - Write-Host "Could not find version info in file" - exit 1 -} - -Write-Host "Found latest version: $versionInfo" - -$latestVersion = $versionInfo - - -#$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - - - - # Check for existing PRs - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Output "Downloading wingetcreate and open PR for $wingetPackage Version $latestVersion" -# Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe -# .\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken - Invoke-WebRequest "https://github.com/russellbanks/Komac/releases/download/v2.2.1/KomacPortable-x64.exe" -OutFile komac.exe - .\komac.exe update --identifier $wingetPackage --version $latestVersion --urls "https://www.isobuster.com/downloads/isobuster/isobuster_install_64bit.exe" "https://www.isobuster.com/downloads/isobuster/isobuster_install.exe" -s -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} +return $versionInfo, $WebsiteURL diff --git a/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 b/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 index de4bf53..728871f 100644 --- a/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 +++ b/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 @@ -1,83 +1,9 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} +. .\Scripts\common.ps1 -$wingetPackage = ${Env:PackageName} -$repo = ${Env:WebsiteURL} - -Write-Host "Try to update $wingetPackage" - -$latestVersionTag = gh release view --repo $repo --json tagName -q ".tagName" -$latestVersionName = gh release view --repo $repo --json name -q ".name" +$latestVersionTag = gh release view --repo $WebsiteURL --json tagName -q ".tagName" +$latestVersionName = gh release view --repo $WebsiteURL --json name -q ".name" $latestVersion = $latestVersionName -replace '.*?(\d+\.\d+\.\d+(.\d+)).*', '$1' -$assets = gh release view --repo $repo --json assets -q ".assets[] .url" +$assets = gh release view --repo $WebsiteURL --json assets -q ".assets[] .url" $msiAsset = $assets | Where-Object { $_ -like "*.msi" } - -#### Standard Part ### - -Write-Host "Version found: $latestVersion" - -$prMessage = "Update version: $wingetPackage version $latestVersion" - -$ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" -$ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" - - -# Check if package is already in winget -$ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck -if ($ghCheck.StatusCode -eq 404) { - Write-Output "Packet not yet in winget. Please add new Packet manually" - exit 1 -} - -$ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck - -#$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions - -if ($ghVersionCheck.StatusCode -eq 200) { - Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." - exit 0 -} -else { - # Check for existing PRs - Write-Host "Fetching existing PRs" - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - #gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json - - $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) - - # TODO Check if PR is already merged, if so exit - - # TODO if PR from us is already open, update PR with new version - - # TODO if PR is closed, not from us and no PR got merged, create new PR - - # TODO if PR is closed, from us and no PR got merged, throw error - - if ($ExistingPRs.Count -gt 0) { - Write-Output "$foundMessage" - $ExistingPRs | ForEach-Object { - Write-Output "Found existing PR: $($_.title)" - Write-Output "-> $($_.url)" - } - } - elseif ($ghCheck.StatusCode -eq 200) { - Write-Host "Open PR for update" - #Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - #.\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl|x64" --prtitle $prMessage -t $gitToken - Invoke-WebRequest "https://github.com/russellbanks/Komac/releases/download/v2.2.1/KomacPortable-x64.exe" -OutFile komac.exe - .\komac.exe update --identifier $wingetPackage --version $latestVersion --urls $msiAsset -s -t $gitToken - } - else { - Write-Output "$foundMessage" - Write-Output "No existing PRs found. Check why wingetcreate has not run." - } -} \ No newline at end of file +return $latestVersion, $msiAsset \ No newline at end of file diff --git a/Scripts/Update-Samsung.SamsungMagician.ps1 b/Scripts/_unused/Update-Samsung.SamsungMagician.ps1 similarity index 100% rename from Scripts/Update-Samsung.SamsungMagician.ps1 rename to Scripts/_unused/Update-Samsung.SamsungMagician.ps1 diff --git a/Scripts/common.ps1 b/Scripts/common.ps1 new file mode 100644 index 0000000..4568318 --- /dev/null +++ b/Scripts/common.ps1 @@ -0,0 +1,258 @@ +function Test-GitHubToken { + if ($Env:GITHUB_TOKEN) { + Write-Host 'GITHUB_TOKEN detected' + return ${Env:GITHUB_TOKEN} + } + else { + Write-Host 'GITHUB_TOKEN not detected' + exit 1 + } +} + + +function Test-PackageAndVersionInGithub { + param( + [Parameter(Mandatory = $true)] [string] $latestVersion, + [Parameter(Mandatory = $false)] [string] $wingetPackage = ${Env:PackageName} + ) + Write-Host "Checking if $wingetPackage is already in winget (via GH) and Version $($Latest.Version) already present" + $ghVersionURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$latestVersion/$wingetPackage.yaml" + $ghCheckURL = "https://github.com/microsoft/winget-pkgs/blob/master/manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/" + + $ghCheck = Invoke-WebRequest -Uri $ghCheckURL -Method Head -SkipHttpErrorCheck + $ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck + + if ($ghCheck.StatusCode -eq 404) { + Write-Host "Packet not yet in winget. Please add new Packet manually" + exit 1 + } + elseif ($ghVersionCheck.StatusCode -eq 200) { + Write-Host "Latest version of $wingetPackage $latestVersion is already present in winget." + exit 0 + } + else { + return $true + } + +} + +function Test-PackageAndVersionInWinget { + param( + [Parameter(Mandatory = $true)] [string] $latestVersion, + [Parameter(Mandatory = $false)] [string] $wingetPackage = ${Env:PackageName} + ) + Write-Host "Checking if $wingetPackage is already in winget and Version $($Latest.Version) already present" + + $progressPreference = 'silentlyContinue' + $latestWingetMsixBundleUri = $(Invoke-RestMethod https://api.github.com/repos/microsoft/winget-cli/releases/latest).assets.browser_download_url | Where-Object { $_.EndsWith(".msixbundle") } + $latestWingetMsixBundle = $latestWingetMsixBundleUri.Split("/")[-1] + Write-Host "Downloading winget to artifacts directory..." + Invoke-WebRequest -Uri $latestWingetMsixBundleUri -OutFile "./$latestWingetMsixBundle" + Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx + Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx + Add-AppxPackage $latestWingetMsixBundle + + start-sleep 20 + + $foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions + + if (!$wingetVersions) { + Write-Host "Packet not yet in winget. Please add new Packet manually" + exit 1 + } + elseif ($wingetVersions.contains($latestVersion)) { + Write-Host "Latest version of $wingetPackage $latestVersion is already present in winget." + exit 0 + } + else { + return $true + } +} + +function Test-ExistingPRs { + param( + [Parameter(Mandatory = $true)] [string] $latestVersion, + [Parameter(Mandatory = $false)] [string] $wingetPackage = ${Env:PackageName} + ) + Write-Host "Checking for exisitng PRs for $wingetPackage $($Latest.Version)" + $ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json + $ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json + $ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs) + + if ($ExistingPRs.Count -gt 0) { + $ExistingPRs | ForEach-Object { + Write-Host "Found existing PR: $($_.title)" + Write-Host "-> $($_.url)" + } + exit 0 + } + else { + + return $true + } +} + +function Get-VersionAndUrl { + param( + [Parameter(Mandatory = $false)] [string] $wingetPackage = ${Env:PackageName}, + [Parameter(Mandatory = $false)] [string] $WebsiteURL = ${Env:WebsiteURL} + ) + + $scriptPath = ".\Scripts\Update-$($wingetPackage).ps1" + + if (-not (Test-Path -Path $scriptPath)) { + Write-Host "The script '$scriptPath' does not exist. Please check the wingetPackage parameter and the current directory." + exit 1 + } + + $Latest = & $scriptPath -WebsiteURL $WebsiteURL -wingetPackage $wingetPackage + + + if (!($Latest | Get-Member -Name "Version") -or !($Latest | Get-Member -Name "URLs")) { + + $lines = $Latest -split "`n" -split " " + + $versionPattern = '^\d+(\.\d+)*$' + $urlPattern = '^http[s]?:\/\/[^\s]+$' + + $version = $lines | Where-Object { $_ -match $versionPattern } + $URLs = $lines | Where-Object { $_ -match $urlPattern } + + if ($version -and $URLs) { + $Latest = @{ + Version = $version + URLs = $URLs + } + } + else { + Write-Host "No Version ($version) or URL ($($URLs -join ',')) found." + exit 1 + } + } + + Write-Host "Found latest version: $version with URLs: $($Latest.URLs -join ',')" + return $Latest +} +function Get-ProductVersionFromFile { + param( + [Parameter(Mandatory = $true)] [string] $WebsiteURL, + [Parameter(Mandatory = $true)] [string] $VersionInfoProperty + ) + + $latestVersionUrl = $WebsiteURL + $DownloadFileName = [System.IO.Path]::GetFileName($latestVersionUrl) + Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName + + # If the file is a ZIP file, unzip it and search for .exe or .msi files + if ($DownloadFileName -like "*.zip") { + $UnzipPath = "." + Expand-Archive -Path $DownloadFileName -DestinationPath $UnzipPath + $file = Get-ChildItem -Path $UnzipPath -Include "*.exe","*.msi" -Recurse | Select-Object -First 1 + } else { + $file = Get-ChildItem -Path $DownloadFileName + } + + if ($null -eq $file) { + Write-Host "File not found" + exit 1 + } + + if ($null -eq $file.VersionInfo) { + Write-Host "No version info found in file" + exit 1 + } + + $versionInfo = $file.VersionInfo.$VersionInfoProperty + $versionInfo = $versionInfo.ToString().Trim() + + if ($null -eq $versionInfo) { + Write-Host "Could not find version info in file" + exit 1 + } + + return $versionInfo +} + +function Update-WingetPackage { + param( + [Parameter(Mandatory = $true)] [string] $WebsiteURL, + [Parameter(Mandatory = $false)] [string] $wingetPackage = ${Env:PackageName}, + [Parameter(Mandatory = $false)][AllowEmptyString()] [ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac" + ) + $gitToken = Test-GitHubToken + + $Latest = Get-VersionAndUrl -wingetPackage $wingetPackage -WebsiteURL $WebsiteURL + + if ($null -eq $Latest) { + Write-Host "No version info found" + exit 1 + } + Write-Host $Latest + Write-Host $($Latest.Version) + Write-Host $($Latest.URLs) + + $prMessage = "Update version: $wingetPackage version $($Latest.Version)" + + $PackageAndVersionInWinget = Test-PackageAndVersionInGithub -wingetPackage $wingetPackage -latestVersion $($Latest.Version) + + + if ($PackageAndVersionInWinget) { + + $ExistingPRs = Test-ExistingPRs -wingetPackage $wingetPackage -latestVersion $($Latest.Version) + + if ($ExistingPRs) { + Write-Host "Downloading $with and open PR for $wingetPackage Version $($Latest.Version)" + Switch ($with) { + "Komac" { + Invoke-WebRequest "https://github.com/russellbanks/Komac/releases/download/v2.2.1/KomacPortable-x64.exe" -OutFile komac.exe + .\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" -s -t $gitToken + } + "WinGetCreate" { + Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe + .\wingetcreate.exe update $wingetPackage -s -v $Latest.Version -u "$($Latest.URLs.replace(' ','" "'))" --prtitle $prMessage -t $gitToken + } + } + } + } +} + +function Get-LatestMongoDBVersions { + param( + [Parameter(Mandatory = $true)] [string] $WebsiteURL, + [Parameter(Mandatory = $true)] [string] $PackageFilter + ) + + $website = Invoke-WebRequest -Uri $WebsiteURL + $content = $website.Content + + $links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } + $msilinks = $links | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } + + $Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }| Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } + + $versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } + $stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } + + $latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 + $latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } + + return @{ + Version = $latestVersion + Url = $latestVersionUrl + } +} + + + +# function Start-Update { +# $wingetPackage = ${Env:PackageName} +# $url = ${Env:WebsiteURL} +# $Latest = Get-VersionAndUrl -wingetPackage $wingetPackage -WebsiteURL $url + +# Update-WingetPackage -wingetPackage $wingetPackage -latestVersion $Latest.Version -with Komac -latestVersionUrls $Latest.URLs +# } + + + +$wingetPackage = ${Env:PackageName} +$WebsiteURL = ${Env:WebsiteURL} diff --git a/Scripts/generic.ps1 b/Scripts/generic.ps1 new file mode 100644 index 0000000..d3724fc --- /dev/null +++ b/Scripts/generic.ps1 @@ -0,0 +1,12 @@ +. .\Scripts\common.ps1 + +#### Main + +if (${Env:With}) { + Update-WingetPackage -wingetPackage ${Env:PackageName} -With ${Env:With} -WebsiteURL ${Env:WebsiteURL} +} +else { + Update-WingetPackage -wingetPackage ${Env:PackageName} -WebsiteURL ${Env:WebsiteURL} +} + + From 85454756b9df0afe4ebe5d6ae03d8eda33242824 Mon Sep 17 00:00:00 2001 From: Utesgui Date: Sat, 11 May 2024 18:33:26 +0000 Subject: [PATCH 05/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 082990d..81d7382 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,5 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| -| Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-14-green) | +| Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-16-green) | | GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-4-blue) | From a62ccc16f23967a3d87bc9826692018b2210d619 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 19:20:45 +0000 Subject: [PATCH 06/37] always use latest komac; minor refactoring --- Scripts/common.ps1 | 13 +++++++------ Scripts/generic.ps1 | 11 ++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Scripts/common.ps1 b/Scripts/common.ps1 index 4568318..ce62241 100644 --- a/Scripts/common.ps1 +++ b/Scripts/common.ps1 @@ -23,7 +23,7 @@ function Test-PackageAndVersionInGithub { $ghVersionCheck = Invoke-WebRequest -Uri $ghVersionURL -Method Head -SkipHttpErrorCheck if ($ghCheck.StatusCode -eq 404) { - Write-Host "Packet not yet in winget. Please add new Packet manually" + Write-Host "Package not yet in winget. Please add new package manually" exit 1 } elseif ($ghVersionCheck.StatusCode -eq 200) { @@ -57,7 +57,7 @@ function Test-PackageAndVersionInWinget { $foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions if (!$wingetVersions) { - Write-Host "Packet not yet in winget. Please add new Packet manually" + Write-Host "Package not yet in winget. Please add new package manually" exit 1 } elseif ($wingetVersions.contains($latestVersion)) { @@ -176,8 +176,8 @@ function Get-ProductVersionFromFile { function Update-WingetPackage { param( [Parameter(Mandatory = $true)] [string] $WebsiteURL, - [Parameter(Mandatory = $false)] [string] $wingetPackage = ${Env:PackageName}, - [Parameter(Mandatory = $false)][AllowEmptyString()] [ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac" + [Parameter(Mandatory = $false)] [string] $WingetPackage = ${Env:PackageName}, + [Parameter(Mandatory = $false)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac" ) $gitToken = Test-GitHubToken @@ -204,7 +204,8 @@ function Update-WingetPackage { Write-Host "Downloading $with and open PR for $wingetPackage Version $($Latest.Version)" Switch ($with) { "Komac" { - Invoke-WebRequest "https://github.com/russellbanks/Komac/releases/download/v2.2.1/KomacPortable-x64.exe" -OutFile komac.exe + $latestKomacRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/russellbanks/Komac/releases/latest").assets | ? {$_.browser_download_url.EndsWith("KomacSetup-x64.exe")} | Select-Object -First 1 -ExpandProperty browser_download_url + Invoke-WebRequest -Uri $latestKomacRelease -OutFile komac.exe .\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" -s -t $gitToken } "WinGetCreate" { @@ -249,7 +250,7 @@ function Get-LatestMongoDBVersions { # $url = ${Env:WebsiteURL} # $Latest = Get-VersionAndUrl -wingetPackage $wingetPackage -WebsiteURL $url -# Update-WingetPackage -wingetPackage $wingetPackage -latestVersion $Latest.Version -with Komac -latestVersionUrls $Latest.URLs +# Update-WingetPackage -WingetPackage $wingetPackage -latestVersion $Latest.Version -with Komac -latestVersionUrls $Latest.URLs # } diff --git a/Scripts/generic.ps1 b/Scripts/generic.ps1 index d3724fc..d876da8 100644 --- a/Scripts/generic.ps1 +++ b/Scripts/generic.ps1 @@ -1,12 +1,13 @@ . .\Scripts\common.ps1 #### Main - -if (${Env:With}) { - Update-WingetPackage -wingetPackage ${Env:PackageName} -With ${Env:With} -WebsiteURL ${Env:WebsiteURL} +$params = @{ + wingetPackage = ${Env:PackageName} + WebsiteURL = ${Env:WebsiteURL} } -else { - Update-WingetPackage -wingetPackage ${Env:PackageName} -WebsiteURL ${Env:WebsiteURL} +if($Env:With) { + $params.Add("With", $Env:With) } +Update-WingetPackage @params From 909466cefaf83ce16f0c2258ec02baeaf4bd5bce Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 21:21:55 +0200 Subject: [PATCH 07/37] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81d7382..dd6c83a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # winget-pgks-updatepipelines -**winget-pkgs** Pull requests by [damn-good-b0t](https://github.com/microsoft/winget-pkgs/pulls/damn-good-b0t) +[**winget-pkgs**](https://github.com/microsoft/winget-pkgs.git) Pull requests by [damn-good-b0t](https://github.com/microsoft/winget-pkgs/pulls/damn-good-b0t) | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| From 5ff89c065324359723a2826b631b408d71e1b471 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 23:18:18 +0200 Subject: [PATCH 08/37] add betaflight --- .github/workflows/GithubReleases.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 50a9cd4..abf8046 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -29,6 +29,9 @@ jobs: - id: "EdgeTX.Companion" repo: "EdgeTX/edgetx" url: "https://github.com/EdgeTX/edgetx/releases/download/{VERSION}/edgetx-cpn-win64-{VERSION}.zip" + - id: "Betaflight.Betaflight-Configurator" + repo: "betaflight/betaflight-configurator" + url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" steps: - name: Update Packages From a11e0fa760f8ab8071db26f543cceb2bcb5a1edf Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sat, 11 May 2024 21:18:30 +0000 Subject: [PATCH 09/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd6c83a..25de5b4 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-16-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-4-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-5-blue) | From 9bd729e2f2f03d6257a7d463b446c60f790fd71f Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 23:37:43 +0200 Subject: [PATCH 10/37] add AdguardTeam/dnsproxy --- .github/workflows/GithubReleases.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index abf8046..ec5e79a 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -32,6 +32,9 @@ jobs: - id: "Betaflight.Betaflight-Configurator" repo: "betaflight/betaflight-configurator" url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" + - id: "AdGuard.dnsproxy" + repo: "AdguardTeam/dnsproxy" + url: " https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip, https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip, https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip" steps: - name: Update Packages From 18c0b1263487fa0b54331e1ce1c3dfc4129a9255 Mon Sep 17 00:00:00 2001 From: Alexander Mnich Date: Sun, 12 May 2024 00:08:34 +0200 Subject: [PATCH 11/37] add AdguardTeam/dnsproxy --- .github/workflows/GithubReleases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index ec5e79a..52935ac 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -34,7 +34,7 @@ jobs: url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" - id: "AdGuard.dnsproxy" repo: "AdguardTeam/dnsproxy" - url: " https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip, https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip, https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip" + url: "\"https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip\"" steps: - name: Update Packages From 37bcf8e4ba853beef8d27a96569286b2d50bfdb2 Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sat, 11 May 2024 22:10:41 +0000 Subject: [PATCH 12/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25de5b4..f27a7bc 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-16-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-5-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-6-blue) | From 8449ca1869d43d8b0620b7757f81e3dd9ebd3b5d Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sat, 11 May 2024 22:15:58 +0000 Subject: [PATCH 13/37] add h3poteto.fedistar --- .github/workflows/GithubReleases.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 52935ac..e23340c 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -32,6 +32,9 @@ jobs: - id: "Betaflight.Betaflight-Configurator" repo: "betaflight/betaflight-configurator" url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" + - id: "h3poteto.fedistar" + repo: "h3poteto/fedistar" + url: "https://github.com/h3poteto/fedistar/releases/download/v{VERSION}/fedistar_{VERSION}_x64_en-US.msi" - id: "AdGuard.dnsproxy" repo: "AdguardTeam/dnsproxy" url: "\"https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip\"" From 23ea3aedf2139c6cd4a2f100b51b3fcb29a5fda9 Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sat, 11 May 2024 22:16:15 +0000 Subject: [PATCH 14/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f27a7bc..066f0e4 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-16-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-6-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-7-blue) | From e5998a835cb2db2d7cd43a2dc39797f98f03c18e Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 01:31:28 +0200 Subject: [PATCH 15/37] add Fork.fork and additional logging (#10) * add Fork.Fork * add logging to common script * add github version check logging * fix komac download --- .github/workflows/update-via-script.yml | 2 ++ Scripts/Update-Fork.Fork.ps1 | 23 ++++++++++++++++ Scripts/common.ps1 | 35 +++++++++++++++++++------ 3 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 Scripts/Update-Fork.Fork.ps1 diff --git a/.github/workflows/update-via-script.yml b/.github/workflows/update-via-script.yml index ff9839d..038a138 100644 --- a/.github/workflows/update-via-script.yml +++ b/.github/workflows/update-via-script.yml @@ -60,6 +60,8 @@ jobs: With: WinGetCreate - PackageName: "SmartProjects.IsoBuster" WebsiteURL: "https://www.isobuster.com/downloads/isobuster/isobuster_install_64bit.exe https://www.isobuster.com/downloads/isobuster/isobuster_install.exe" + - PackageName: "Fork.Fork" + WebsiteURL: "https://fork.dev" steps: - name: Checkout diff --git a/Scripts/Update-Fork.Fork.ps1 b/Scripts/Update-Fork.Fork.ps1 new file mode 100644 index 0000000..db8d119 --- /dev/null +++ b/Scripts/Update-Fork.Fork.ps1 @@ -0,0 +1,23 @@ +. .\Scripts\common.ps1 + + +# Currently not all versions have .exe installers +#Text response with entries of form " Fork--.nupkg " +# Invoke-WebRequest -Uri "https://git-fork.com/update/win/RELEASES?id=Fork" -OutFile "RELEASES" +# $releases = Get-Content "RELEASES" +# $versionNumbers = $releases | ForEach-Object { +# if ($_ -match 'Fork-(.*?)-') { +# $Matches[1] +# } +# } +# $versionNumbers = $versionNumbers | Sort-Object -Descending | Select-Object -Unique + +# $latestVersion = $versionNumbers[0] +# $latestVersionUrl = "https://cdn.fork.dev/win/Fork-$latestVersion.exe" + +$websiteContent = Invoke-WebRequest -Uri $WebsiteURL +$latestVersionUrl = $websiteContent.Links | Where-Object {$_.tagName -eq "A" -and $_.outerHTML.Contains('"downloadBtn2Win"')} | Select-Object -First 1 -ExpandProperty href +# extract version from link +$latestVersion = [regex]::Match($latestVersionUrl, '.*Fork-(.*).exe').Groups[1].Value + +return $latestVersion, "$latestVersionUrl" diff --git a/Scripts/common.ps1 b/Scripts/common.ps1 index ce62241..4412467 100644 --- a/Scripts/common.ps1 +++ b/Scripts/common.ps1 @@ -31,6 +31,7 @@ function Test-PackageAndVersionInGithub { exit 0 } else { + Write-Host "Package $wingetPackage is in winget, but version $latestVersion is not present." return $true } @@ -147,8 +148,9 @@ function Get-ProductVersionFromFile { if ($DownloadFileName -like "*.zip") { $UnzipPath = "." Expand-Archive -Path $DownloadFileName -DestinationPath $UnzipPath - $file = Get-ChildItem -Path $UnzipPath -Include "*.exe","*.msi" -Recurse | Select-Object -First 1 - } else { + $file = Get-ChildItem -Path $UnzipPath -Include "*.exe", "*.msi" -Recurse | Select-Object -First 1 + } + else { $file = Get-ChildItem -Path $DownloadFileName } @@ -201,17 +203,34 @@ function Update-WingetPackage { $ExistingPRs = Test-ExistingPRs -wingetPackage $wingetPackage -latestVersion $($Latest.Version) if ($ExistingPRs) { - Write-Host "Downloading $with and open PR for $wingetPackage Version $($Latest.Version)" - Switch ($with) { + Write-Host "Downloading $With and open PR for $wingetPackage Version $($Latest.Version)" + Switch ($With) { "Komac" { - $latestKomacRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/russellbanks/Komac/releases/latest").assets | ? {$_.browser_download_url.EndsWith("KomacSetup-x64.exe")} | Select-Object -First 1 -ExpandProperty browser_download_url + $latestKomacRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/russellbanks/Komac/releases/latest").assets | Where-Object { $_.browser_download_url.EndsWith("KomacPortable-x64.exe") } | Select-Object -First 1 -ExpandProperty browser_download_url Invoke-WebRequest -Uri $latestKomacRelease -OutFile komac.exe + if (Test-Path ".\komac.exe") { + Write-Host "Komac successfully downloaded" + } + else { + Write-Error "Komac not downloaded" + exit 1 + } .\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" -s -t $gitToken } "WinGetCreate" { Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe + if (Test-Path ".\wingetcreate.exe") { + Write-Host "wingetcreate successfully downloaded" + } + else { + Write-Error "wingetcreate not downloaded" + exit 1 + } .\wingetcreate.exe update $wingetPackage -s -v $Latest.Version -u "$($Latest.URLs.replace(' ','" "'))" --prtitle $prMessage -t $gitToken } + default { + Write-Error "Invalid value \"$With\" for -With parameter. Valid values are 'Komac' and 'WinGetCreate'" + } } } } @@ -229,17 +248,17 @@ function Get-LatestMongoDBVersions { $links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value } $msilinks = $links | Select-String -Pattern 'https?://[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } - $Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }| Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } + $Packagelinks = $msilinks | Select-String -Pattern "https?://[^\s]*$PackageFilter[^\s]*\.msi" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } | Where-Object { $_ -notmatch "$PackageFilter-isolated|$PackageFilter-readonly" } $versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] } $stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' } - $latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 + $latestVersion = $stableVersions | Sort-Object { [Version]$_ } | Select-Object -Last 1 $latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion } return @{ Version = $latestVersion - Url = $latestVersionUrl + Url = $latestVersionUrl } } From 24ca2cbf148cfadb5b79bf06008146cbf41a4d3c Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sat, 11 May 2024 23:31:43 +0000 Subject: [PATCH 16/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 066f0e4..1cca1cf 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,5 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| -| Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-16-green) | +| Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | | GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-7-blue) | From bce31dcab18396c8e802e9b81f17a294bac50f63 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 02:12:01 +0200 Subject: [PATCH 17/37] add hoppscotch.hoppscotch --- .github/workflows/GithubReleases.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index e23340c..aeb0e6c 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -34,7 +34,10 @@ jobs: url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" - id: "h3poteto.fedistar" repo: "h3poteto/fedistar" - url: "https://github.com/h3poteto/fedistar/releases/download/v{VERSION}/fedistar_{VERSION}_x64_en-US.msi" + url: "https://github.com/h3poteto/fedistar/releases/download/v{VERSION}/fedistar_{VERSION}_x64_en-US.msi" + - id: "hoppscotch.Hoppscotch" + repo: "hoppscotch/releases" + url: "https://github.com/hoppscotch/releases/releases/download/v{VERSION}/Hoppscotch_win_x64.msi" - id: "AdGuard.dnsproxy" repo: "AdguardTeam/dnsproxy" url: "\"https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip\"" From cfc14e0a957e7709f8cc5e00b8429c3babc7ff51 Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sun, 12 May 2024 00:12:19 +0000 Subject: [PATCH 18/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cca1cf..0714f58 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-7-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-8-blue) | From 4857d8699dec0aa14385f4d6076d4c68eb99cac7 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 09:24:44 +0000 Subject: [PATCH 19/37] switch to latest komac in GH releases --- .github/workflows/GithubReleases.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index aeb0e6c..7117cd9 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -34,9 +34,9 @@ jobs: url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" - id: "h3poteto.fedistar" repo: "h3poteto/fedistar" - url: "https://github.com/h3poteto/fedistar/releases/download/v{VERSION}/fedistar_{VERSION}_x64_en-US.msi" - - id: "hoppscotch.Hoppscotch" - repo: "hoppscotch/releases" + url: "https://github.com/h3poteto/fedistar/releases/download/v{VERSION}/fedistar_{VERSION}_x64_en-US.msi" + - id: "hoppscotch.Hoppscotch" + repo: "hoppscotch/releases" url: "https://github.com/hoppscotch/releases/releases/download/v{VERSION}/Hoppscotch_win_x64.msi" - id: "AdGuard.dnsproxy" repo: "AdguardTeam/dnsproxy" @@ -50,4 +50,5 @@ jobs: repo: ${{ matrix.repo }} url: ${{ matrix.url }} komac-token: ${{ secrets.WINGET_PAT }} + komac-version: latest custom-fork-owner: damn-good-b0t From 0b9bcfb463231ebed0bdcf18b4d42dde26d8c5aa Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 09:26:21 +0000 Subject: [PATCH 20/37] switch to b0t winget-updater --- .github/workflows/GithubReleases.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 7117cd9..d89bac2 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -40,11 +40,11 @@ jobs: url: "https://github.com/hoppscotch/releases/releases/download/v{VERSION}/Hoppscotch_win_x64.msi" - id: "AdGuard.dnsproxy" repo: "AdguardTeam/dnsproxy" - url: "\"https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip\"" + url: "https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip" steps: - name: Update Packages - uses: michidk/winget-updater@v1 + uses: b0t-at/winget-updater@b0t-main with: identifier: ${{ matrix.id }} repo: ${{ matrix.repo }} From f12f034a513dab93c33b7cf68486646e49566566 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 11:51:26 +0000 Subject: [PATCH 21/37] support submit environment variable --- .github/workflows/GithubReleases.yml | 2 ++ .github/workflows/update-via-script.yml | 2 ++ Scripts/common.ps1 | 7 ++++--- Scripts/generic.ps1 | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index d89bac2..141a0e5 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -9,6 +9,7 @@ jobs: update-releasebased: name: ${{ matrix.id }} runs-on: ubuntu-latest + environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Test' }} strategy: fail-fast: false @@ -52,3 +53,4 @@ jobs: komac-token: ${{ secrets.WINGET_PAT }} komac-version: latest custom-fork-owner: damn-good-b0t + submit: ${{ env.SUBMIT_PR }} diff --git a/.github/workflows/update-via-script.yml b/.github/workflows/update-via-script.yml index 038a138..e9ddf53 100644 --- a/.github/workflows/update-via-script.yml +++ b/.github/workflows/update-via-script.yml @@ -9,6 +9,7 @@ jobs: update-scriptbased: name: ${{ matrix.PackageName }} runs-on: windows-latest + environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Test' }} strategy: fail-fast: false @@ -78,6 +79,7 @@ jobs: WebsiteURL: ${{ matrix.WebsiteURL }} PackageName: ${{ matrix.PackageName }} With: ${{ matrix.With }} + Submit: ${{ env.SUBMIT_PR }} run: .\Scripts\generic.ps1 diff --git a/Scripts/common.ps1 b/Scripts/common.ps1 index 4412467..0c3ec61 100644 --- a/Scripts/common.ps1 +++ b/Scripts/common.ps1 @@ -179,7 +179,8 @@ function Update-WingetPackage { param( [Parameter(Mandatory = $true)] [string] $WebsiteURL, [Parameter(Mandatory = $false)] [string] $WingetPackage = ${Env:PackageName}, - [Parameter(Mandatory = $false)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac" + [Parameter(Mandatory = $false)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac", + [Parameter(Mandatory = $false)] [switch] $Submit = $false ) $gitToken = Test-GitHubToken @@ -215,7 +216,7 @@ function Update-WingetPackage { Write-Error "Komac not downloaded" exit 1 } - .\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" -s -t $gitToken + .\komac.exe update --identifier $wingetPackage --version $Latest.Version --urls "$($Latest.URLs.replace(' ','" "'))" ($Submit -eq $true ? "-s" : "") -t $gitToken } "WinGetCreate" { Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe @@ -226,7 +227,7 @@ function Update-WingetPackage { Write-Error "wingetcreate not downloaded" exit 1 } - .\wingetcreate.exe update $wingetPackage -s -v $Latest.Version -u "$($Latest.URLs.replace(' ','" "'))" --prtitle $prMessage -t $gitToken + .\wingetcreate.exe update $wingetPackage ($Submit -eq $true ? "-s" : "") -v $Latest.Version -u "$($Latest.URLs.replace(' ','" "'))" --prtitle $prMessage -t $gitToken } default { Write-Error "Invalid value \"$With\" for -With parameter. Valid values are 'Komac' and 'WinGetCreate'" diff --git a/Scripts/generic.ps1 b/Scripts/generic.ps1 index d876da8..bb3ae2e 100644 --- a/Scripts/generic.ps1 +++ b/Scripts/generic.ps1 @@ -8,6 +8,9 @@ $params = @{ if($Env:With) { $params.Add("With", $Env:With) } +if($Env:Submit) { + $params.Add("Submit", $true) +} Update-WingetPackage @params From 2ed96a6f449d7ca3695ece05e817b3940a66a10f Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 11:55:05 +0000 Subject: [PATCH 22/37] fix submit var context --- .github/workflows/GithubReleases.yml | 2 +- .github/workflows/update-via-script.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 141a0e5..fdab943 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -53,4 +53,4 @@ jobs: komac-token: ${{ secrets.WINGET_PAT }} komac-version: latest custom-fork-owner: damn-good-b0t - submit: ${{ env.SUBMIT_PR }} + submit: ${{ vars.SUBMIT_PR }} diff --git a/.github/workflows/update-via-script.yml b/.github/workflows/update-via-script.yml index e9ddf53..3815f16 100644 --- a/.github/workflows/update-via-script.yml +++ b/.github/workflows/update-via-script.yml @@ -79,7 +79,7 @@ jobs: WebsiteURL: ${{ matrix.WebsiteURL }} PackageName: ${{ matrix.PackageName }} With: ${{ matrix.With }} - Submit: ${{ env.SUBMIT_PR }} + Submit: ${{ vars.SUBMIT_PR }} run: .\Scripts\generic.ps1 From ce5cc6dff8f6eb096f73e40f5ffaf9945964ffa5 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 11:59:52 +0000 Subject: [PATCH 23/37] fix edgetx.edgetx --- .github/workflows/GithubReleases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index fdab943..7bd5839 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -29,7 +29,7 @@ jobs: url: "https://github.com/ankitects/anki/releases/download/{VERSION}/anki-{VERSION}-windows-qt6.exe" - id: "EdgeTX.Companion" repo: "EdgeTX/edgetx" - url: "https://github.com/EdgeTX/edgetx/releases/download/{VERSION}/edgetx-cpn-win64-{VERSION}.zip" + url: "https://github.com/EdgeTX/edgetx/releases/download/v{VERSION}/edgetx-cpn-win64-v{VERSION}.zip" - id: "Betaflight.Betaflight-Configurator" repo: "betaflight/betaflight-configurator" url: "https://github.com/betaflight/betaflight-configurator/releases/download/{VERSION}/betaflight-configurator_{VERSION}_win64-installer.exe" From 6869f1dad179c6268697195250acd36908532f9f Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 21:03:16 +0200 Subject: [PATCH 24/37] add OpenTofu.Tofu --- .github/workflows/GithubReleases.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 7bd5839..fb74e45 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -42,7 +42,9 @@ jobs: - id: "AdGuard.dnsproxy" repo: "AdguardTeam/dnsproxy" url: "https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip" - + - id: "OpenTofu.Tofu" + repo: "opentofu/opentofu" + url: "https://github.com/opentofu/opentofu/releases/download/v{VERSION}/tofu_{VERSION}_windows_386.zip https://github.com/opentofu/opentofu/releases/download/v{VERSION}/tofu_{VERSION}_windows_amd64.zip" steps: - name: Update Packages uses: b0t-at/winget-updater@b0t-main From 4fa864e2262952e95e88695fb6580a40b32f6d84 Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sun, 12 May 2024 19:03:27 +0000 Subject: [PATCH 25/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0714f58..227e7c2 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-8-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-9-blue) | From 80516bb4cc30828c4e49d9c8888d2dde6166d27b Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 21:10:06 +0200 Subject: [PATCH 26/37] add mitmproxy.mitmproxy --- .github/workflows/GithubReleases.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index fb74e45..1fa7f58 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -44,7 +44,10 @@ jobs: url: "https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-386-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-amd64-v{VERSION}.zip https://github.com/AdguardTeam/dnsproxy/releases/download/v{VERSION}/dnsproxy-windows-arm64-v{VERSION}.zip" - id: "OpenTofu.Tofu" repo: "opentofu/opentofu" - url: "https://github.com/opentofu/opentofu/releases/download/v{VERSION}/tofu_{VERSION}_windows_386.zip https://github.com/opentofu/opentofu/releases/download/v{VERSION}/tofu_{VERSION}_windows_amd64.zip" + url: "https://github.com/opentofu/opentofu/releases/download/v{VERSION}/tofu_{VERSION}_windows_386.zip https://github.com/opentofu/opentofu/releases/download/v{VERSION}/tofu_{VERSION}_windows_amd64.zip" + - id: "mitmproxy.mitmproxy" + repo: "mitmproxy/mitmproxy" + url: "https://downloads.mitmproxy.org/{VERSION}/mitmproxy-{VERSION}-windows-x86_64-installer.exe" steps: - name: Update Packages uses: b0t-at/winget-updater@b0t-main From 887dc01712703ce42c9ec4c02272d33b5c6d4804 Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sun, 12 May 2024 19:10:17 +0000 Subject: [PATCH 27/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 227e7c2..84118b5 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-9-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-10-blue) | From 1bc61d0adf19c937aab6e7ac32d5ff038ec2e437 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 21:14:35 +0200 Subject: [PATCH 28/37] add commercialhaskell.stack --- .github/workflows/GithubReleases.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 1fa7f58..d5b6960 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -48,6 +48,9 @@ jobs: - id: "mitmproxy.mitmproxy" repo: "mitmproxy/mitmproxy" url: "https://downloads.mitmproxy.org/{VERSION}/mitmproxy-{VERSION}-windows-x86_64-installer.exe" + - id: "commercialhaskell.stack" + repo: "commercialhaskell/stack" + url: "https://github.com/commercialhaskell/stack/releases/download/v{VERSION}/stack-{VERSION}-windows-x86_64-installer.exe" steps: - name: Update Packages uses: b0t-at/winget-updater@b0t-main From 611bf6ff15214a7746ef13cceb664698376e9aa8 Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sun, 12 May 2024 19:14:53 +0000 Subject: [PATCH 29/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84118b5..cd526c4 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-10-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-11-blue) | From 9bd58edb635db28e9511ee40d2fa194d5ed37355 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Sun, 12 May 2024 21:20:15 +0200 Subject: [PATCH 30/37] add JohnMacFarlane.Pandoc --- .github/workflows/GithubReleases.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index d5b6960..174c201 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -51,6 +51,9 @@ jobs: - id: "commercialhaskell.stack" repo: "commercialhaskell/stack" url: "https://github.com/commercialhaskell/stack/releases/download/v{VERSION}/stack-{VERSION}-windows-x86_64-installer.exe" + - id: "JohnMacFarlane.Pandoc" + repo: "jgm/pandoc" + url: "https://github.com/jgm/pandoc/releases/download/{VERSION}/pandoc-{VERSION}-windows-x86_64.msi" steps: - name: Update Packages uses: b0t-at/winget-updater@b0t-main From 5050ea7eed0cd2e6f2bee728c74140f14748749a Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sun, 12 May 2024 19:25:26 +0000 Subject: [PATCH 31/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd526c4..a62b0ad 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-11-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-12-blue) | From df838c027c9215524e26665f09480504007e0158 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Mon, 13 May 2024 00:01:29 +0200 Subject: [PATCH 32/37] add RustDesk.RustDesk --- .github/workflows/GithubReleases.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 174c201..a7c7ea9 100644 --- a/.github/workflows/GithubReleases.yml +++ b/.github/workflows/GithubReleases.yml @@ -54,6 +54,9 @@ jobs: - id: "JohnMacFarlane.Pandoc" repo: "jgm/pandoc" url: "https://github.com/jgm/pandoc/releases/download/{VERSION}/pandoc-{VERSION}-windows-x86_64.msi" + - id: "RustDesk.RustDesk" + repo: "rustdesk/rustdesk" + url: "https://github.com/rustdesk/rustdesk/releases/download/{VERSION}/rustdesk-{VERSION}-x86-sciter.exe https://github.com/rustdesk/rustdesk/releases/download/{VERSION}/rustdesk-{VERSION}-x86_64.exe" steps: - name: Update Packages uses: b0t-at/winget-updater@b0t-main From 9b340d3f80d3d03893585f4fd76a84510b2718ae Mon Sep 17 00:00:00 2001 From: a-mnich Date: Sun, 12 May 2024 22:01:41 +0000 Subject: [PATCH 33/37] Update package count badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a62b0ad..4b6ae3a 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ | Package Version Handling| Count| |----------------------------|---------------------------------------------------------------| | Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-17-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-12-blue) | +| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-13-blue) | From bb58386af7f17d85e9c45f369a46fabff9b77375 Mon Sep 17 00:00:00 2001 From: Alexander Mnich <56564725+a-mnich@users.noreply.github.com> Date: Mon, 13 May 2024 21:16:38 +0200 Subject: [PATCH 34/37] move update scripts into separate folder (#12) --- Scripts/{ => Packages}/Update-Crucial.StorageExecutive.ps1 | 0 Scripts/{ => Packages}/Update-FlipperDevicesInc.qFlipper.ps1 | 0 Scripts/{ => Packages}/Update-Fork.Fork.ps1 | 0 Scripts/{ => Packages}/Update-Gitbutler.GitButler.ps1 | 0 Scripts/{ => Packages}/Update-Glarysoft.GlaryUtilities.ps1 | 0 Scripts/{ => Packages}/Update-Logitech.OptionsPlus.ps1 | 0 Scripts/{ => Packages}/Update-Loupedeck.Loupedeck.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.Compass.Full.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.Compass.Isolated.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.Compass.Readonly.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.DatabaseTools.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.MongoDBAtlasCLI.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.MongoDBCLI.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.Server.ps1 | 0 Scripts/{ => Packages}/Update-MongoDB.Shell.ps1 | 0 Scripts/{ => Packages}/Update-SmartProjects.IsoBuster.ps1 | 0 Scripts/{ => Packages}/Update-StrawberryPerl.StrawberryPerl.ps1 | 0 Scripts/common.ps1 | 2 +- 18 files changed, 1 insertion(+), 1 deletion(-) rename Scripts/{ => Packages}/Update-Crucial.StorageExecutive.ps1 (100%) rename Scripts/{ => Packages}/Update-FlipperDevicesInc.qFlipper.ps1 (100%) rename Scripts/{ => Packages}/Update-Fork.Fork.ps1 (100%) rename Scripts/{ => Packages}/Update-Gitbutler.GitButler.ps1 (100%) rename Scripts/{ => Packages}/Update-Glarysoft.GlaryUtilities.ps1 (100%) rename Scripts/{ => Packages}/Update-Logitech.OptionsPlus.ps1 (100%) rename Scripts/{ => Packages}/Update-Loupedeck.Loupedeck.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.Compass.Full.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.Compass.Isolated.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.Compass.Readonly.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.DatabaseTools.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.MongoDBAtlasCLI.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.MongoDBCLI.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.Server.ps1 (100%) rename Scripts/{ => Packages}/Update-MongoDB.Shell.ps1 (100%) rename Scripts/{ => Packages}/Update-SmartProjects.IsoBuster.ps1 (100%) rename Scripts/{ => Packages}/Update-StrawberryPerl.StrawberryPerl.ps1 (100%) diff --git a/Scripts/Update-Crucial.StorageExecutive.ps1 b/Scripts/Packages/Update-Crucial.StorageExecutive.ps1 similarity index 100% rename from Scripts/Update-Crucial.StorageExecutive.ps1 rename to Scripts/Packages/Update-Crucial.StorageExecutive.ps1 diff --git a/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 b/Scripts/Packages/Update-FlipperDevicesInc.qFlipper.ps1 similarity index 100% rename from Scripts/Update-FlipperDevicesInc.qFlipper.ps1 rename to Scripts/Packages/Update-FlipperDevicesInc.qFlipper.ps1 diff --git a/Scripts/Update-Fork.Fork.ps1 b/Scripts/Packages/Update-Fork.Fork.ps1 similarity index 100% rename from Scripts/Update-Fork.Fork.ps1 rename to Scripts/Packages/Update-Fork.Fork.ps1 diff --git a/Scripts/Update-Gitbutler.GitButler.ps1 b/Scripts/Packages/Update-Gitbutler.GitButler.ps1 similarity index 100% rename from Scripts/Update-Gitbutler.GitButler.ps1 rename to Scripts/Packages/Update-Gitbutler.GitButler.ps1 diff --git a/Scripts/Update-Glarysoft.GlaryUtilities.ps1 b/Scripts/Packages/Update-Glarysoft.GlaryUtilities.ps1 similarity index 100% rename from Scripts/Update-Glarysoft.GlaryUtilities.ps1 rename to Scripts/Packages/Update-Glarysoft.GlaryUtilities.ps1 diff --git a/Scripts/Update-Logitech.OptionsPlus.ps1 b/Scripts/Packages/Update-Logitech.OptionsPlus.ps1 similarity index 100% rename from Scripts/Update-Logitech.OptionsPlus.ps1 rename to Scripts/Packages/Update-Logitech.OptionsPlus.ps1 diff --git a/Scripts/Update-Loupedeck.Loupedeck.ps1 b/Scripts/Packages/Update-Loupedeck.Loupedeck.ps1 similarity index 100% rename from Scripts/Update-Loupedeck.Loupedeck.ps1 rename to Scripts/Packages/Update-Loupedeck.Loupedeck.ps1 diff --git a/Scripts/Update-MongoDB.Compass.Full.ps1 b/Scripts/Packages/Update-MongoDB.Compass.Full.ps1 similarity index 100% rename from Scripts/Update-MongoDB.Compass.Full.ps1 rename to Scripts/Packages/Update-MongoDB.Compass.Full.ps1 diff --git a/Scripts/Update-MongoDB.Compass.Isolated.ps1 b/Scripts/Packages/Update-MongoDB.Compass.Isolated.ps1 similarity index 100% rename from Scripts/Update-MongoDB.Compass.Isolated.ps1 rename to Scripts/Packages/Update-MongoDB.Compass.Isolated.ps1 diff --git a/Scripts/Update-MongoDB.Compass.Readonly.ps1 b/Scripts/Packages/Update-MongoDB.Compass.Readonly.ps1 similarity index 100% rename from Scripts/Update-MongoDB.Compass.Readonly.ps1 rename to Scripts/Packages/Update-MongoDB.Compass.Readonly.ps1 diff --git a/Scripts/Update-MongoDB.DatabaseTools.ps1 b/Scripts/Packages/Update-MongoDB.DatabaseTools.ps1 similarity index 100% rename from Scripts/Update-MongoDB.DatabaseTools.ps1 rename to Scripts/Packages/Update-MongoDB.DatabaseTools.ps1 diff --git a/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 b/Scripts/Packages/Update-MongoDB.MongoDBAtlasCLI.ps1 similarity index 100% rename from Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 rename to Scripts/Packages/Update-MongoDB.MongoDBAtlasCLI.ps1 diff --git a/Scripts/Update-MongoDB.MongoDBCLI.ps1 b/Scripts/Packages/Update-MongoDB.MongoDBCLI.ps1 similarity index 100% rename from Scripts/Update-MongoDB.MongoDBCLI.ps1 rename to Scripts/Packages/Update-MongoDB.MongoDBCLI.ps1 diff --git a/Scripts/Update-MongoDB.Server.ps1 b/Scripts/Packages/Update-MongoDB.Server.ps1 similarity index 100% rename from Scripts/Update-MongoDB.Server.ps1 rename to Scripts/Packages/Update-MongoDB.Server.ps1 diff --git a/Scripts/Update-MongoDB.Shell.ps1 b/Scripts/Packages/Update-MongoDB.Shell.ps1 similarity index 100% rename from Scripts/Update-MongoDB.Shell.ps1 rename to Scripts/Packages/Update-MongoDB.Shell.ps1 diff --git a/Scripts/Update-SmartProjects.IsoBuster.ps1 b/Scripts/Packages/Update-SmartProjects.IsoBuster.ps1 similarity index 100% rename from Scripts/Update-SmartProjects.IsoBuster.ps1 rename to Scripts/Packages/Update-SmartProjects.IsoBuster.ps1 diff --git a/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 b/Scripts/Packages/Update-StrawberryPerl.StrawberryPerl.ps1 similarity index 100% rename from Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 rename to Scripts/Packages/Update-StrawberryPerl.StrawberryPerl.ps1 diff --git a/Scripts/common.ps1 b/Scripts/common.ps1 index 0c3ec61..29b100e 100644 --- a/Scripts/common.ps1 +++ b/Scripts/common.ps1 @@ -99,7 +99,7 @@ function Get-VersionAndUrl { [Parameter(Mandatory = $false)] [string] $WebsiteURL = ${Env:WebsiteURL} ) - $scriptPath = ".\Scripts\Update-$($wingetPackage).ps1" + $scriptPath = ".\Scripts\Packages\Update-$($wingetPackage).ps1" if (-not (Test-Path -Path $scriptPath)) { Write-Host "The script '$scriptPath' does not exist. Please check the wingetPackage parameter and the current directory." From 6f093aa9f452a80a79f97092c27bbf8dfec2e3f1 Mon Sep 17 00:00:00 2001 From: Alexander Mnich Date: Mon, 13 May 2024 22:44:29 +0200 Subject: [PATCH 35/37] add mass manifest update --- .github/workflows/MassUpdateManifests.yml | 27 +++++++ Scripts/Update-ExistingManifest.ps1 | 99 +++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 .github/workflows/MassUpdateManifests.yml create mode 100644 Scripts/Update-ExistingManifest.ps1 diff --git a/.github/workflows/MassUpdateManifests.yml b/.github/workflows/MassUpdateManifests.yml new file mode 100644 index 0000000..e404e2b --- /dev/null +++ b/.github/workflows/MassUpdateManifests.yml @@ -0,0 +1,27 @@ +name: Mass Update Manifest +on: + workflow_dispatch: + inputs: + PackageIdentifier: + description: "Package Identifier" + required: true + +jobs: + update: + name: Update manifests + runs-on: windows-latest + env: + WINGET_PKGS_FORK: ${{vars.WINGET_PKGS_FORK}} + WINGET_PAT: ${{secrets.WINGET_PAT}} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + - name: Checkout winget-pkgs fork + uses: actions/checkout@v4 + with: + repository: ${{env.WINGET_PKGS_FORK}} + token: ${{env.WINGET_PAT}} + - name: Trigget Mass Package Update + run: ./Scripts/UpdateManifests.ps1 -PackageIdentifier ${{ github.event.inputs.PackageIdentifier }} diff --git a/Scripts/Update-ExistingManifest.ps1 b/Scripts/Update-ExistingManifest.ps1 new file mode 100644 index 0000000..7396ce4 --- /dev/null +++ b/Scripts/Update-ExistingManifest.ps1 @@ -0,0 +1,99 @@ +#Import-Module powershell-yaml +# param( +# [Parameter(Mandatory = $true)] [string] $PackageIdentifier, +# [Parameter(Mandatory = $true)] [string] $OutputDir +# ) + +function Get-InstallerManifestContentGH { + param( + [Parameter(Mandatory = $true)] [string] $PackageIdentifier, + [Parameter(Mandatory = $false)] [string] $Version + ) + $ghInstallerManifestURL = "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests/$($PackageIdentifier.Substring(0, 1).ToLower())/$($PackageIdentifier.replace(".","/"))/$Version/$PackageIdentifier.installer.yaml" + return Invoke-RestMethod -Uri $ghInstallerManifestURL +} + + +function Get-AllInstallerManifestsGH { + param( + [Parameter(Mandatory = $true)] [string] $PackageIdentifier + ) + $versions = (komac.exe list-versions --identifier $PackageIdentifier --json) | ConvertFrom-Json + + $manifestDict = @{} + foreach ($version in $versions) { + $manifestDict.Add($version, (Get-InstallerManifestContentGH -PackageIdentifier $PackageIdentifier -Version $version)) + } + return $manifestDict +} + +function Export-InstallerLinks { + param( + [Parameter(Mandatory = $true)] [string] $Manifest + ) + + # Load the manifest file as a PowerShell custom object + $manifestPS = ConvertFrom-Yaml $Manifest + + $installerLinks = @() + + foreach ($installer in $manifestPS.Installers) { + $installerLinks += $installer.InstallerUrl + } + + return $installerLinks +} + + +function Update-WingetPackage { + param( + [Parameter(Mandatory = $true)] [string] $PackageIdentifier, + [Parameter(Mandatory = $true)] [string] $OutputDir, + [Parameter(Mandatory = $false)] [string] $Version, + [Parameter(Mandatory = $false)] [switch] $All + ) + + # Get the manifest(s) + if ($All -eq $true) { + $manifestDict = Get-AllInstallerManifestsGH -PackageIdentifier $PackageIdentifier + + } + else { + $manifestDict = @{} + $manifestDict[$Version] = Get-InstallerManifestContentGH -PackageIdentifier $PackageIdentifier -Version $Version + } + + $packageFolder = "$OutputDir\manifests\$($PackageIdentifier.Substring(0, 1).ToLower())/$($PackageIdentifier.replace(".", "/"))" + Set-Location $packageFolder + git checkout master + + foreach ($version in $manifestDict.Keys) { + $manifest = $manifestDict[$version] + # Extract the installer links from the manifest + $installerLinks = Export-InstallerLinks -Manifest $manifest + + # Create the branch name + $branchName = "manual_" + $PackageIdentifier + "_" + $version + # Create a new branch on the remote + git checkout -b $branchName + + Komac.exe update --version $version --identifier $PackageIdentifier --urls ($installerLinks -join ' ') -o $OutputDir + + git add $version + # Commit the changes + git commit -am "Update existing $PackageIdentifier version $($directory.Name) Manifest" + git checkout master + + # Push the branch to the remote + #git push origin $branchName + } + +} + +Update-WingetPackage -PackageIdentifier "hoppscotch.Hoppscotch" -OutputDir "C:\Programming\winget-pkgs" -All + + + + + + From f59d528ff42ec966cc6a5edcd6dc9d9cf89b9a95 Mon Sep 17 00:00:00 2001 From: Alexander Mnich Date: Mon, 13 May 2024 22:46:40 +0200 Subject: [PATCH 36/37] adapt package count trigger --- .github/workflows/PackageCount.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/PackageCount.yml b/.github/workflows/PackageCount.yml index 9072e3e..80a03fd 100644 --- a/.github/workflows/PackageCount.yml +++ b/.github/workflows/PackageCount.yml @@ -4,6 +4,9 @@ on: push: branches: - main + paths: + - .github/workflows/GithubReleases.yml + - .github/workflows/update-via-script.yml jobs: update-package-count: runs-on: ubuntu-latest From 64ece463d00dbf02b59391d99b251d53c8e34a6c Mon Sep 17 00:00:00 2001 From: Alexander Mnich Date: Mon, 13 May 2024 22:54:54 +0200 Subject: [PATCH 37/37] update manifest fixes --- .github/workflows/MassUpdateManifests.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/MassUpdateManifests.yml b/.github/workflows/MassUpdateManifests.yml index e404e2b..561ae84 100644 --- a/.github/workflows/MassUpdateManifests.yml +++ b/.github/workflows/MassUpdateManifests.yml @@ -11,7 +11,7 @@ jobs: name: Update manifests runs-on: windows-latest env: - WINGET_PKGS_FORK: ${{vars.WINGET_PKGS_FORK}} + WINGET_PKGS_FORK_REPO: ${{vars.WINGET_PKGS_FORK_REPO}} WINGET_PAT: ${{secrets.WINGET_PAT}} steps: - name: Checkout @@ -21,7 +21,9 @@ jobs: - name: Checkout winget-pkgs fork uses: actions/checkout@v4 with: - repository: ${{env.WINGET_PKGS_FORK}} + repository: ${{env.WINGET_PKGS_FORK_REPO}} token: ${{env.WINGET_PAT}} - name: Trigget Mass Package Update - run: ./Scripts/UpdateManifests.ps1 -PackageIdentifier ${{ github.event.inputs.PackageIdentifier }} + run: | + pwd + ./Scripts/UpdateManifests.ps1 -PackageIdentifier ${{ github.event.inputs.PackageIdentifier }}