Skip to content

Make install script more robust #1255

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

Merged
merged 3 commits into from
May 19, 2025
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
8 changes: 5 additions & 3 deletions docs/contribute/locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ This guide uses the first option. If you'd like to clone the repository and buil

This downloads the latest binary, makes it executable, and installs it to your user PATH.

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

2. **Run docs-builder from a docs folder**

Use the `serve` command from any docs folder to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
Expand All @@ -66,16 +68,16 @@ If you get a `Permission denied` error, make sure that you aren't trying to run

This downloads the latest binary, makes it executable, and installs it to your user PATH.

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

2. **Run docs-builder from a docs folder**

Use the `serve` command from any docs folder to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:

```sh
docs-builder serve
```

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


:::
::::

Expand Down
19 changes: 15 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -e
set -euo pipefail

# Determine OS type and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -56,11 +56,22 @@ fi
echo "Downloading docs-builder for $OS/$ARCH..."

# Download the appropriate binary
curl -LO "https://github.com/elastic/docs-builder/releases/latest/download/$BINARY"
if ! curl -LO "https://github.com/elastic/docs-builder/releases/latest/download/$BINARY"; then
echo "Error: Failed to download $BINARY. Please check your internet connection."
exit 1
fi

# Validate the downloaded file
if [ ! -s "$BINARY" ]; then
echo "Error: Downloaded file $BINARY is missing or empty."
exit 1
fi

# Extract only the docs-builder file to /tmp directory
# Use -o flag to always overwrite files without prompting
unzip -j -o "$BINARY" docs-builder -d /tmp
if ! unzip -j -o "$BINARY" docs-builder -d /tmp; then
echo "Error: Failed to extract docs-builder from $BINARY."
exit 1
fi

# Ensure the binary is executable
chmod +x /tmp/docs-builder
Expand Down
Loading