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" diff --git a/.github/workflows/GithubReleases.yml b/.github/workflows/GithubReleases.yml index 50a9cd4..a7c7ea9 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 @@ -28,14 +29,42 @@ 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" + - 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/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" + - 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" + - 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" + - 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: michidk/winget-updater@v1 + uses: b0t-at/winget-updater@b0t-main with: identifier: ${{ matrix.id }} repo: ${{ matrix.repo }} url: ${{ matrix.url }} komac-token: ${{ secrets.WINGET_PAT }} + komac-version: latest custom-fork-owner: damn-good-b0t + submit: ${{ vars.SUBMIT_PR }} diff --git a/.github/workflows/MassUpdateManifests.yml b/.github/workflows/MassUpdateManifests.yml new file mode 100644 index 0000000..561ae84 --- /dev/null +++ b/.github/workflows/MassUpdateManifests.yml @@ -0,0 +1,29 @@ +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_REPO: ${{vars.WINGET_PKGS_FORK_REPO}} + 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_REPO}} + token: ${{env.WINGET_PAT}} + - name: Trigget Mass Package Update + run: | + pwd + ./Scripts/UpdateManifests.ps1 -PackageIdentifier ${{ github.event.inputs.PackageIdentifier }} diff --git a/.github/workflows/PackageCount.yml b/.github/workflows/PackageCount.yml index 9c2a056..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 @@ -15,7 +18,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 @@ -23,8 +26,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 }} diff --git a/.github/workflows/update-via-script.yml b/.github/workflows/update-via-script.yml index 0808438..3815f16 100644 --- a/.github/workflows/update-via-script.yml +++ b/.github/workflows/update-via-script.yml @@ -9,39 +9,60 @@ jobs: update-scriptbased: name: ${{ matrix.PackageName }} runs-on: windows-latest + environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Test' }} strategy: fail-fast: false 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" + - PackageName: "Fork.Fork" + WebsiteURL: "https://fork.dev" steps: - name: Checkout @@ -57,6 +78,8 @@ 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 }} + Submit: ${{ vars.SUBMIT_PR }} + run: .\Scripts\generic.ps1 diff --git a/README.md b/README.md index 082990d..4b6ae3a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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| |----------------------------|---------------------------------------------------------------| -| Script based | ![Script based Packages](https://img.shields.io/badge/ScriptPackages-14-green) | -| GitHub Release based | ![GitHub based Packages](https://img.shields.io/badge/GithubPackages-4-blue) | +| 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-13-blue) | diff --git a/Scripts/Packages/Update-Crucial.StorageExecutive.ps1 b/Scripts/Packages/Update-Crucial.StorageExecutive.ps1 new file mode 100644 index 0000000..922ed19 --- /dev/null +++ b/Scripts/Packages/Update-Crucial.StorageExecutive.ps1 @@ -0,0 +1,7 @@ +. .\Scripts\common.ps1 + +$latestVersionUrl = $WebsiteURL + +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersion" + +return "$latestVersionUrl|x64", $versionInfo diff --git a/Scripts/Packages/Update-FlipperDevicesInc.qFlipper.ps1 b/Scripts/Packages/Update-FlipperDevicesInc.qFlipper.ps1 new file mode 100644 index 0000000..6385229 --- /dev/null +++ b/Scripts/Packages/Update-FlipperDevicesInc.qFlipper.ps1 @@ -0,0 +1,8 @@ +. .\Scripts\common.ps1 + + +$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 + +return $latestVersionDirectory, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Packages/Update-Fork.Fork.ps1 b/Scripts/Packages/Update-Fork.Fork.ps1 new file mode 100644 index 0000000..db8d119 --- /dev/null +++ b/Scripts/Packages/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/Packages/Update-Gitbutler.GitButler.ps1 b/Scripts/Packages/Update-Gitbutler.GitButler.ps1 new file mode 100644 index 0000000..0408bf2 --- /dev/null +++ b/Scripts/Packages/Update-Gitbutler.GitButler.ps1 @@ -0,0 +1,26 @@ +. .\Scripts\common.ps1 + + +# Follow redirect of https://app.gitbutler.com/downloads/release/windows/x86_64/msi +$website = $WebsiteURL +$absolutURL=[System.Net.HttpWebRequest]::Create($website).GetResponse().ResponseUri.AbsoluteUri + +# regex to check if variable absolutURL is valid URL +$regex = "^(http|https)://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$" +if ($absolutURL -match $regex) { + $latestVersionUrl = $absolutURL + Write-Host "URL is valid" +} +else { + Write-Host "URL is not valid" + exit 1 +} + + +# get full name of file from link +$fileName = $latestVersionUrl.Split("/")[-1] + +# Get Version via Regex. The version is the part betweet "GitButler_" and "_x64" +$latestVersion = $fileName -replace ".*GitButler_(.*)_(x64|x86).*", '$1' + +return $latestVersion, $latestVersionUrl diff --git a/Scripts/Packages/Update-Glarysoft.GlaryUtilities.ps1 b/Scripts/Packages/Update-Glarysoft.GlaryUtilities.ps1 new file mode 100644 index 0000000..34c29fa --- /dev/null +++ b/Scripts/Packages/Update-Glarysoft.GlaryUtilities.ps1 @@ -0,0 +1,7 @@ +. .\Scripts\common.ps1 + +$latestVersionUrl = $WebsiteURL +# download latest version from loupedeck.com and get version by filename +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersionRaw" + +return $versionInfo, $latestVersionUrl diff --git a/Scripts/Packages/Update-Logitech.OptionsPlus.ps1 b/Scripts/Packages/Update-Logitech.OptionsPlus.ps1 new file mode 100644 index 0000000..66588c7 --- /dev/null +++ b/Scripts/Packages/Update-Logitech.OptionsPlus.ps1 @@ -0,0 +1,7 @@ +. .\Scripts\common.ps1 + +$latestVersionUrl = $WebsiteURL +# download latest version from loupedeck.com and get version by filename +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersion" + +return $versionInfo, $latestVersionUrl diff --git a/Scripts/Packages/Update-Loupedeck.Loupedeck.ps1 b/Scripts/Packages/Update-Loupedeck.Loupedeck.ps1 new file mode 100644 index 0000000..eb25db6 --- /dev/null +++ b/Scripts/Packages/Update-Loupedeck.Loupedeck.ps1 @@ -0,0 +1,24 @@ +. .\Scripts\common.ps1 + +$latestVersionUrl = $WebsiteURL + +# download latest version from loupedeck.com and get version by filename +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $WebsiteURL -VersionInfoProperty "ProductVersion" + + +Write-Host "Found latest version: $versionInfo" +$latestversion = $versionInfo +# extract major and minor version e.g. 5.9 from 5.9.10 +$majorMinorVersion = $versionInfo -replace '\.\d+$' +$fullDownloadURL = "https://5145542.fs1.hubspotusercontent-na1.net/hubfs/5145542/Knowledge%20Base/LD%20Software%20Downloads/$majorMinorVersion/LoupedeckInstaller_" + $versionInfo + ".exe" + +Write-Host "Full download URL: $fullDownloadURL" + +# check if full download URL is valid +$fullDownloadURLResponse = Invoke-WebRequest -Uri $fullDownloadURL -UseBasicParsing -Method Head +if ($fullDownloadURLResponse.StatusCode -ne 200) { + Write-Host "Full download URL is not valid" + exit 1 +} + +return $latestVersion, $fullDownloadURL diff --git a/Scripts/Packages/Update-MongoDB.Compass.Full.ps1 b/Scripts/Packages/Update-MongoDB.Compass.Full.ps1 new file mode 100644 index 0000000..81e15a6 --- /dev/null +++ b/Scripts/Packages/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/Packages/Update-MongoDB.Compass.Isolated.ps1 b/Scripts/Packages/Update-MongoDB.Compass.Isolated.ps1 new file mode 100644 index 0000000..bffe2b1 --- /dev/null +++ b/Scripts/Packages/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/Packages/Update-MongoDB.Compass.Readonly.ps1 b/Scripts/Packages/Update-MongoDB.Compass.Readonly.ps1 new file mode 100644 index 0000000..2d124f6 --- /dev/null +++ b/Scripts/Packages/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/Packages/Update-MongoDB.DatabaseTools.ps1 b/Scripts/Packages/Update-MongoDB.DatabaseTools.ps1 new file mode 100644 index 0000000..3b1b14b --- /dev/null +++ b/Scripts/Packages/Update-MongoDB.DatabaseTools.ps1 @@ -0,0 +1,10 @@ +. .\Scripts\common.ps1 + +$PackageFilter = "mongodb-database-tools" + +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL + +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url + +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Packages/Update-MongoDB.MongoDBAtlasCLI.ps1 b/Scripts/Packages/Update-MongoDB.MongoDBAtlasCLI.ps1 new file mode 100644 index 0000000..72fc014 --- /dev/null +++ b/Scripts/Packages/Update-MongoDB.MongoDBAtlasCLI.ps1 @@ -0,0 +1,10 @@ +. .\Scripts\common.ps1 + +$PackageFilter = "mongodb-atlas-cli" + +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL + +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url + +return $latestVersion, "$latestVersionUrl|x64" \ No newline at end of file diff --git a/Scripts/Packages/Update-MongoDB.MongoDBCLI.ps1 b/Scripts/Packages/Update-MongoDB.MongoDBCLI.ps1 new file mode 100644 index 0000000..90e77c5 --- /dev/null +++ b/Scripts/Packages/Update-MongoDB.MongoDBCLI.ps1 @@ -0,0 +1,10 @@ +. .\Scripts\common.ps1 + +$PackageFilter = "mongocli" + +$Latest = Get-LatestMongoDBVersions -PackageFilter $PackageFilter -WebsiteURL $WebsiteURL + +$latestVersion = $Latest.Version +$latestVersionUrl = $Latest.Url + +return $latestVersion, "$latestVersionUrl|x64" diff --git a/Scripts/Packages/Update-MongoDB.Server.ps1 b/Scripts/Packages/Update-MongoDB.Server.ps1 new file mode 100644 index 0000000..6bdf9d7 --- /dev/null +++ b/Scripts/Packages/Update-MongoDB.Server.ps1 @@ -0,0 +1,26 @@ +. .\Scripts\common.ps1 + + + +# Download the webpage +$website = Invoke-WebRequest -Uri $WebsiteURL + +# 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?://[^\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] } + +# Exclude release candidates +$stableVersions = $versions | Where-Object { $_ -notmatch '-rc' } + +# Sort the versions and get the latest one +$latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1 +$latestVersionUrl = $links | Where-Object { $_ -match $latestVersion } + +return $latestVersion, $latestVersionUrl \ No newline at end of file diff --git a/Scripts/Packages/Update-MongoDB.Shell.ps1 b/Scripts/Packages/Update-MongoDB.Shell.ps1 new file mode 100644 index 0000000..eaf7528 --- /dev/null +++ b/Scripts/Packages/Update-MongoDB.Shell.ps1 @@ -0,0 +1,27 @@ +. .\Scripts\common.ps1 + + + +# Download the webpage +$website = Invoke-WebRequest -Uri $WebsiteURL + +# 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 } +$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] } + +# 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 } + +return $latestVersion, $latestVersionUrl + diff --git a/Scripts/Packages/Update-SmartProjects.IsoBuster.ps1 b/Scripts/Packages/Update-SmartProjects.IsoBuster.ps1 new file mode 100644 index 0000000..e0af14b --- /dev/null +++ b/Scripts/Packages/Update-SmartProjects.IsoBuster.ps1 @@ -0,0 +1,7 @@ +. .\Scripts\common.ps1 + +$latestVersionUrl = $WebsiteURL -split " " | Select-Object -First 1 + +$versionInfo = Get-ProductVersionFromFile -WebsiteURL $latestVersionUrl -VersionInfoProperty "ProductVersion" + +return $versionInfo, $WebsiteURL diff --git a/Scripts/Packages/Update-StrawberryPerl.StrawberryPerl.ps1 b/Scripts/Packages/Update-StrawberryPerl.StrawberryPerl.ps1 new file mode 100644 index 0000000..728871f --- /dev/null +++ b/Scripts/Packages/Update-StrawberryPerl.StrawberryPerl.ps1 @@ -0,0 +1,9 @@ +. .\Scripts\common.ps1 + +$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 $WebsiteURL --json assets -q ".assets[] .url" +$msiAsset = $assets | Where-Object { $_ -like "*.msi" } + +return $latestVersion, $msiAsset \ No newline at end of file diff --git a/Scripts/Update-Crucial.StorageExecutive.ps1 b/Scripts/Update-Crucial.StorageExecutive.ps1 deleted file mode 100644 index 68e40af..0000000 --- a/Scripts/Update-Crucial.StorageExecutive.ps1 +++ /dev/null @@ -1,80 +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} - - -# 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." - } -} 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 + + + + + + diff --git a/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 b/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 deleted file mode 100644 index 6bd8a45..0000000 --- a/Scripts/Update-FlipperDevicesInc.qFlipper.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$url = ${Env:WebsiteURL} -$wingetPackage = ${Env:PackageName} - -$versionDirectoryUrl = $url -Write-Host "Try to update $wingetPackage" - - -$versionDirectory = Invoke-RestMethod -Uri $versionDirectoryUrl -$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." - } -} diff --git a/Scripts/Update-Gitbutler.GitButler.ps1 b/Scripts/Update-Gitbutler.GitButler.ps1 deleted file mode 100644 index 8435fdc..0000000 --- a/Scripts/Update-Gitbutler.GitButler.ps1 +++ /dev/null @@ -1,94 +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} - -Write-Host "Try to update $wingetPackage" - -# Follow redirect of https://app.gitbutler.com/downloads/release/windows/x86_64/msi -$website = $url -$absolutURL=[System.Net.HttpWebRequest]::Create($website).GetResponse().ResponseUri.AbsoluteUri - -# regex to check if variable absolutURL is valid URL -$regex = "^(http|https)://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$" -if ($absolutURL -match $regex) { - $latestVersionUrl = $absolutURL - Write-Host "URL is valid" -} -else { - Write-Host "URL is not valid" - exit 1 -} - - -# get full name of file from link -$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." - } -} diff --git a/Scripts/Update-Glarysoft.GlaryUtilities.ps1 b/Scripts/Update-Glarysoft.GlaryUtilities.ps1 deleted file mode 100644 index 08f9e6e..0000000 --- a/Scripts/Update-Glarysoft.GlaryUtilities.ps1 +++ /dev/null @@ -1,81 +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} - - -# 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 - - 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." - } -} diff --git a/Scripts/Update-Logitech.OptionsPlus.ps1 b/Scripts/Update-Logitech.OptionsPlus.ps1 deleted file mode 100644 index af49031..0000000 --- a/Scripts/Update-Logitech.OptionsPlus.ps1 +++ /dev/null @@ -1,84 +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} - - -# 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 - - 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." - } -} diff --git a/Scripts/Update-Loupedeck.Loupedeck.ps1 b/Scripts/Update-Loupedeck.Loupedeck.ps1 deleted file mode 100644 index b506c2b..0000000 --- a/Scripts/Update-Loupedeck.Loupedeck.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -if ($Env:GITHUB_TOKEN) { - Write-Host 'GITHUB_TOKEN detected' - $gitToken = ${Env:GITHUB_TOKEN} -} -else { - Write-Host 'GITHUB_TOKEN not detected' - exit 1 -} - -$url = ${Env:WebsiteURL} -$wingetPackage = ${Env:PackageName} - -# 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 - -if ($null -eq $versionInfo) { - Write-Host "Could not find version info in file" - exit 1 -} - -Write-Host "Found latest version: $versionInfo" -$latestversion = $versionInfo -# extract major and minor version e.g. 5.9 from 5.9.10 -$majorMinorVersion = $versionInfo -replace '\.\d+$' -$fullDownloadURL = "https://5145542.fs1.hubspotusercontent-na1.net/hubfs/5145542/Knowledge%20Base/LD%20Software%20Downloads/$majorMinorVersion/LoupedeckInstaller_" + $versionInfo + ".exe" - -Write-Host "Full download URL: $fullDownloadURL" - -# check if full download URL is valid -$fullDownloadURLResponse = Invoke-WebRequest -Uri $fullDownloadURL -UseBasicParsing -Method Head -if ($fullDownloadURLResponse.StatusCode -ne 200) { - Write-Host "Full download URL is not valid" - 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." - } -} 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 deleted file mode 100644 index c29170e..0000000 --- a/Scripts/Update-MongoDB.DatabaseTools.ps1 +++ /dev/null @@ -1,106 +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} - -# Placeholder for the release notes URL -$releaseNotesUrl = "https://www.mongodb.com/docs/database-tools/release-notes/database-tools-changelog/#{version}-changelog" - -$PackageMapping = @{ - "MongoDB.DatabaseTools" = "mongodb-database-tools" -} - -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." - } -} -} diff --git a/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 b/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 deleted file mode 100644 index 4ac2f35..0000000 --- a/Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1 +++ /dev/null @@ -1,98 +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} - -$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 - - 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." - } -} - diff --git a/Scripts/Update-MongoDB.MongoDBCLI.ps1 b/Scripts/Update-MongoDB.MongoDBCLI.ps1 deleted file mode 100644 index 389d095..0000000 --- a/Scripts/Update-MongoDB.MongoDBCLI.ps1 +++ /dev/null @@ -1,100 +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} - -$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 - - 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." - } -} - diff --git a/Scripts/Update-MongoDB.Server.ps1 b/Scripts/Update-MongoDB.Server.ps1 deleted file mode 100644 index e7b1f91..0000000 --- a/Scripts/Update-MongoDB.Server.ps1 +++ /dev/null @@ -1,92 +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} - -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?://[^\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] } - -# Exclude release candidates -$stableVersions = $versions | Where-Object { $_ -notmatch '-rc' } - -# Sort the versions and get the latest one -$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." - } -} diff --git a/Scripts/Update-MongoDB.Shell.ps1 b/Scripts/Update-MongoDB.Shell.ps1 deleted file mode 100644 index d9ef543..0000000 --- a/Scripts/Update-MongoDB.Shell.ps1 +++ /dev/null @@ -1,92 +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} - -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 } -$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] } - -# 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: $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 deleted file mode 100644 index 4971e52..0000000 --- a/Scripts/Update-SmartProjects.IsoBuster.ps1 +++ /dev/null @@ -1,87 +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} - -# 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() - -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." - } -} diff --git a/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 b/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 deleted file mode 100644 index de4bf53..0000000 --- a/Scripts/Update-StrawberryPerl.StrawberryPerl.ps1 +++ /dev/null @@ -1,83 +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} -$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" -$latestVersion = $latestVersionName -replace '.*?(\d+\.\d+\.\d+(.\d+)).*', '$1' -$assets = gh release view --repo $repo --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 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..29b100e --- /dev/null +++ b/Scripts/common.ps1 @@ -0,0 +1,279 @@ +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 "Package not yet in winget. Please add new package manually" + exit 1 + } + elseif ($ghVersionCheck.StatusCode -eq 200) { + Write-Host "Latest version of $wingetPackage $latestVersion is already present in winget." + exit 0 + } + else { + Write-Host "Package $wingetPackage is in winget, but version $latestVersion is not present." + 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 "Package not yet in winget. Please add new package 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\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." + 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)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac", + [Parameter(Mandatory = $false)] [switch] $Submit = $false + ) + $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" { + $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(' ','" "'))" ($Submit -eq $true ? "-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 ($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'" + } + } + } + } +} + +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..bb3ae2e --- /dev/null +++ b/Scripts/generic.ps1 @@ -0,0 +1,16 @@ +. .\Scripts\common.ps1 + +#### Main +$params = @{ + wingetPackage = ${Env:PackageName} + WebsiteURL = ${Env:WebsiteURL} +} +if($Env:With) { + $params.Add("With", $Env:With) +} +if($Env:Submit) { + $params.Add("Submit", $true) +} + +Update-WingetPackage @params +