From a7cb1f9a6e41a5ffcfee6adeffbe92eeb501c7be Mon Sep 17 00:00:00 2001 From: Intubun <41478036+Intubun@users.noreply.github.com> Date: Fri, 22 May 2026 12:49:02 +0200 Subject: [PATCH] update npm versioning, build.sh and delete tcl.ref and fix to latest stable --- .github/workflows/main-wasm.yml | 112 +++++++++++++++++++++++++++----- npm/build.sh | 22 +++---- npm/tcl.ref | 12 ---- 3 files changed, 103 insertions(+), 43 deletions(-) delete mode 100644 npm/tcl.ref diff --git a/.github/workflows/main-wasm.yml b/.github/workflows/main-wasm.yml index 0b0ef86e..802921f1 100644 --- a/.github/workflows/main-wasm.yml +++ b/.github/workflows/main-wasm.yml @@ -5,7 +5,7 @@ name: CI-wasm # when a release tag of the form v... is pushed — that gate is the # manual release trigger: # -# # bump magic/VERSION and/or npm/tcl.ref, commit, push to default branch +# # bump magic/VERSION, commit, push to default branch # git tag v8.3.638 # git push origin v8.3.638 # @@ -21,6 +21,14 @@ on: description: 'emsdk version to build with (default: latest; pin a version number to bisect)' type: string default: 'latest' + tcl_ref: + description: 'TCL ref to build against (default: auto-resolve latest stable tag). Use a tag like core-9-0-3, a branch, or a commit SHA to bisect a regression.' + type: string + default: '' + tcl_repo_url: + description: 'TCL repository URL (default: https://github.com/tcltk/tcl.git)' + type: string + default: '' dry_run: description: 'Dry run: pack only, do not publish even on tag pushes' type: boolean @@ -73,23 +81,56 @@ jobs: echo "===== emcc -dM -E - ====="; echo | emcc -dM -E - | sort echo "===== em++ -dM -E - ====="; echo | em++ -dM -E - | sort - # Clone tcltk/tcl into a sibling directory at the pinned ref from - # npm/tcl.ref. npm/build.sh would do this on its own, but doing it as - # an explicit step makes the resolved SHA visible at the top of the - # job log and keeps the build step's output focused on the C build. - # The TCL source tree is treated as read-only — the actual WASM build - # runs inside magic (toolchains/emscripten/build-tcl-wasm.sh). - - name: Pin and clone tcltk/tcl + # Determine which TCL ref to build against. + # Priority: workflow_dispatch input > auto-resolved latest stable tag. + # TCL stable releases follow the core--- + # naming convention; core-9-0-x is the current stable series. + # Falls back to main only if no release tags are found at all. + - name: Resolve TCL ref + id: resolve-tcl + env: + TCL_REPO_URL: ${{ github.event.inputs.tcl_repo_url || 'https://github.com/tcltk/tcl.git' }} + TCL_REF_INPUT: ${{ github.event.inputs.tcl_ref || '' }} + run: | + if [ -n "$TCL_REF_INPUT" ]; then + TCL_REF="$TCL_REF_INPUT" + echo "Using workflow_dispatch TCL_REF: $TCL_REF" + else + TCL_REF=$(git ls-remote --tags --sort=-version:refname "$TCL_REPO_URL" \ + 'refs/tags/core-9-0-*' \ + | grep -v '\^{}' \ + | head -1 \ + | awk '{print $2}' \ + | sed 's|refs/tags/||') + if [ -z "$TCL_REF" ]; then + TCL_REF=main + echo "Warning: no stable core-9-0-x tag found, falling back to main" + else + echo "Auto-resolved latest stable TCL tag: $TCL_REF" + fi + fi + echo "tcl_ref=$TCL_REF" >> "$GITHUB_OUTPUT" + echo "tcl_repo_url=$TCL_REPO_URL" >> "$GITHUB_OUTPUT" + + # Clone tcltk/tcl into a sibling directory at the resolved ref. + # Done as an explicit step so the exact commit is visible in the job + # log. The source tree is read-only — the WASM build runs inside magic. + - name: Clone tcltk/tcl + env: + TCL_REPO_URL: ${{ steps.resolve-tcl.outputs.tcl_repo_url }} + TCL_REF: ${{ steps.resolve-tcl.outputs.tcl_ref }} run: | - . npm/tcl.ref - : "${TCL_REPO_URL:=https://github.com/tcltk/tcl.git}" - : "${TCL_REF:=main}" - echo "Pinned TCL: $TCL_REF ($TCL_REPO_URL)" # autocrlf=false: ubuntu-latest is already LF, but make it explicit. git -c core.autocrlf=false clone "$TCL_REPO_URL" ../tcl - ( cd ../tcl && git checkout --detach "$TCL_REF" ) + cd ../tcl + git checkout --detach "$TCL_REF" + echo "=== TCL commit ===" + git log -n1 --format="commit %H%nauthor %an <%ae>%ndate %ci%nref %D%n%n %s" - name: Build WASM — both variants (tcl + notcl) + env: + TCL_REF: ${{ steps.resolve-tcl.outputs.tcl_ref }} + TCL_REPO_URL: ${{ steps.resolve-tcl.outputs.tcl_repo_url }} run: | source ./emsdk/emsdk_env.sh bash npm/build.sh --variant=both @@ -132,13 +173,16 @@ jobs: echo "version=${tag#v}" >> "$GITHUB_OUTPUT" echo "Tag release: $tag → npm version ${tag#v}" else - # For non-tag CI runs, use a dev-suffixed version so the packed - # tarball is still consumable for local inspection / artifact upload. + # For non-tag CI runs, embed date + git hash as build metadata + # (semver +METADATA) so the snapshot sorts as 8.3.799+date.gitHASH. + # Build metadata is ignored by npm for version comparison — the + # snapshot is treated as equivalent to 8.3.799 for range matching, + # which is correct: it is that release built from a specific commit. base=$(cat VERSION) date=$(git show -s --format=%cs | tr -d '-') hash=$(git show -s --format=%h) - echo "publish=false" >> "$GITHUB_OUTPUT" - echo "version=${base}-${date}.${hash}" >> "$GITHUB_OUTPUT" + echo "publish=false" >> "$GITHUB_OUTPUT" + echo "version=${base}+${date}.git${hash}" >> "$GITHUB_OUTPUT" echo "Non-tag build: will not publish." fi @@ -168,3 +212,37 @@ jobs: run: cd npm && npm publish env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Write a Markdown summary visible next to the artifacts on the Actions + # page. Captures the exact versions used so a future regression can be + # bisected without scrolling through raw logs. + - name: Build summary + if: always() + env: + TCL_REF: ${{ steps.resolve-tcl.outputs.tcl_ref }} + TCL_REPO_URL: ${{ steps.resolve-tcl.outputs.tcl_repo_url }} + run: | + source ./emsdk/emsdk_env.sh 2>/dev/null || true + EMCC_VER=$(emcc --version 2>/dev/null | head -1 || echo "unavailable") + GCC_VER=$(gcc --version 2>/dev/null | head -1 || echo "unavailable") + NODE_VER=$(node --version 2>/dev/null || echo "unavailable") + MAGIC_VER=$(cat VERSION 2>/dev/null || echo "unavailable") + if [ -d ../tcl/.git ]; then + TCL_SHA=$(cd ../tcl && git rev-parse HEAD) + TCL_DATE=$(cd ../tcl && git log -1 --format="%ci") + TCL_SUBJECT=$(cd ../tcl && git log -1 --format="%s") + else + TCL_SHA="(not cloned)"; TCL_DATE=""; TCL_SUBJECT="" + fi + printf '## Build info\n\n' >> "$GITHUB_STEP_SUMMARY" + printf '| Component | Details |\n' >> "$GITHUB_STEP_SUMMARY" + printf '|-----------|----------|\n' >> "$GITHUB_STEP_SUMMARY" + printf '| Magic | `%s` |\n' "$MAGIC_VER" >> "$GITHUB_STEP_SUMMARY" + printf '| Emscripten | %s |\n' "$EMCC_VER" >> "$GITHUB_STEP_SUMMARY" + printf '| GCC | %s |\n' "$GCC_VER" >> "$GITHUB_STEP_SUMMARY" + printf '| Node.js | %s |\n' "$NODE_VER" >> "$GITHUB_STEP_SUMMARY" + printf '| TCL repo | %s |\n' "$TCL_REPO_URL" >> "$GITHUB_STEP_SUMMARY" + printf '| TCL ref | `%s` |\n' "$TCL_REF" >> "$GITHUB_STEP_SUMMARY" + printf '| TCL commit | `%s` |\n' "$TCL_SHA" >> "$GITHUB_STEP_SUMMARY" + printf '| TCL date | %s |\n' "$TCL_DATE" >> "$GITHUB_STEP_SUMMARY" + printf '| TCL subject | %s |\n' "$TCL_SUBJECT" >> "$GITHUB_STEP_SUMMARY" diff --git a/npm/build.sh b/npm/build.sh index 37df8893..a96ad4f2 100755 --- a/npm/build.sh +++ b/npm/build.sh @@ -94,26 +94,20 @@ sed_strip_cr() { } if [ $OPT_RELEASE -eq 1 ]; then - EXTRA_CFLAGS=" -O2" + EXTRA_CFLAGS="-O2" else - EXTRA_CFLAGS=" -g" + EXTRA_CFLAGS="-g" fi -# --- TCL fork: locate, pin, prebuild (TCL variant only) --------------------- -# Reads npm/tcl.ref to get the upstream URL + commit SHA. If the TCL source -# tree does not exist yet, clone it (with autocrlf=false to keep configure -# parseable on Windows hosts). If it does exist, just check out the pinned -# ref — no auto-fetch, so releases stay reproducible. +# --- TCL fork: locate and prebuild (TCL variant only) ----------------------- +# Uses TCL_REPO_URL and TCL_REF from the environment (both have defaults). +# If the TCL source tree does not exist yet, clones it. If it does exist, +# checks out the requested ref — no auto-fetch, so builds are reproducible. # # The TCL source tree is treated as read-only. The actual WASM build runs in # $TCL_BUILD_DIR (inside magic), driven by # toolchains/emscripten/build-tcl-wasm.sh. ensure_tcl_built() { - local TCL_REF_FILE="$SCRIPT_DIR/tcl.ref" - if [ -f "$TCL_REF_FILE" ]; then - # shellcheck source=/dev/null - . "$TCL_REF_FILE" - fi : "${TCL_REPO_URL:=https://github.com/tcltk/tcl.git}" : "${TCL_REF:=main}" @@ -167,7 +161,7 @@ build_variant() { if [ "$variant" = "tcl" ]; then ensure_tcl_built - CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1${EXTRA_CFLAGS}" \ + CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 ${EXTRA_CFLAGS}" \ emconfigure ./configure \ --without-cairo --without-opengl --without-x --without-tk \ --with-tcl="$TCL_WASM_PREFIX/lib" \ @@ -177,7 +171,7 @@ build_variant() { --host=asmjs-unknown-emscripten \ --target=asmjs-unknown-emscripten else - CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1${EXTRA_CFLAGS}" \ + CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 ${EXTRA_CFLAGS}" \ emconfigure ./configure \ --without-cairo --without-opengl --without-x \ --without-tk --without-tcl \ diff --git a/npm/tcl.ref b/npm/tcl.ref deleted file mode 100644 index 5febcec2..00000000 --- a/npm/tcl.ref +++ /dev/null @@ -1,12 +0,0 @@ -# Pin for the TCL fork that the WASM build links against. -# -# Format: shell-style "VAR=VALUE" lines (no spaces around =). -# Lines starting with # or blank lines are ignored. -# -# To take a newer TCL release into magic-wasm: -# 1. Update TCL_REF below to the desired commit SHA (or tag/branch). -# 2. Bump magic/VERSION as usual. -# 3. Commit + push. CI rebuilds and republishes. - -TCL_REPO_URL=https://github.com/tcltk/tcl.git -TCL_REF=84b23291b0dd811d642abef4ec7a55473c3eccb3