diff --git a/.github/workflows/check-editor-releases.yml b/.github/workflows/check-editor-releases.yml index 2127abd..729e923 100644 --- a/.github/workflows/check-editor-releases.yml +++ b/.github/workflows/check-editor-releases.yml @@ -57,6 +57,8 @@ jobs: EXELEARNING_EDITOR_REPO_URL: https://github.com/exelearning/exelearning.git EXELEARNING_EDITOR_REF: ${{ steps.check.outputs.tag }} EXELEARNING_EDITOR_REF_TYPE: tag + # Embed the final release version in the editor build (not 0.0.0-alpha). + APP_VERSION: ${{ steps.check.outputs.tag }} run: make build-editor - name: Compute version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7cb7238..4440108 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,8 +47,10 @@ jobs: VERSION_TAG="${RAW_TAG#v}" echo "RELEASE_TAG=${VERSION_TAG}" >> $GITHUB_ENV echo "EXELEARNING_EDITOR_REPO_URL=https://github.com/exelearning/exelearning.git" >> $GITHUB_ENV - echo "EXELEARNING_EDITOR_REF=main" >> $GITHUB_ENV - echo "EXELEARNING_EDITOR_REF_TYPE=branch" >> $GITHUB_ENV + # Build the editor from the matching editor tag so the embedded + # editor reports the final release version (not a nightly/alpha build). + echo "EXELEARNING_EDITOR_REF=v${VERSION_TAG}" >> $GITHUB_ENV + echo "EXELEARNING_EDITOR_REF_TYPE=tag" >> $GITHUB_ENV else INPUT_RELEASE="${{ github.event.inputs.release_tag }}" if [ -z "$INPUT_RELEASE" ]; then diff --git a/Makefile b/Makefile index 41b70f4..0d97a24 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,24 @@ fetch-editor-source: build-editor: check-bun fetch-editor-source @echo "Building eXeLearning static editor..." rm -rf $(EDITOR_OUTPUT_DIR) - cd $(EDITOR_SUBMODULE_PATH) && bun install && OUTPUT_DIR=$(EDITOR_OUTPUT_DIR) bun run build:static + @# Resolve the version to embed in the editor build. The editor's build script + @# (scripts/build-static-bundle.ts) reads APP_VERSION/VERSION; without it the + @# build falls back to package.json (0.0.0-alpha). Resolution order: + @# APP_VERSION -> VERSION -> EXELEARNING_EDITOR_REF (env or .env) -> + @# exact git tag of the checked-out editor -> empty (dev default -> alpha) + @set -e; \ + get_env() { \ + if [ -f .env ]; then \ + grep -E "^$$1=" .env | tail -n1 | cut -d '=' -f2-; \ + fi; \ + }; \ + APP_VER="$${APP_VERSION:-$${VERSION:-$${EXELEARNING_EDITOR_REF:-$$(get_env EXELEARNING_EDITOR_REF)}}}"; \ + if [ -z "$$APP_VER" ] || [ "$$APP_VER" = "main" ] || [ "$$APP_VER" = "master" ]; then \ + EXACT_TAG="$$(git -C $(EDITOR_SUBMODULE_PATH) describe --tags --exact-match 2>/dev/null || true)"; \ + if [ -n "$$EXACT_TAG" ]; then APP_VER="$$EXACT_TAG"; fi; \ + fi; \ + echo "Editor version input: $${APP_VER:-(default -> alpha)}"; \ + cd $(EDITOR_SUBMODULE_PATH) && bun install && OUTPUT_DIR=$(EDITOR_OUTPUT_DIR) APP_VERSION="$$APP_VER" bun run build:static @# If the build script ignored OUTPUT_DIR, copy from fetched source output. @if [ ! -f "$(EDITOR_OUTPUT_DIR)/index.html" ] && [ -f "$(EDITOR_SUBMODULE_PATH)/dist/static/index.html" ]; then \ echo "Copying build output to dist/static/..."; \