|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This script updates `index.md` in the GitHub Pages root directory provided |
| 4 | +# by the required argument to be passed. The file will be updated to simply |
| 5 | +# render the `resolc-bin` JSON data for each of the supported platforms. |
| 6 | +# `index.md` is the file served by GitHub Pages after being built by Jekyll |
| 7 | +# and the Markdown processed by kramdown. |
| 8 | + |
| 9 | +set -exo pipefail |
| 10 | + |
| 11 | +gh_pages_root_dir="$1" |
| 12 | +if [ -z "$gh_pages_root_dir" ]; then |
| 13 | + echo "Error: The path to the GitHub Pages root directory must be passed" |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | + |
| 17 | +linux="$gh_pages_root_dir/linux/list.json" |
| 18 | +macos="$gh_pages_root_dir/macos/list.json" |
| 19 | +wasm="$gh_pages_root_dir/wasm/list.json" |
| 20 | +windows="$gh_pages_root_dir/windows/list.json" |
| 21 | +nightly_linux="$gh_pages_root_dir/nightly/linux/list.json" |
| 22 | +nightly_macos="$gh_pages_root_dir/nightly/macos/list.json" |
| 23 | +nightly_wasm="$gh_pages_root_dir/nightly/wasm/list.json" |
| 24 | +nightly_windows="$gh_pages_root_dir/nightly/windows/list.json" |
| 25 | + |
| 26 | +build_info_files=("$linux" "$macos" "$wasm" "$windows" "$nightly_linux" |
| 27 | + "$nightly_macos" "$nightly_wasm" "$nightly_windows") |
| 28 | + |
| 29 | +for file in "${build_info_files[@]}"; do |
| 30 | + if [ ! -f "$file" ]; then |
| 31 | + echo "Error: File does not exist - $file" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | +done |
| 35 | + |
| 36 | +# Sort the data by version in descending order. |
| 37 | +sort_by_version_descending() { |
| 38 | + local build_info_file="$1" |
| 39 | + if [ -z "$build_info_file" ]; then |
| 40 | + echo "Error: A file path argument is required for sorting" |
| 41 | + return 1 |
| 42 | + fi |
| 43 | + |
| 44 | + # Load the data and sort builds and releases with the latest version first. |
| 45 | + data=$(jq '.' "$build_info_file") |
| 46 | + sorted_data=$(echo "$data" | jq '.builds = (.builds | sort_by(.version) | reverse) | |
| 47 | + .releases = (.releases | to_entries | sort_by(.key) | reverse | from_entries)') |
| 48 | + |
| 49 | + echo "$sorted_data" | jq . |
| 50 | +} |
| 51 | + |
| 52 | +echo "Updating GitHub Pages index.md file..." |
| 53 | + |
| 54 | +cat > "$gh_pages_root_dir/index.md" << EOF |
| 55 | +--- |
| 56 | +title: resolc-bin |
| 57 | +--- |
| 58 | +
|
| 59 | +# resolc-bin |
| 60 | +
|
| 61 | +Listed here are details about the \`resolc\` binary releases for the supported platforms. |
| 62 | +The information is synced with the [resolc-bin GitHub repository](https://github.com/paritytech/resolc-bin). |
| 63 | +
|
| 64 | +## Linux |
| 65 | +
|
| 66 | +<details> |
| 67 | + <summary>See builds</summary> |
| 68 | +
|
| 69 | +{% highlight json %} |
| 70 | +$(sort_by_version_descending $linux) |
| 71 | +{% endhighlight %} |
| 72 | +
|
| 73 | +</details> |
| 74 | +
|
| 75 | +## MacOS |
| 76 | +
|
| 77 | +<details> |
| 78 | + <summary>See builds</summary> |
| 79 | +
|
| 80 | +{% highlight json %} |
| 81 | +$(sort_by_version_descending $macos) |
| 82 | +{% endhighlight %} |
| 83 | +
|
| 84 | +</details> |
| 85 | +
|
| 86 | +## Wasm |
| 87 | +
|
| 88 | +<details> |
| 89 | + <summary>See builds</summary> |
| 90 | +
|
| 91 | +{% highlight json %} |
| 92 | +$(sort_by_version_descending $wasm) |
| 93 | +{% endhighlight %} |
| 94 | +
|
| 95 | +</details> |
| 96 | +
|
| 97 | +## Windows |
| 98 | +
|
| 99 | +<details> |
| 100 | + <summary>See builds</summary> |
| 101 | +
|
| 102 | +{% highlight json %} |
| 103 | +$(sort_by_version_descending $windows) |
| 104 | +{% endhighlight %} |
| 105 | +
|
| 106 | +</details> |
| 107 | +
|
| 108 | +## Nightly |
| 109 | +
|
| 110 | +### Linux |
| 111 | +
|
| 112 | +<details> |
| 113 | + <summary>See builds</summary> |
| 114 | +
|
| 115 | +{% highlight json %} |
| 116 | +$(sort_by_version_descending $nightly_linux) |
| 117 | +{% endhighlight %} |
| 118 | +
|
| 119 | +</details> |
| 120 | +
|
| 121 | +### MacOS |
| 122 | +
|
| 123 | +<details> |
| 124 | + <summary>See builds</summary> |
| 125 | +
|
| 126 | +{% highlight json %} |
| 127 | +$(sort_by_version_descending $nightly_macos) |
| 128 | +{% endhighlight %} |
| 129 | +
|
| 130 | +</details> |
| 131 | +
|
| 132 | +### Wasm |
| 133 | +
|
| 134 | +<details> |
| 135 | + <summary>See builds</summary> |
| 136 | +
|
| 137 | +{% highlight json %} |
| 138 | +$(sort_by_version_descending $nightly_wasm) |
| 139 | +{% endhighlight %} |
| 140 | +
|
| 141 | +</details> |
| 142 | +
|
| 143 | +### Windows |
| 144 | +
|
| 145 | +<details> |
| 146 | + <summary>See builds</summary> |
| 147 | +
|
| 148 | +{% highlight json %} |
| 149 | +$(sort_by_version_descending $nightly_windows) |
| 150 | +{% endhighlight %} |
| 151 | +
|
| 152 | +</details> |
| 153 | +EOF |
| 154 | + |
| 155 | +echo "File has been updated!" |
0 commit comments