Skip to content
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 cli/cmd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
func UpgradeCmd(ch *cmdutil.Helper) *cobra.Command {
var version string
var nightly bool
var force bool

upgradeCmd := &cobra.Command{
Use: "upgrade",
Expand All @@ -24,19 +25,20 @@ func UpgradeCmd(ch *cmdutil.Helper) *cobra.Command {
}
version = "v" + v.String()

return installscript.Install(cmd.Context(), version)
return installscript.Install(cmd.Context(), version, force)
}

if nightly {
return installscript.Install(cmd.Context(), "nightly")
return installscript.Install(cmd.Context(), "nightly", force)
}

return installscript.Install(cmd.Context(), "")
return installscript.Install(cmd.Context(), "", force)
},
}

upgradeCmd.Flags().StringVar(&version, "version", "", "Install a specific version of Rill")
upgradeCmd.Flags().BoolVar(&nightly, "nightly", false, "Install the latest nightly build")
upgradeCmd.Flags().BoolVar(&force, "force", false, "Reinstall even if the latest version is already installed")

return upgradeCmd
}
13 changes: 9 additions & 4 deletions cli/pkg/installscript/installscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ import (
"os/exec"
)

func Install(ctx context.Context, version string) error {
return execScript(ctx, version, "--version", version)
func Install(ctx context.Context, version string, force bool) error {
var env []string
if force {
env = append(os.Environ(), "RILL_INSTALL_FORCE=1")
}
return execScript(ctx, version, env, "--version", version)
}

func Uninstall(ctx context.Context) error {
return execScript(ctx, "", "--uninstall")
return execScript(ctx, "", nil, "--uninstall")
}

func execScript(ctx context.Context, version string, args ...string) error {
func execScript(ctx context.Context, version string, env []string, args ...string) error {
script, err := createScriptFile(ctx, version)
if err != nil {
return err
Expand All @@ -26,6 +30,7 @@ func execScript(ctx context.Context, version string, args ...string) error {

scriptArgs := append([]string{script}, args...)
cmd := exec.CommandContext(ctx, "/bin/sh", scriptArgs...)
cmd.Env = env
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/developers/get-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ To ensure you're on the latest version of Rill and enjoying all of our newest fe
rill upgrade
```

If the latest version is already installed, the upgrade is skipped. To reinstall anyway, run `rill upgrade --force`, or set `RILL_INSTALL_FORCE=1` when using the installation script:
```bash
curl https://rill.sh | RILL_INSTALL_FORCE=1 sh
```

:::info What about Rill Cloud?

Rill Cloud is always on the latest stable version of Rill. To check the latest version available, please see our [Releases](https://github.com/rilldata/rill/releases) page.
Expand Down
1 change: 1 addition & 0 deletions docs/docs/reference/cli/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rill upgrade [flags]
### Flags

```
--force Reinstall even if the latest version is already installed
--nightly Install the latest nightly build
--version string Install a specific version of Rill
```
Expand Down
24 changes: 19 additions & 5 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ sha256Verify() {
# Download the binary and check the integrity using the SHA256 checksum
downloadBinary() {
CDN="cdn.rilldata.com"

LATEST_URL="https://${CDN}/rill/latest.txt"
if [ "${VERSION}" = "latest" ]; then
VERSION=$(curl --silent --show-error "${LATEST_URL}")
fi
BINARY_URL="https://${CDN}/rill/${VERSION}/rill_${PLATFORM}.zip"
CHECKSUM_URL="https://${CDN}/rill/${VERSION}/checksums.txt"

Expand All @@ -91,6 +86,24 @@ downloadBinary() {
unzip -q "rill_${PLATFORM}.zip"
}

# Resolve 'latest' to a concrete version and exit if it is already installed.
resolveLatestVersion() {
if [ "${VERSION}" != "latest" ]; then
return
fi
VERSION=$(curl --silent --show-error "https://cdn.rilldata.com/rill/latest.txt")

if [ -n "$RILL_INSTALL_FORCE" ] || ! [ -x "$INSTALL_DIR/rill" ]; then
return
fi
# Output format: 'rill version v0.90.3 (build commit: ... date: ...)'
INSTALLED_VERSION=$("$INSTALL_DIR"/rill version 2>/dev/null | cut -d' ' -f3) || true
if [ "$INSTALLED_VERSION" = "$VERSION" ]; then
printf "Rill %s is already installed. To reinstall, run 'rill upgrade --force' or set RILL_INSTALL_FORCE=1.\n" "$VERSION"
exit 0
fi
}

# Print install options
printInstallOptions() {
printf "\nWhere would you like to install rill? (Default [1])\n\n"
Expand Down Expand Up @@ -298,6 +311,7 @@ installRill() {
checkDependencies
initPlatform
resolveInstallDir
resolveLatestVersion
initTmpDir
downloadBinary
installBinary
Expand Down
Loading