Skip to content

Commit

Permalink
Merge pull request #2195 from AdmiringWorm/librecad-fix
Browse files Browse the repository at this point in the history
(librecad) Switch to using new GitHub API helper
  • Loading branch information
JPRuskin committed Mar 27, 2023
2 parents 0d1477e + 43b197b commit 5b20cbb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
4 changes: 3 additions & 1 deletion automatic/librecad/librecad.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"2.2": "2.2.0-rc4"
"2.2": "2.2.0-rc4",
"2.1": "2.1.3",
"2.0": "2.0.11"
}
38 changes: 23 additions & 15 deletions automatic/librecad/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
param($IncludeStream, [switch]$Force)
Import-Module AU

$releases = 'https://github.com/LibreCAD/LibreCAD/releases'
$softwareName = 'LibreCAD'

function global:au_BeforeUpdate { Get-RemoteFiles -Purge -NoSuffix }

function global:au_SearchReplace {
@{
".\legal\VERIFICATION.txt" = @{
"(?i)(^\s*location on\:?\s*)\<.*\>" = "`${1}<$releases>"
"(?i)(^\s*location on\:?\s*)\<.*\>" = "`${1}<$($Latest.ReleaseUrl)>"
"(?i)(\s*1\..+)\<.*\>" = "`${1}<$($Latest.URL32)>"
"(?i)(^\s*checksum\s*type\:).*" = "`${1} $($Latest.ChecksumType32)"
"(?i)(^\s*checksum(32)?\:).*" = "`${1} $($Latest.Checksum32)"
Expand All @@ -25,22 +24,31 @@ function global:au_SearchReplace {
}
}

function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing
function global:au_AfterUpdate {
Update-Metadata -key 'releaseNotes' -value $Latest.ReleaseNotes
}

$re = '\.exe$'
$urls32 = $download_page.Links | ? href -match $re | select -expand href | % { 'https://github.com' + $_ }
function global:au_GetLatest {
$releases = Get-AllGitHubReleases -Owner 'LibreCAD' -Name 'LibreCAD'

$streams = @{}
$urls32 | % {
$verRe = '\/'
$version = $_ -split "$verRe" | select -last 1 -skip 1
$version = Get-Version $version

if (!($streams.ContainsKey($version.ToString(2)))) {
$streams.Add($version.ToString(2), @{
Version = $version.ToString()
URL32 = $_
$releases | % {
if ($_.tag_name -eq 'latest') {
# This is the continuous build, ie nightly builds so we skip this one
return
}

$version = Get-Version $_.tag_name

$url = $_.assets | ? browser_download_url -match '\.exe$' | Select-Object -ExpandProperty browser_download_url
$streamName = $version.ToString(2)

if (!($streams.ContainsKey($streamName)) -and $url) {
$streams.Add($streamName, @{
Version = $version
URL32 = $url
ReleaseNotes = $_.body
ReleaseUrl = $_.html_url
})
}
}
Expand Down

0 comments on commit 5b20cbb

Please sign in to comment.