Skip to content

Commit 332e82e

Browse files
committed
👷 auto update j gha
1 parent 2282def commit 332e82e

4 files changed

Lines changed: 154 additions & 5 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Auto-update J
2+
3+
# Builds J WASM from https://github.com/jsoftware/jsource via
4+
# scripts/build-j-wasm.sh (Docker + Emscripten) and opens a PR with the
5+
# updated wasm/j/* artifacts and bumped scripts/known-versions.json.
6+
# Triggered automatically by check-language-updates.yml when version.txt
7+
# on master reports a new jversion.
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
j_version:
13+
description: 'New J version (e.g. 9.8.0-beta1) to record in known-versions.json'
14+
required: true
15+
type: string
16+
issue_number:
17+
description: 'Optional issue number to close from the PR (leave blank for none)'
18+
required: false
19+
default: ''
20+
type: string
21+
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
issues: write
26+
27+
concurrency:
28+
group: auto-update-j
29+
cancel-in-progress: false
30+
31+
jobs:
32+
build-and-pr:
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 90 # Docker pull + GMP + libj.a + emj link is heavy
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
# Docker is preinstalled on ubuntu-latest; nothing to set up.
39+
- name: Show Docker info
40+
run: docker --version
41+
42+
- name: Build J WASM
43+
run: bash scripts/build-j-wasm.sh
44+
45+
- name: Update known-versions.json and display strings
46+
env:
47+
J_VERSION: ${{ inputs.j_version }}
48+
run: |
49+
# known-versions.json stores the raw jversion string (e.g. 9.8.0-beta1).
50+
tmp=$(mktemp)
51+
jq --arg v "$J_VERSION" '.j = $v' scripts/known-versions.json > "$tmp"
52+
mv "$tmp" scripts/known-versions.json
53+
echo "--- updated known-versions.json ---"
54+
cat scripts/known-versions.json
55+
56+
# User-facing displays render with a J prefix (e.g. J9.8.0-beta1).
57+
# Replace from the J prefix up to the closing tag/quote, so we don't
58+
# have to know the previous version's exact format.
59+
J_DISPLAY="J${J_VERSION}"
60+
echo "Display version: $J_DISPLAY"
61+
62+
# index.html: scoped to the data-lang="j" dropdown item only.
63+
sed -i -E "/data-lang=\"j\"/,/<\/div>/ s|(<span class=\"lang-version\">)J[^<]*(</span>)|\1${J_DISPLAY}\2|" index.html
64+
65+
# generate-og-languages.cjs: only the J row.
66+
sed -i -E "s|(name: 'J',[[:space:]]+version: ')J[^']*(')|\1${J_DISPLAY}\2|" scripts/generate-og-languages.cjs
67+
68+
echo "--- index.html (J dropdown) ---"
69+
grep -A3 'data-lang="j"' index.html | head -5
70+
echo "--- generate-og-languages.cjs (J row) ---"
71+
grep "name: 'J'" scripts/generate-og-languages.cjs
72+
73+
- name: Compose PR body
74+
id: body
75+
env:
76+
J_VERSION: ${{ inputs.j_version }}
77+
ISSUE_NUMBER: ${{ inputs.issue_number }}
78+
run: |
79+
{
80+
echo "Auto-generated by \`.github/workflows/auto-update-j.yml\`."
81+
echo ""
82+
echo "- Rebuilt \`wasm/j/emj.js\`, \`wasm/j/emj.wasm\`, and \`wasm/j/emj.data\` via \`scripts/build-j-wasm.sh\` (Docker + Emscripten)."
83+
echo "- Bumped \`scripts/known-versions.json\` J entry to \`${J_VERSION}\`."
84+
echo "- Synced display strings in \`index.html\` and \`scripts/generate-og-languages.cjs\` to \`J${J_VERSION}\`."
85+
echo ""
86+
echo "Source: https://github.com/jsoftware/jsource (master)"
87+
if [ -n "$ISSUE_NUMBER" ]; then
88+
echo ""
89+
echo "Closes #${ISSUE_NUMBER}"
90+
fi
91+
} > pr-body.md
92+
echo "wrote pr-body.md ($(wc -c < pr-body.md) bytes)"
93+
{
94+
echo 'body<<__EOF__'
95+
cat pr-body.md
96+
echo '__EOF__'
97+
} >> "$GITHUB_OUTPUT"
98+
99+
- name: Open pull request
100+
uses: peter-evans/create-pull-request@v7
101+
with:
102+
branch: auto/update-j-${{ inputs.j_version }}
103+
delete-branch: true
104+
commit-message: "Update J to ${{ inputs.j_version }}"
105+
title: "Update J to ${{ inputs.j_version }}"
106+
body: ${{ steps.body.outputs.body }}
107+
labels: language-update
108+
assignees: codereport
109+
add-paths: |
110+
wasm/j
111+
scripts/known-versions.json
112+
scripts/generate-og-languages.cjs
113+
index.html

