Repository navigation
139 lines (118 loc) · 4.82 KB
/
Copy pathdocs-cli-help.yml
File metadata and controls
139 lines (118 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Generate Sui CLI Help Snippets
on:
workflow_dispatch: {}
schedule:
- cron: "0 8 * * *" # nightly 08:00 UTC
permissions:
contents: write
concurrency:
group: sui-help
cancel-in-progress: false
jobs:
build-help:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Determine latest Sui release tag
id: release
run: |
TAG=$(curl -s https://api.github.com/repos/MystenLabs/sui/releases \
| jq -r 'map(select(.tag_name | startswith("testnet-")))[0].tag_name')
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Restore cached Sui binary
id: cache
uses: actions/cache@v4
with:
path: .cache/sui/${{ steps.release.outputs.tag }}/sui
key: sui-${{ runner.os }}-${{ steps.release.outputs.tag }}
- name: Download Sui CLI if cache miss
if: steps.cache.outputs.cache-hit != 'true'
run: |
set -euo pipefail
TAG="${{ steps.release.outputs.tag }}"
mkdir -p ".cache/sui/${TAG}"
# Try different possible asset names
ASSETS=(
"sui-mainnet-v${TAG#testnet-v}-ubuntu-x86_64.tgz"
"sui-testnet-v${TAG#testnet-v}-ubuntu-x86_64.tgz"
"sui-${TAG}-ubuntu-x86_64.tgz"
"sui-linux-x86_64"
)
DOWNLOADED=false
for ASSET in "${ASSETS[@]}"; do
URL="https://github.com/MystenLabs/sui/releases/download/${TAG}/${ASSET}"
echo "Trying: $URL"
if curl -fsSL -o "/tmp/sui-download" "$URL" 2>/dev/null; then
echo "Successfully downloaded: $ASSET"
# Check if it's a tarball
if [[ "$ASSET" == *.tgz ]]; then
tar -xzf /tmp/sui-download -C ".cache/sui/${TAG}/"
# Find the sui binary in extracted files
find ".cache/sui/${TAG}/" -name "sui" -type f -executable -exec mv {} ".cache/sui/${TAG}/sui" \;
else
mv /tmp/sui-download ".cache/sui/${TAG}/sui"
fi
chmod +x ".cache/sui/${TAG}/sui"
DOWNLOADED=true
break
fi
done
if [ "$DOWNLOADED" = false ]; then
echo "Failed to download sui binary from any known location"
echo "Available assets for ${TAG}:"
curl -s "https://api.github.com/repos/MystenLabs/sui/releases/tags/${TAG}" | jq -r '.assets[].name'
exit 1
fi
# Verify it's actually a binary
if ! file ".cache/sui/${TAG}/sui" | grep -q "executable"; then
echo "Downloaded file is not an executable:"
file ".cache/sui/${TAG}/sui"
head -n 5 ".cache/sui/${TAG}/sui"
exit 1
fi
- name: Generate MDX snippets (sh fenced)
run: |
set -euo pipefail
TAG="${{ steps.release.outputs.tag }}"
BIN=".cache/sui/${TAG}/sui"
OUT_DIR="docs/content/snippets/console-output"
mkdir -p "$OUT_DIR"
gen() { # gen <filename> <command...>
local file="$1"; shift
{ echo '```sh'; "$BIN" "$@"; echo '```'; } > "$OUT_DIR/$file"
echo " - $OUT_DIR/$file"
}
echo "Generating help snippets from $BIN"
gen "sui-help.mdx" --help
gen "sui-client-help.mdx" client --help
gen "sui-client-call-help.mdx" client call --help
gen "sui-client-ptb-help.mdx" client ptb --help
gen "sui-replay-help.mdx" replay --help
gen "sui-keytool-sign-help.mdx" keytool sign --help
gen "sui-keytool-help.mdx" keytool --help
gen "sui-move-help.mdx" move --help
gen "sui-move-build-help.mdx" move build --help
gen "sui-validator-help.mdx" validator --help
gen "sui-validator-report-validator-help.mdx" validator report-validator --help
- name: Diff guard
id: diff
run: |
if git diff --quiet docs/content/snippets/console-output/; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes detected."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Changes detected."
fi
- name: Commit & push changes
if: steps.diff.outputs.changed == 'true'
run: |
set -e
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add docs/content/snippets/console-output/*.mdx
git commit -m "chore(ci): update Sui CLI help snippets (${{ steps.release.outputs.tag }})"
git push