This repository was archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_and_build.ps1
More file actions
45 lines (35 loc) · 1.5 KB
/
Copy pathcheck_and_build.ps1
File metadata and controls
45 lines (35 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$baseDir = $PSScriptRoot
pushd $baseDir
# first, lets make sure we're behaving ourselves and wait for our ratelimit, if any
# get currently authenticated user rate limit info
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
# if we don't have at least 100 requests left, wait until reset
if ($rate.remaining -lt 10) {
$wait = ($rate.reset - (Get-Date (Get-Date).ToUniversalTime() -UFormat %s))
echo "Rate limit remaining is $($rate.remaining), waiting for $($wait / 1000) seconds to reset"
sleep $wait
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
echo "Rate limit has reset to $($rate.remaining) requests"
}
$result = &{
# now, lets grab our victim's list of versions
$versions = gh api repos/devlooped/nugetizer/releases |
ConvertFrom-Json |
Sort-Object published_at |
Select -ExpandProperty tag_name
if (!$?) { return -1 }
# we'll write that list out to a file which we use for change tracking
$versions > versions.txt
# check if the versions list has changed
git diff -w --quiet --exit-code -- versions.txt
if ($?) { return $false } # if it returns 0, the list hasn't changed
# the list has changed, so we should build the most recent (last) element of the versions list
[Array]::Reverse($versions)
$ver = $versions[0]
# execute the build
&"$baseDir/do_build.ps1" -VersionFromTag -Commit $ver
if (!$?) { return $LastExitCode }
return $true
}
popd
return $result