-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbuild-dev.ps1
More file actions
59 lines (46 loc) · 2.15 KB
/
build-dev.ps1
File metadata and controls
59 lines (46 loc) · 2.15 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function Invoke-Git {
param(
[Parameter(Mandatory = $true)]
[string]$RepositoryPath,
[Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)]
[string[]]$Arguments
)
& git -C $RepositoryPath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "git $($Arguments -join ' ') failed in $RepositoryPath"
}
}
# Ensure all submodules are initialized, including nested submodules used by dependencies.
Invoke-Git $PSScriptRoot submodule sync --recursive
Invoke-Git $PSScriptRoot submodule foreach --recursive git reset --hard
Invoke-Git $PSScriptRoot submodule foreach --recursive git clean -ffdx
Invoke-Git $PSScriptRoot submodule update --init --recursive
# Ensure all top-level dependency submodules are checked out to the latest remote commit
# without leaving stale untracked files from previous checkouts behind.
Get-ChildItem (Join-Path $PSScriptRoot 'ext') -Directory | ForEach-Object {
$path = $_.FullName
Write-Host "Updating submodule: $path"
Invoke-Git $path fetch origin --tags --prune
$defaultRef = (& git -C $path symbolic-ref refs/remotes/origin/HEAD).Trim()
if ($LASTEXITCODE -ne 0) {
throw "Unable to determine the default branch for $path"
}
$defaultBranch = $defaultRef -replace '^refs/remotes/origin/', ''
# Clean before and after the reset so older generated files cannot survive a branch move.
Invoke-Git $path clean -ffdx
Invoke-Git $path reset --hard "origin/$defaultBranch"
Invoke-Git $path clean -ffdx
# Bring nested submodules to the commits referenced by the updated parent checkout,
# then clean their working trees too.
Invoke-Git $path submodule sync --recursive
Invoke-Git $path submodule update --init --recursive
Invoke-Git $path submodule foreach --recursive git reset --hard
Invoke-Git $path submodule foreach --recursive git clean -ffdx
Invoke-Git $path submodule update --init --recursive
}
# Ensure deterministic builds do not affect submodule build
# TODO: Remove first two values once all projects are updated to latest build props.
$env:CI = $false
$env:GITHUB_ACTIONS = $false
$env:SIXLABORS_TESTING = $true
docfx