.github/workflows/check-language-updates.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ jobs:
4343
echo "kap_updated=false" >> "$GITHUB_OUTPUT"
4444
fi
4545
46+
- name: Detect J-specific update
47+
id: j
48+
if: steps.check.outcome == 'failure'
49+
run: |
50+
if [ ! -f update-report.md ]; then
51+
echo "j_updated=false" >> "$GITHUB_OUTPUT"
52+
exit 0
53+
fi
54+
new_version=$(grep -E '^- \*\*J\*\*' update-report.md \
55+
| grep -oP '`\K[^`]+(?=`[^`]*$)' || true)
56+
if [ -n "$new_version" ]; then
57+
echo "J update detected: $new_version"
58+
echo "j_version=$new_version" >> "$GITHUB_OUTPUT"
59+
echo "j_updated=true" >> "$GITHUB_OUTPUT"
60+
else
61+
echo "No J update in this run."
62+
echo "j_updated=false" >> "$GITHUB_OUTPUT"
63+
fi
64+
4665
- name: Find or create language-update issue
4766
id: issue
4867
if: steps.check.outcome == 'failure'
@@ -89,3 +108,15 @@ jobs:
89108
gh workflow run auto-update-kap.yml \
90109
-f kap_version="$KAP_VERSION" \
91110
-f issue_number="$ISSUE_NUMBER"
111+
112+
- name: Trigger auto-update-j workflow
113+
if: steps.j.outputs.j_updated == 'true' && steps.issue.outputs.issue_number != ''
114+
env:
115+
GH_TOKEN: ${{ github.token }}
116+
J_VERSION: ${{ steps.j.outputs.j_version }}
117+
ISSUE_NUMBER: ${{ steps.issue.outputs.issue_number }}
118+
run: |
119+
echo "Dispatching auto-update-j.yml (j_version=$J_VERSION, issue=#$ISSUE_NUMBER)"
120+
gh workflow run auto-update-j.yml \
121+
-f j_version="$J_VERSION" \
122+
-f issue_number="$ISSUE_NUMBER"

scripts/check-language-updates.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Sources:
88
# CBQN – latest GitHub tag (dzaima/CBQN)
99
# Uiua – Cargo.toml version from uiua-lang/uiua "latest" tag (= uiua.org/pad)
10-
# J – latest GitHub release (jsoftware/jsource)
10+
# J – jsoftware/jsource master version.txt (#define jversion)
1111
# Kap – kapdemo.dhsdevelopments.com/downloads.html
1212
# TinyAPL – beta.tinyapl.rubenverg.com/run version selector
1313
#
@@ -81,13 +81,18 @@ else
8181
fi
8282

8383
# ── J ─────────────────────────────────────────────────────────
84-
echo "J (github.com/jsoftware/jsource releases)"
84+
echo "J (github.com/jsoftware/jsource version.txt)"
8585
known=$(read_known j)
86-
latest_j=$(gh api repos/jsoftware/jsource/releases/latest --jq '.tag_name' 2>/dev/null || true)
86+
# version.txt on master is the source of truth — jsource bumps it whenever
87+
# they cut a build. GitHub release tags lag and use a different scheme.
88+
latest_j=$(curl -sfL --max-time 10 \
89+
"https://raw.githubusercontent.com/jsoftware/jsource/master/version.txt" 2>/dev/null \
90+
| grep -oP '#define jversion "\K[^"]+' \
91+
| head -1 || true)
8792
if $snapshot_mode; then
8893
echo " Current: ${latest_j:-FETCH_FAILED}"
8994
else
90-
compare "J" "$known" "$latest_j" "github.com/jsoftware/jsource/releases"
95+
compare "J" "$known" "$latest_j" "github.com/jsoftware/jsource version.txt"
9196
fi
9297

9398
# ── Kap ───────────────────────────────────────────────────────

scripts/known-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"cbqn": "v0.11.0",
33
"uiua": "0.19.0-dev.2",
4-
"j": "build96",
4+
"j": "9.7.0-beta10",
55
"kap": "20260425-1",
66
"tinyapl": "0.12.0"
77
}

0 commit comments

Comments
 (0)