|
| 1 | +#!/usr/bin/env bash |
| 2 | +# .github/scripts/generate-versions-page.sh |
| 3 | +# |
| 4 | +# Generates the Tool Versions documentation page for devrail.dev. |
| 5 | +# Fetches tool-versions.json release assets from the dev-toolchain repo |
| 6 | +# and outputs a complete Hugo markdown page to stdout. |
| 7 | +# |
| 8 | +# Usage: bash .github/scripts/generate-versions-page.sh |
| 9 | +# Requires: gh (GitHub CLI), jq, curl |
| 10 | +# Environment: GH_TOKEN must be set (provided by GitHub Actions) |
| 11 | + |
| 12 | +set -euo pipefail |
| 13 | + |
| 14 | +REPO="devrail-dev/dev-toolchain" |
| 15 | + |
| 16 | +# --- Helpers --- |
| 17 | + |
| 18 | +render_table() { |
| 19 | + local json="$1" |
| 20 | + echo "| Tool | Version |" |
| 21 | + echo "|---|---|" |
| 22 | + echo "${json}" | jq -r '.tools | to_entries | sort_by(.key) | .[] | "| \(.key) | \(.value) |"' |
| 23 | +} |
| 24 | + |
| 25 | +# --- Frontmatter and intro --- |
| 26 | + |
| 27 | +cat <<'FRONTMATTER' |
| 28 | +--- |
| 29 | +title: "Tool Versions" |
| 30 | +linkTitle: "Tool Versions" |
| 31 | +weight: 10 |
| 32 | +description: "Tool versions included in each dev-toolchain container release." |
| 33 | +--- |
| 34 | +
|
| 35 | +<!-- This page is generated automatically by .github/workflows/update-tool-versions.yml --> |
| 36 | +<!-- Do not edit manually — changes will be overwritten on the next scheduled run. --> |
| 37 | +
|
| 38 | +This page shows the exact tool versions shipped in each release of the |
| 39 | +[dev-toolchain container](/docs/container/). It is updated automatically |
| 40 | +when new releases are published. |
| 41 | +
|
| 42 | +FRONTMATTER |
| 43 | + |
| 44 | +# --- Fetch releases --- |
| 45 | +# gh api returns newest first by default. Select non-draft releases and |
| 46 | +# extract tag, date, and the tool-versions.json asset download URL. |
| 47 | + |
| 48 | +releases=$(gh api "repos/${REPO}/releases" --paginate --jq ' |
| 49 | + .[] | select(.draft == false) | |
| 50 | + { |
| 51 | + tag: .tag_name, |
| 52 | + date: (.published_at | split("T")[0]), |
| 53 | + asset_url: ( |
| 54 | + [.assets[] | select(.name == "tool-versions.json") | .url] | first // null |
| 55 | + ) |
| 56 | + } |
| 57 | +') |
| 58 | + |
| 59 | +# --- Render page --- |
| 60 | + |
| 61 | +first=true |
| 62 | +has_previous=false |
| 63 | + |
| 64 | +while IFS= read -r release; do |
| 65 | + tag=$(echo "${release}" | jq -r '.tag') |
| 66 | + date=$(echo "${release}" | jq -r '.date') |
| 67 | + asset_url=$(echo "${release}" | jq -r '.asset_url') |
| 68 | + |
| 69 | + # Skip releases without a tool-versions.json asset |
| 70 | + if [[ "${asset_url}" == "null" ]]; then |
| 71 | + continue |
| 72 | + fi |
| 73 | + |
| 74 | + # Download the asset via the GitHub API (works for public and private repos) |
| 75 | + versions_json=$(gh api "${asset_url}" --jq '.' 2>/dev/null) || continue |
| 76 | + |
| 77 | + if ${first}; then |
| 78 | + echo "## Latest Release: ${tag}" |
| 79 | + echo "" |
| 80 | + echo "Released ${date}." |
| 81 | + echo "" |
| 82 | + render_table "${versions_json}" |
| 83 | + echo "" |
| 84 | + first=false |
| 85 | + else |
| 86 | + if ! ${has_previous}; then |
| 87 | + echo "## Previous Releases" |
| 88 | + echo "" |
| 89 | + has_previous=true |
| 90 | + fi |
| 91 | + echo "<details>" |
| 92 | + echo "<summary><strong>${tag}</strong> (${date})</summary>" |
| 93 | + echo "" |
| 94 | + render_table "${versions_json}" |
| 95 | + echo "" |
| 96 | + echo "</details>" |
| 97 | + echo "" |
| 98 | + fi |
| 99 | +done <<< "${releases}" |
| 100 | + |
| 101 | +# Fallback if no releases have the asset yet |
| 102 | +if ${first}; then |
| 103 | + echo "No releases with tool version manifests are available yet." |
| 104 | + echo "Version data will appear here after the next dev-toolchain release." |
| 105 | +fi |
0 commit comments