-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (149 loc) · 5.81 KB
/
update-version-table.yml
File metadata and controls
174 lines (149 loc) · 5.81 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This workflow is always run from main.
# Automated trigger: beamable/BeamableProduct fires a repository_dispatch
# event (type: unity-sdk-released) when a unity-sdk-X.Y.Z release tag is
# pushed. Use workflow_dispatch below for manual runs and testing.
name: Update SDK/CLI Version Table
on:
repository_dispatch:
types: [unity-sdk-released]
workflow_dispatch:
inputs:
_note:
description: >
Manual trigger. Normally fired automatically by beamable/BeamableProduct
on unity-sdk-X.Y.Z release tag pushes. Always run from main.
required: false
default: ''
jobs:
update:
name: Update table on ${{ matrix.branch }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
strategy:
matrix:
branch: [unity/v5.0, unity/v5.1]
concurrency:
group: update-version-table-${{ matrix.branch }}
cancel-in-progress: false
steps:
- name: Checkout ${{ matrix.branch }}
uses: actions/checkout@v6
with:
ref: ${{ matrix.branch }}
token: ${{ secrets.DOCS_PAT }}
- name: Extract branch minor version
id: branch
run: |
BRANCH="${{ matrix.branch }}"
echo "minor=${BRANCH#unity/v}" >> $GITHUB_OUTPUT
- name: Build full version table from BeamableProduct tags
env:
GH_TOKEN: ${{ github.token }}
run: |
# Fetch all release tags (exclude PREVIEW and RC builds), newest first
gh api repos/beamable/BeamableProduct/tags \
--paginate \
--jq '.[].name' \
| grep -E '^unity-sdk-[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -V -r \
> /tmp/release-tags.txt
echo "Release tags found:"
cat /tmp/release-tags.txt
# Fetch the CLI version pinned at each tag
> /tmp/table-rows.txt
while IFS= read -r tag; do
sdk_version="${tag#unity-sdk-}"
cli_version=$(gh api \
"repos/beamable/BeamableProduct/contents/client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json?ref=${tag}" \
--jq '.content' | base64 -d | jq -r '.nugetPackageVersion')
echo "| ${sdk_version} | ${cli_version} |" >> /tmp/table-rows.txt
done < /tmp/release-tags.txt
echo "Generated table rows:"
cat /tmp/table-rows.txt
- name: Build condensed table
env:
CURRENT_MINOR: ${{ steps.branch.outputs.minor }}
run: |
python3 - <<'EOF'
import os, pathlib
current_minor = os.environ["CURRENT_MINOR"]
seen_minors = set()
condensed = []
for line in pathlib.Path("/tmp/table-rows.txt").read_text().splitlines(keepends=True):
parts = line.strip().split("|")
if len(parts) < 3:
continue
sdk_version = parts[1].strip()
major_minor = ".".join(sdk_version.split(".")[:2])
if major_minor == current_minor:
condensed.append(line)
elif major_minor not in seen_minors:
seen_minors.add(major_minor)
condensed.append(line)
pathlib.Path("/tmp/condensed-rows.txt").write_text("".join(condensed))
EOF
- name: Update installing-beamable.md
run: |
python3 - <<'EOF'
import re, pathlib
md = pathlib.Path("docs/unity/getting-started/installing-beamable.md")
rows = pathlib.Path("/tmp/condensed-rows.txt").read_text().rstrip("\n")
new_table = (
"| SDK Version | CLI Version |\n"
"| :---------- | :---------- |\n"
+ rows
)
text = md.read_text()
updated = re.sub(
r'\| SDK Version \| CLI Version \|.*?(?=\n\n)',
new_table,
text,
flags=re.DOTALL
)
if updated == text:
print("Table unchanged — no edit needed.")
else:
md.write_text(updated)
print("Table updated.")
EOF
- name: Write sdk-cli-version-history.md
run: |
python3 - <<'EOF'
import pathlib
rows = pathlib.Path("/tmp/table-rows.txt").read_text().rstrip("\n")
full_table = (
"| SDK Version | CLI Version |\n"
"| :---------- | :---------- |\n"
+ rows
)
content = (
"# SDK/CLI Version History\n"
"\n"
"Every Beamable Unity SDK release and the Beam CLI version it requires.\n"
"\n"
"For installation instructions and a summary of current versions,\n"
"see [Installing Beamable](./installing-beamable.md).\n"
"\n"
+ full_table
+ "\n"
)
pathlib.Path("docs/unity/getting-started/sdk-cli-version-history.md").write_text(content)
print("Version history page written.")
EOF
- name: Commit and push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git ls-files --others --exclude-standard docs/unity/getting-started/sdk-cli-version-history.md | grep -q .; then
git add docs/unity/getting-started/sdk-cli-version-history.md
fi
git add docs/unity/getting-started/installing-beamable.md \
docs/unity/getting-started/sdk-cli-version-history.md 2>/dev/null || true
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "Update SDK/CLI version table and history page"
git push
fi