Skip to content

Commit a357d47

Browse files
committed
ci: prepare for multiple versions
1 parent fcde6c2 commit a357d47

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

.github/workflows/update-version.yml

+30-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,40 @@ jobs:
2020
- name: Get the latest release
2121
id: get_release
2222
run: |
23-
latest_release=$(curl -s https://api.github.com/repos/filecoin-project/lotus/releases/latest | jq -r .tag_name)
24-
echo "latest_release=$latest_release" >> $GITHUB_OUTPUT
23+
RELEASES=$(curl -s "https://api.github.com/repos/filecoin-project/lotus/releases")
24+
25+
get_latest_release() {
26+
local TAG_PATTERN=$1
27+
local RELEASES_TAGS=$(echo "$RELEASES" | jq -r --arg pattern "$TAG_PATTERN" '
28+
.[] | select(.tag_name | test("^" + $pattern)) | select(.prerelease == false) |
29+
.tag_name
30+
')
31+
32+
if [ -z "$RELEASES_TAGS" ]; then
33+
exit 1
34+
fi
35+
36+
local LATEST_RELEASE=$(echo "$RELEASES_TAGS" | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//' | tail -n 1)
37+
38+
if [ -z "$LATEST_RELEASE" ]; then
39+
exit 1
40+
fi
41+
42+
echo "$LATEST_RELEASE"
43+
}
44+
45+
latest_lotus=$(get_latest_release "v")
46+
latest_miner=$(get_latest_release "miner/v")
47+
48+
echo "latest_lotus=$latest_lotus" >> $GITHUB_OUTPUT
49+
echo "latest_miner=$latest_miner" >> $GITHUB_OUTPUT
2550
2651
- name: Update version.json
2752
run: |
28-
jq --arg version "$LATEST_VERSION" '.lotus = $version' data/version.json > data/version.tmp && mv data/version.tmp data/version.json
53+
jq --arg lotus "$LATEST_LOTUS" --arg miner "$LATEST_MINER" '.lotus = $lotus | .miner = $miner' data/version.json > data/version.tmp && mv data/version.tmp data/version.json
2954
env:
30-
LATEST_VERSION: ${{ steps.get_release.outputs.latest_release }}
55+
LATEST_LOTUS: ${{ steps.get_release.outputs.latest_lotus }}
56+
LATEST_MINER: ${{ steps.get_release.outputs.latest_miner }}
3157

3258
- name: Check if changes exist
3359
id: git_diff

content/en/lotus/manage/lotus-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ weight: 445
1212
toc: true
1313
---
1414

15-
{{< remote-markdown "https://api.github.com/repos/filecoin-project/lotus/contents/documentation/en/cli-lotus.md" >}}
15+
{{< remote-markdown "https://api.github.com/repos/filecoin-project/lotus/contents/documentation/en/cli-lotus.md" "lotus" "v%s" >}}

content/en/storage-providers/operate/lotus-miner-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ weight: 350
1111
toc: true
1212
---
1313

14-
{{< remote-markdown "https://api.github.com/repos/filecoin-project/lotus/contents/documentation/en/cli-lotus-miner.md" >}}
14+
{{< remote-markdown "https://api.github.com/repos/filecoin-project/lotus/contents/documentation/en/cli-lotus-miner.md" "miner" "miner/v%s" >}}

data/version.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"lotus": "1.27.1",
2+
"lotus": "1.26.1",
3+
"miner": "1.26.1",
34
"go": "1.21.7"
45
}

layouts/shortcodes/remote-markdown.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{{ $baseUrl := .Get 0 }}
2-
{{ $release := .Get 1 | default (index .Site.Data.version "lotus") }}
2+
{{ $project := .Get 1 | default "lotus" -}}
3+
{{ $releaseFmt := .Get 2 | default "v%s" -}}
34

4-
{{ $url := printf "%s?ref=release/v%s" $baseUrl $release }}
5+
{{ $releaseValue := index .Site.Data.version $project }}
6+
{{ $releaseName := printf $releaseFmt $releaseValue }}
7+
8+
{{ $url := printf "%s?ref=release/%s" $baseUrl $releaseName }}
59

610
{{ $response := getJSON $url }}
711
{{ $content := $response.content | base64Decode }}

0 commit comments

Comments
 (0)