Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(librecad) Switch to using new GitHub API helper #2195

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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