From e93a9b4cad9caa693d75971c8b0f85ea30cb8f7a Mon Sep 17 00:00:00 2001
From: Timo Furrer <tfurrer@gitlab.com>
Date: Tue, 16 Jan 2024 17:36:42 +0100
Subject: [PATCH] Generate available OpenTofu versions into README

---
 Makefile  | 9 +++++++--
 README.md | 7 +++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 2174b57..43a144d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,14 @@
 docs:
 	csplit -sf readme -n 1 .gitlab/README.md '/<INPUTS>/'
-	yq '.spec.inputs | .[] | "| `" + key + "` | `" + .default + "` | " + .description + (.options | (" Must be one of " + (. | map("`" + . + "`")| join(", ") + "." )) // "") + " |"' templates/full-pipeline.yml > readme_inputs.md
 	echo '<!-- This document is generated by `make docs` from `.gitlab/README.md` -->' > README.md
 	echo >> README.md
 	cat readme0 >> README.md
-	cat readme_inputs.md >> README.md
+	yq '.spec.inputs | .[] | "| `" + key + "` | `" + .default + "` | " + .description + (.options | (" Must be one of " + (. | map("`" + . + "`")| join(", ") + "." )) // "") + " |"' templates/full-pipeline.yml >> README.md
+	echo >> README.md
+	echo '### Available OpenTofu Versions' >> README.md
+	echo >> README.md
+	echo 'The following OpenTofu versions are available with this component via the `opentofu_version` input:' >> README.md
+	echo >> README.md
+	yq -r '.spec.inputs.opentofu_version.options | .[] | "- [`" + . + "`](https://github.com/opentofu/opentofu/releases/tag/v" + . + ")"' templates/full-pipeline.yml >> README.md
 	tail -n+2 readme1 >> README.md
 	rm -f readme0 readme1 readme_inputs.md
diff --git a/README.md b/README.md
index a5d5d06..9643171 100644
--- a/README.md
+++ b/README.md
@@ -83,6 +83,13 @@ stages: [validate, test, build, deploy, cleanup]
 | `auto_apply` | `false` | Whether the apply job is manual or automatically run. |
 | `auto_destroy` | `false` | Whether the destroy job is manual or automatically run. |
 
+### Available OpenTofu Versions
+
+The following OpenTofu versions are available with this component via the `opentofu_version` input:
+
+- [`1.6.0`](https://github.com/opentofu/opentofu/releases/tag/v1.6.0)
+- [`1.6.0-rc1`](https://github.com/opentofu/opentofu/releases/tag/v1.6.0-rc1)
+
 ## Releases & Versioning
 
 This project currently releases tagged commits. 
-- 
GitLab