Browse Source

Make BlueBrick package automatic update

Douglas Thrift 1 year ago
parent
commit
b16c66765b

manual/bluebrick/bluebrick.nuspec → automatic/bluebrick/bluebrick.nuspec


manual/bluebrick/tools/BlueBrick.exe.gui → automatic/bluebrick/tools/BlueBrick.exe.gui


+ 3 - 3
manual/bluebrick/tools/chocolateyinstall.ps1

@@ -8,9 +8,9 @@ $blueBrickLnk = Join-Path ([System.Environment]::GetFolderPath('CommonPrograms')
 $packageArgs = @{
   packageName   = $packageName
   unzipLocation = $toolsDir
-  url           = 'https://bluebrick.lswproject.com/download/BlueBrick1.8.1.zip'
-  checksum      = '1bce9fe3e3ff1595ddab07765aaa8232362e34a4a4d666dab5d0573eb4725f4a'
-  checksumType  = 'sha256'
+  url           = 'https://bluebrick.lswproject.com/download/BlueBrick1.8.1.zip'        # BlueBrick
+  checksum      = '1bce9fe3e3ff1595ddab07765aaa8232362e34a4a4d666dab5d0573eb4725f4a'    # BlueBrick
+  checksumType  = 'sha256'                                                              # BlueBrick
 }
 $partsPackageArgs = @{
   packageName   = $packageName

manual/bluebrick/tools/chocolateyuninstall.ps1 → automatic/bluebrick/tools/chocolateyuninstall.ps1


+ 24 - 0
automatic/bluebrick/update.ps1

@@ -0,0 +1,24 @@
+Import-Module au
+
+$latest_release = 'https://bluebrick.lswproject.com/download.html'
+
+function global:au_GetLatest {
+    $download_page = Invoke-WebRequest -Uri $latest_release
+    $regex         = '^.+/BlueBrick(\d+\.\d+\.\d+)\.zip$'
+    $url           = $download_page.Links | ? href -Match $regex | select -First 1 -ExpandProperty href
+    $url           = [System.Uri]::new([System.Uri]$latest_release, $url).AbsoluteUri
+    $version       = $url -replace $regex, '$1'
+    return @{ Version = $version; URL32 = $url }
+}
+
+function global:au_SearchReplace {
+    @{
+        'tools\chocolateyInstall.ps1' = @{
+            "(\s+url\s+=\s+)('.*')(\s+#\sBlueBrick)"          = "`$1'$($Latest.URL32)'`$3"
+            "(\s+checksum\s+=\s+)('.*')(\s+#\sBlueBrick)"     = "`$1'$($Latest.Checksum32)'`$3"
+            "(\s+checksumType\s+=\s+)('.*')(\s+#\sBlueBrick)" = "`$1'$($Latest.ChecksumType32)'`$3"
+        }
+    }
+}
+
+update -ChecksumFor 32