diff --git a/.gitea/workflows/pages.yml b/.gitea/workflows/pages.yml index 530f002b3..584f44b5c 100644 --- a/.gitea/workflows/pages.yml +++ b/.gitea/workflows/pages.yml @@ -18,7 +18,6 @@ jobs: runs-on: alpha-ubuntu24.04 timeout-minutes: 45 env: - PACKAGE_FLAGS: --locked SITE_ASSET_VERSION: ${{ gitea.sha }} steps: - name: Check out Breeze from Gitea @@ -39,16 +38,12 @@ jobs: - name: Install site build dependencies run: USER="$(id -un)" .github/scripts/install-apt-packages.sh .github/apt/empty-packages.txt apt-utils gnupg ripgrep unzip zip zstd - - name: Resolve locked package sources on Gitea - env: - GIT_CONFIG_COUNT: '3' - GIT_CONFIG_KEY_0: url.https://git.waozi.xyz/waozi/.insteadOf - GIT_CONFIG_VALUE_0: https://github.com/waozixyz/ - GIT_CONFIG_KEY_1: url.https://git.waozi.xyz/kryonlabs/.insteadOf - GIT_CONFIG_VALUE_1: https://github.com/kryonlabs/ - GIT_CONFIG_KEY_2: url.https://git.waozi.xyz/ziranlang/.insteadOf - GIT_CONFIG_VALUE_2: https://github.com/ziranlang/ - run: make packages + - name: Fetch the pinned site icons from Gitea + run: | + set -eu + kryon_dir="$PWD/build/site-kryon" + sh site/fetch-kryon-icons.sh "$kryon_dir" + printf 'KRYON_DIR=%s\n' "$kryon_dir" >> "$GITHUB_ENV" - name: Select the verified web app origin if: gitea.event_name != 'pull_request' @@ -68,7 +63,8 @@ jobs: - name: Test website routes, assets and Telegram bridge run: | - make site-assets-test apt-repo-test + node tests/site_assets_test.mjs + sh tests/apt_repo_test.sh node tests/telegram_bridge_test.mjs - name: Deploy current master to Cloudflare Pages diff --git a/site/build-production.sh b/site/build-production.sh index 30fe2cf6a..14c09d376 100644 --- a/site/build-production.sh +++ b/site/build-production.sh @@ -32,10 +32,10 @@ mkdir -p "$release_dir/app" unzip -q "$release_dir/inbe-web.zip" -d "$release_dir/app" test -s "$release_dir/app/index.wasm" -make package-unpackaged-assets +make -f site/production.mk package-unpackaged-assets SITE_WEB_DIR="$PWD/$release_dir/app" sh site/build.sh # Gitea's job token is only valid on Gitea. Downloads still follow the public release. -env -u GITHUB_TOKEN -u GH_TOKEN make site-release-assets-check +env -u GITHUB_TOKEN -u GH_TOKEN make -f site/production.mk site-release-assets-check if [ -n "${APT_SIGNING_KEY:-}" ]; then deb_dir="$release_dir/debs" diff --git a/site/build.sh b/site/build.sh index 766b3ce78..717a5fa5a 100755 --- a/site/build.sh +++ b/site/build.sh @@ -34,7 +34,7 @@ copy_dir_contents() { sync_shared_web_icons() { sync_script="$kryon_dir/scripts/sync-icons.sh" require_path "$sync_script" - sh "$sync_script" "$root_dir/web-assets/icons" platforms language tiles + sh "$sync_script" "$out_dir/web-assets/icons" platforms language tiles } expand_template_file() { @@ -230,8 +230,8 @@ fi mkdir -p "$out_dir/legacy-converter" cp "$out_dir/legacy-converter.html" "$out_dir/legacy-converter/index.html" -sync_shared_web_icons copy_dir_contents "$root_dir/web-assets" "$out_dir/web-assets" +sync_shared_web_icons # Keep the released app's audio URL available alongside the current archive name. copy_path "$out_dir/web-assets/dl/breathing-meditation-audio-v1.zip" "$out_dir/web-assets/dl/inbe-meditation-audio-v1.zip" copy_dir_contents "$root_dir/site-icons" "$out_dir/site-icons" diff --git a/site/fetch-kryon-icons.sh b/site/fetch-kryon-icons.sh new file mode 100644 index 000000000..d72cfbe34 --- /dev/null +++ b/site/fetch-kryon-icons.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -eu +cd "$(dirname "$0")/.." + +destination=${1:?Usage: fetch-kryon-icons.sh DESTINATION} +revision=$(python3 - <<'PY' +import json +import re +from pathlib import Path + +lock = json.loads(Path('ziran.lock').read_text()) +pins = [package['commit'] for package in lock['packages'] if package['name'] == 'kryon'] +if len(pins) != 1 or not re.fullmatch(r'[0-9a-f]{40}', pins[0]): + raise SystemExit('Expected one pinned Kryon commit in ziran.lock') +print(pins[0]) +PY +) +mkdir -p "$destination/icons" "$destination/scripts" +for file in scripts/sync-icons.sh icons/platforms.png icons/platforms.json \ + icons/language.png icons/language.json icons/tiles.png icons/tiles.json; do + temporary=$(mktemp "$destination/$file.XXXXXX") + trap 'rm -f "$temporary"' 0 + curl -fsSL --max-time 30 --retry 2 \ + "https://git.waozi.xyz/kryonlabs/kryon/raw/commit/$revision/$file" -o "$temporary" + test -s "$temporary" + chmod 644 "$temporary" + mv -f "$temporary" "$destination/$file" + trap - 0 +done +printf 'Fetched the site icon sheets from Kryon commit %s\n' "$revision" diff --git a/site/production.mk b/site/production.mk new file mode 100644 index 000000000..e697f78cb --- /dev/null +++ b/site/production.mk @@ -0,0 +1,12 @@ +# Pages uses the released web app and builds only the website's downloads. +UNPACKAGED_AUDIO_DIR := unpackaged_assets/audio +UNPACKAGED_AUDIO_FILES := $(shell git ls-files -- $(UNPACKAGED_AUDIO_DIR)) +MEDITATION_AUDIO_TRACKS := $(patsubst $(UNPACKAGED_AUDIO_DIR)/%,%,$(filter %.ogg,$(UNPACKAGED_AUDIO_FILES))) +MEDITATION_AUDIO_ZIP := web-assets/dl/breathing-meditation-audio-v1.zip +ifeq ($(strip $(MEDITATION_AUDIO_TRACKS)),) +$(error No tracked meditation audio files) +endif + +MAKE := $(MAKE) -f site/production.mk +.PHONY: validate-meditation-audio package-unpackaged-assets site-release-assets-check +include mk/site.mk