Auto-update J #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-update J | |
| # Builds J WASM from https://github.com/jsoftware/jsource via | |
| # scripts/build-j-wasm.sh (Docker + Emscripten) and opens a PR with the | |
| # updated wasm/j/* artifacts and bumped scripts/known-versions.json. | |
| # Triggered automatically by check-language-updates.yml when version.txt | |
| # on master reports a new jversion. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| j_version: | |
| description: 'New J version (e.g. 9.8.0-beta1) to record in known-versions.json' | |
| required: true | |
| type: string | |
| issue_number: | |
| description: 'Optional issue number to close from the PR (leave blank for none)' | |
| required: false | |
| default: '' | |
| type: string | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| concurrency: | |
| group: auto-update-j | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-pr: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 90 # Docker pull + GMP + libj.a + emj link is heavy | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Docker is preinstalled on ubuntu-latest; nothing to set up. | |
| - name: Show Docker info | |
| run: docker --version | |
| - name: Build J WASM | |
| run: bash scripts/build-j-wasm.sh | |
| - name: Update known-versions.json and display strings | |
| env: | |
| J_VERSION: ${{ inputs.j_version }} | |
| run: | | |
| # known-versions.json stores the raw jversion string (e.g. 9.8.0-beta1). | |
| tmp=$(mktemp) | |
| jq --arg v "$J_VERSION" '.j = $v' scripts/known-versions.json > "$tmp" | |
| mv "$tmp" scripts/known-versions.json | |
| echo "--- updated known-versions.json ---" | |
| cat scripts/known-versions.json | |
| # User-facing displays render with a J prefix (e.g. J9.8.0-beta1). | |
| # Replace from the J prefix up to the closing tag/quote, so we don't | |
| # have to know the previous version's exact format. | |
| J_DISPLAY="J${J_VERSION}" | |
| echo "Display version: $J_DISPLAY" | |
| # index.html: scoped to the data-lang="j" dropdown item only. | |
| sed -i -E "/data-lang=\"j\"/,/<\/div>/ s|(<span class=\"lang-version\">)J[^<]*(</span>)|\1${J_DISPLAY}\2|" index.html | |
| # generate-og-languages.cjs: only the J row. | |
| sed -i -E "s|(name: 'J',[[:space:]]+version: ')J[^']*(')|\1${J_DISPLAY}\2|" scripts/generate-og-languages.cjs | |
| echo "--- index.html (J dropdown) ---" | |
| grep -A3 'data-lang="j"' index.html | head -5 | |
| echo "--- generate-og-languages.cjs (J row) ---" | |
| grep "name: 'J'" scripts/generate-og-languages.cjs | |
| - name: Compose PR body | |
| id: body | |
| env: | |
| J_VERSION: ${{ inputs.j_version }} | |
| ISSUE_NUMBER: ${{ inputs.issue_number }} | |
| run: | | |
| { | |
| echo "Auto-generated by \`.github/workflows/auto-update-j.yml\`." | |
| echo "" | |
| echo "- Rebuilt \`wasm/j/emj.js\`, \`wasm/j/emj.wasm\`, and \`wasm/j/emj.data\` via \`scripts/build-j-wasm.sh\` (Docker + Emscripten)." | |
| echo "- Bumped \`scripts/known-versions.json\` J entry to \`${J_VERSION}\`." | |
| echo "- Synced display strings in \`index.html\` and \`scripts/generate-og-languages.cjs\` to \`J${J_VERSION}\`." | |
| echo "" | |
| echo "Source: https://github.com/jsoftware/jsource (master)" | |
| if [ -n "$ISSUE_NUMBER" ]; then | |
| echo "" | |
| echo "Closes #${ISSUE_NUMBER}" | |
| fi | |
| } > pr-body.md | |
| echo "wrote pr-body.md ($(wc -c < pr-body.md) bytes)" | |
| { | |
| echo 'body<<__EOF__' | |
| cat pr-body.md | |
| echo '__EOF__' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Open pull request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.PAT_REPO }} | |
| branch: auto/update-j-${{ inputs.j_version }} | |
| delete-branch: true | |
| commit-message: "Update J to ${{ inputs.j_version }}" | |
| title: "Update J to ${{ inputs.j_version }}" | |
| body: ${{ steps.body.outputs.body }} | |
| labels: language-update | |
| assignees: codereport | |
| add-paths: | | |
| wasm/j | |
| scripts/known-versions.json | |
| scripts/generate-og-languages.cjs | |
| index.html |