@@ -9,6 +9,8 @@ $ErrorActionPreference = "Stop"
9
9
$ProgressPreference = " SilentlyContinue"
10
10
11
11
$BuildDir = " build"
12
+ $REPO_OWNER = " yetone"
13
+ $REPO_NAME = " avante.nvim"
12
14
13
15
function Build-FromSource ($feature ) {
14
16
if (-not (Test-Path $BuildDir )) {
@@ -41,9 +43,7 @@ function Test-GHAuth {
41
43
}
42
44
}
43
45
44
- function Download-Prebuilt ($feature ) {
45
- $REPO_OWNER = " yetone"
46
- $REPO_NAME = " avante.nvim"
46
+ function Download-Prebuilt ($feature , $tag ) {
47
47
48
48
$SCRIPT_DIR = $PSScriptRoot
49
49
# Set the target directory to clone the artifact
@@ -65,11 +65,12 @@ function Download-Prebuilt($feature) {
65
65
$TempFile = Get-Item ([System.IO.Path ]::GetTempFilename()) | Rename-Item - NewName { $_.Name + " .zip" } - PassThru
66
66
67
67
if ((Test-Command " gh" ) -and (Test-GHAuth )) {
68
- gh release download -- repo " $REPO_OWNER /$REPO_NAME " -- pattern " *$ARTIFACT_NAME_PATTERN *" -- output $TempFile -- clobber
68
+ write-host " Using GitHub CLI to download artifacts..."
69
+ gh release download $latestTag -- repo " $REPO_OWNER /$REPO_NAME " -- pattern " *$ARTIFACT_NAME_PATTERN *" -- output $TempFile -- clobber
69
70
} else {
70
71
# Get the artifact download URL
71
- $LATEST_RELEASE = Invoke-RestMethod - Uri " https://api.github.com/repos/$REPO_OWNER /$REPO_NAME /releases/latest "
72
- $ARTIFACT_URL = $LATEST_RELEASE .assets | Where-Object { $_.name -like " *$ARTIFACT_NAME_PATTERN *" } | Select-Object - ExpandProperty browser_download_url
72
+ $RELEASE = Invoke-RestMethod - Uri " https://api.github.com/repos/$REPO_OWNER /$REPO_NAME /releases/tags/ $tag "
73
+ $ARTIFACT_URL = $RELEASE .assets | Where-Object { $_.name -like " *$ARTIFACT_NAME_PATTERN *" } | Select-Object - ExpandProperty browser_download_url
73
74
74
75
# Download and extract the artifact
75
76
Invoke-WebRequest - Uri $ARTIFACT_URL - OutFile $TempFile
@@ -103,22 +104,15 @@ function Main {
103
104
if ($latestTag -eq $builtTag -and $latestTag ) {
104
105
Write-Host " Local build is up to date. No download needed."
105
106
} elseif ($latestTag -ne $builtTag -and $latestTag ) {
106
- if (Test-Command " gh" -and Test-GHAuth ) {
107
- gh release download $latestTag -- repo " github.com/$REPO_OWNER /$REPO_NAME " -- pattern " *$ARTIFACT_NAME_PATTERN *" -- clobber -- output - | tar - zxvf - - C $TARGET_DIR
108
- Save-Tag $latestTag
109
- } else {
110
- $ARTIFACT_URL = Invoke-RestMethod - Uri " https://api.github.com/repos/$REPO_OWNER /$REPO_NAME /releases/tags/$latestTag " | Select-String - Pattern " browser_download_url" | ForEach-Object { $_.Matches.Groups [1 ].Value } | Where-Object { $_ -match $ARTIFACT_NAME_PATTERN }
111
-
112
- Invoke-WebRequest - Uri $ARTIFACT_URL - OutFile " $TempFile "
113
- Expand-Archive - Path " $TempFile " - DestinationPath " $TARGET_DIR " - Force
114
- Remove-Item " $TempFile "
115
- Save-Tag $latestTag
116
- }
107
+ Write-Host " Downloading prebuilt binaries $latestTag for $Version ..."
108
+ Download- Prebuilt $Version $latestTag
109
+ Save-Tag $latestTag
117
110
} else {
118
111
cargo build -- release -- features= $Version
119
112
Get-ChildItem - Path " target/release/avante_*.dll" | ForEach-Object {
120
113
Copy-Item $_.FullName " build/$ ( $_.Name ) "
121
114
}
115
+ Save-Tag $latestTag
122
116
}
123
117
}
124
118
Write-Host " Completed!"
0 commit comments