Skip to content

Commit 5d4b323

Browse files
authored
allow specifying version to install (#1358)
1 parent 28df1ec commit 5d4b323

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

docs/contribute/locally.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ This guide uses the first option. If you'd like to clone the repository and buil
3939
```
4040

4141
This downloads the latest binary, makes it executable, and installs it to your user PATH.
42+
You can optionally specify a specific version to install:
43+
44+
```sh
45+
DOCS_BUILDER_VERSION=0.40.0 curl -sL https://ela.st/docs-builder-install | sh
46+
```
4247

4348
To download and install the binary file manually, refer to [Releases](https://github.com/elastic/docs-builder/releases) on GitHub.
4449

@@ -68,6 +73,11 @@ If you get a `Permission denied` error, make sure that you aren't trying to run
6873
```
6974

7075
This downloads the latest binary, makes it executable, and installs it to your user PATH.
76+
You can optionally specify a specific version to install:
77+
78+
```powershell
79+
$env:DOCS_BUILDER_VERSION = '0.40.0'; iwr -useb https://ela.st/docs-builder-install.ps1 | iex
80+
```
7181

7282
To download and install the binary file manually, refer to [Releases](https://github.com/elastic/docs-builder/releases) on GitHub.
7383

install.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# PowerShell script to install docs-builder binary
22

33
# Use AppData\Local for user-specific installation instead of Program Files
4-
$targetDir = Join-Path -Path $env:LOCALAPPDATA -ChildPath "docs-builder"
4+
$targetDir = Join-Path -Path $env:LOCALAPPDATA -ChildPath "docs-builder"
55
$targetPath = Join-Path -Path $targetDir -ChildPath "docs-builder.exe"
66

7+
$version = $env:DOCS_BUILDER_VERSION
8+
if (-not $version) { $version = 'latest' }
9+
710
# Check if docs-builder already exists
811
if (Test-Path -Path $targetPath) {
912
Write-Host "docs-builder is already installed."
@@ -20,10 +23,15 @@ if (-not (Test-Path -Path $targetDir)) {
2023
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
2124
}
2225

23-
# Download the latest Windows binary from releases
26+
if ($version -eq 'latest') {
27+
$downloadUrl = "https://github.com/elastic/docs-builder/releases/latest/download/docs-builder-win-x64.zip"
28+
} else {
29+
$downloadUrl = "https://github.com/elastic/docs-builder/releases/download/$version/docs-builder-win-x64.zip"
30+
}
31+
2432
$tempZipPath = "$env:TEMP\docs-builder-win-x64.zip"
2533
Write-Host "Downloading docs-builder binary..."
26-
Invoke-WebRequest -Uri "https://github.com/elastic/docs-builder/releases/latest/download/docs-builder-win-x64.zip" -OutFile $tempZipPath
34+
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempZipPath
2735

2836
# Create a temporary directory for extraction
2937
$tempExtractPath = "$env:TEMP\docs-builder-extract"
@@ -53,8 +61,8 @@ if ($currentPath -notlike "*$targetDir*") {
5361
}
5462

5563
# Clean up temporary files
56-
Remove-Item -Path $tempZipPath -Force
64+
Remove-Item -Path $tempZipPath -Force
5765
Remove-Item -Path $tempExtractPath -Recurse -Force
5866

59-
Write-Host "docs-builder has been installed successfully and is available in your PATH."
60-
Write-Host "You may need to restart your terminal or PowerShell session for the PATH changes to take effect."
67+
Write-Host "docs-builder ($version) has been installed successfully and is available in your PATH."
68+
Write-Host "You may need to restart your terminal or PowerShell session for the PATH changes to take effect."

install.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
1212
ARCH="arm64"
1313
fi
1414

15+
VERSION="${DOCS_BUILDER_VERSION:-latest}"
16+
1517
# Determine binary to download based on OS
1618
if [ "$OS" = "darwin" ]; then
1719
BINARY="docs-builder-mac-$ARCH.zip"
@@ -55,8 +57,14 @@ fi
5557

5658
echo "Downloading docs-builder for $OS/$ARCH..."
5759

60+
if [ "$VERSION" = "latest" ]; then
61+
DOWNLOAD_URL="https://github.com/elastic/docs-builder/releases/latest/download/$BINARY"
62+
else
63+
DOWNLOAD_URL="https://github.com/elastic/docs-builder/releases/download/$VERSION/$BINARY"
64+
fi
65+
5866
# Download the appropriate binary
59-
if ! curl -LO "https://github.com/elastic/docs-builder/releases/latest/download/$BINARY"; then
67+
if ! curl -LO "$DOWNLOAD_URL"; then
6068
echo "Error: Failed to download $BINARY. Please check your internet connection."
6169
exit 1
6270
fi
@@ -87,5 +95,5 @@ fi
8795
# Clean up the downloaded zip file
8896
rm -f "$BINARY"
8997

90-
echo "docs-builder has been installed successfully and is available in your PATH."
91-
echo "You can run 'docs-builder --help' to see available commands."
98+
echo "docs-builder ($VERSION) has been installed successfully and is available in your PATH."
99+
echo "You can run 'docs-builder --help' to see available commands."

0 commit comments

Comments
 (0)