From 1cc23042963f6ebba574438ec73f7e18d39de24f Mon Sep 17 00:00:00 2001
From: Christian Nunciato
Date: Tue, 10 Oct 2023 02:42:57 -0700
Subject: [PATCH] Add ESC CLI version shortcode
---
static/esc/latest-version | 1 +
themes/default/content/docs/install/esc.md | 26 +++++++++----------
.../shortcodes/latest-version-esc.html | 7 +++++
3 files changed, 21 insertions(+), 13 deletions(-)
create mode 100644 static/esc/latest-version
create mode 100644 themes/default/layouts/shortcodes/latest-version-esc.html
diff --git a/static/esc/latest-version b/static/esc/latest-version
new file mode 100644
index 00000000000..5d4294b9120
--- /dev/null
+++ b/static/esc/latest-version
@@ -0,0 +1 @@
+0.5.1
\ No newline at end of file
diff --git a/themes/default/content/docs/install/esc.md b/themes/default/content/docs/install/esc.md
index dbbf7fdffe4..9a3e0711d4b 100644
--- a/themes/default/content/docs/install/esc.md
+++ b/themes/default/content/docs/install/esc.md
@@ -27,12 +27,12 @@ $ brew install pulumi/tap/esc
### MacOS binary download
-amd64
-arm64
+amd64
+arm64
macOS Sierra (10.12) or later is required.
-The latest version of Pulumi ESC is 0.5.1.
+The latest version of Pulumi ESC is {{< latest-version-esc >}}.
{{% notes type="info" %}}
For a streamlined Pulumi ESC walkthrough, including language runtime installation and cloud configuration, see the [Get Started](/docs/pulumi-cloud/esc/getting-started) guides.
@@ -132,7 +132,7 @@ The installer script can be rerun to subsequently install new updates.
If you do not wish to use the previous options, you can install Pulumi manually.
-1. Download [Pulumi ESC 0.5.1 for macOS](https://get.pulumi.com/esc/releases/esc-v0.5.1-darwin-x64.tar.gz).
+1. Download [Pulumi ESC {{< latest-version-esc >}} for macOS](https://get.pulumi.com/esc/releases/esc-v{{< latest-version-esc >}}-darwin-x64.tar.gz).
1. Extract the tarball and move the binaries in the `esc` directory to a directory included in your system's `$PATH`.
@@ -155,11 +155,11 @@ $ curl -fsSL https://get.pulumi.com/esc/install.sh | sh
-The latest version of Pulumi ESC is 0.5.1.
+The latest version of Pulumi ESC is {{< latest-version-esc >}}.
{{< get-started-note >}}
@@ -205,7 +205,7 @@ See [How to permanently set $PATH on Unix](https://stackoverflow.com/questions/1
Alternatively, you can install Pulumi ESC manually. We provide a prebuilt binary for Linux.
-1. Download [Pulumi ESC 0.5.1 for Linux x64](https://get.pulumi.com/esc/releases/esc-v0.5.1-linux-x64.tar.gz).
+1. Download [Pulumi ESC {{< latest-version-esc >}} for Linux x64](https://get.pulumi.com/esc/releases/esc-v{{< latest-version-esc >}}-linux-x64.tar.gz).
1. Extract the tarball and move the binaries in the `esc` directory to a directory included in your system's `$PATH`.
@@ -221,14 +221,14 @@ Alternatively, you can install Pulumi ESC manually. We provide a prebuilt binary
Windows 8 and later are supported.
-The latest version of Pulumi ESC is 0.5.1. For older versions, see [Available Versions](/docs/install/versions/).
+The latest version of Pulumi ESC is {{< latest-version-esc >}}. For older versions, see [Available Versions](/docs/install/versions/).
{{< get-started-note >}}
@@ -274,7 +274,7 @@ This will install the `esc.exe` CLI to `%USERPROFILE%\.pulumi\bin` and add it to
Alternatively, you can install Pulumi ESC manually using binaries built for Windows x64.
-1. Download [Pulumi ESC 0.5.1 binaries for Windows x64](https://get.pulumi.com/esc/releases/esc-v0.5.1-windows-x64.zip). For prior versions and release notes, see the [Available Versions](/docs/install/versions/) page.
+1. Download [Pulumi ESC {{< latest-version-esc >}} binaries for Windows x64](https://get.pulumi.com/esc/releases/esc-v{{< latest-version-esc >}}-windows-x64.zip). For prior versions and release notes, see the [Available Versions](/docs/install/versions/) page.
1. Unzip the file and extract the contents to a folder such as `C:\esc`.
@@ -298,7 +298,7 @@ After installing Pulumi ESC, verify everything is in working order by running th
```bash
$ esc version
-v0.5.1
+v{{< latest-version-esc >}}
```
{{% /choosable %}}
@@ -307,7 +307,7 @@ v0.5.1
```bash
$ esc version
-v0.5.1
+v{{< latest-version-esc >}}
```
{{% /choosable %}}
@@ -316,7 +316,7 @@ v0.5.1
```bash
> esc version
-v0.5.1
+v{{< latest-version-esc >}}
```
{{% /choosable %}}
diff --git a/themes/default/layouts/shortcodes/latest-version-esc.html b/themes/default/layouts/shortcodes/latest-version-esc.html
new file mode 100644
index 00000000000..422892c2d5f
--- /dev/null
+++ b/themes/default/layouts/shortcodes/latest-version-esc.html
@@ -0,0 +1,7 @@
+{{- $latestVersionFile := "/static/esc/latest-version" -}}
+{{- $latestVersion := readFile $latestVersionFile -}}
+{{/* The file must not contain whitespace or newlines, as dependencies may not be resilient. */}}
+{{- if gt (len (findRE "\\s" $latestVersion)) 0 -}}
+ {{- errorf "%q must not contain whitespace or newlines" $latestVersionFile -}}
+{{- end -}}
+{{- $latestVersion -}}