From 3a58c974d490c7bbbd8d3e1cc26aaad4809febcd Mon Sep 17 00:00:00 2001 From: Gergo Date: Thu, 19 Nov 2026 13:15:22 +0100 Subject: [PATCH] Build the listed AnnoBase frontend packages after the download; settings and destination relative to the workspace Co-Authored-By: Claude Opus 5.5 --- README.md | 1 + action.yml | 7 ++++++- fetch.py | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5d1c1de..b73306a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Forgejo Actions step that puts the AnnoBase release named in the app settings ne - `settings`: JSON file of the app, relative to the workspace. It holds `"AnnoBase": { "Version": "1.0.4" }` (backend `appsettings.json`) or `"annobase": { "version": "1.0.4" }` with `key: annobase.version` (frontend `package.json`). - `token`: the organisation secret `ANNOBASE_TOKEN` (read-only token of the `annobase-ci` user for `annodev/anno-base`). +- `frontend-packages`: AnnoBase frontend packages to build after the download (`bun install --frozen-lockfile`, then `bun run --cwd packages/ build`), for example `api react map`. Empty for backend jobs. - `destination`: default `/AnnoBase`, which is where the `AnnoBaseBackendPath` and frontend `link:` paths of the products point. The step reads release `v` of `annodev/anno-base`, downloads `manifest.json` and the archive it names, checks the sha256 and unpacks the archive. AnnoBase itself stays private; this repository holds only the download step. diff --git a/action.yml b/action.yml index 80e7e96..57afd48 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,10 @@ inputs: description: Folder that receives AnnoBase; empty means AnnoBase in the workspace required: false default: "" + frontend-packages: + description: AnnoBase frontend packages to build after the download, for example "api react map"; empty builds none + required: false + default: "" runs: using: composite steps: @@ -24,8 +28,9 @@ runs: ANNOBASE_SETTINGS: ${{ inputs.settings }} ANNOBASE_KEY: ${{ inputs.key }} ANNOBASE_DESTINATION: ${{ inputs.destination }} + ANNOBASE_FRONTEND_PACKAGES: ${{ inputs.frontend-packages }} run: | set -euo pipefail - args=(--settings "$ANNOBASE_SETTINGS" --key "$ANNOBASE_KEY") + args=(--settings "$ANNOBASE_SETTINGS" --key "$ANNOBASE_KEY" --frontend-packages "$ANNOBASE_FRONTEND_PACKAGES") if [ -n "$ANNOBASE_DESTINATION" ]; then args+=(--destination "$ANNOBASE_DESTINATION"); fi python3 "${{ github.action_path }}/fetch.py" "${args[@]}" diff --git a/fetch.py b/fetch.py index 6870f29..70cd670 100644 --- a/fetch.py +++ b/fetch.py @@ -2,6 +2,7 @@ import argparse import hashlib import json import os +import subprocess import sys import tarfile import tempfile @@ -57,17 +58,14 @@ def extract(archive, destination): tar.extractall(destination) -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("--settings", required=True) - parser.add_argument("--key", default="AnnoBase.Version") - parser.add_argument("--destination", default=os.path.join(os.environ.get("GITHUB_WORKSPACE", "."), "AnnoBase")) - args = parser.parse_args() - token = os.environ.get("ANNOBASE_TOKEN", "").strip() - if not token: - sys.exit("ANNOBASE_TOKEN is empty") - version = setting(args.settings, args.key) - destination = Path(args.destination) +def build_frontend(destination, packages): + folder = destination / "source" / "frontend" + subprocess.run(["bun", "install", "--frozen-lockfile"], cwd=folder, check=True) + for package in packages: + subprocess.run(["bun", "run", "--cwd", f"packages/{package}", "build"], cwd=folder, check=True) + + +def fetch(version, destination, token): marker = destination / MARKER if marker.is_file() and marker.read_text().strip() == version: print(f"AnnoBase {version} is already in {destination}") @@ -93,5 +91,28 @@ def main(): print(f"AnnoBase {version} ({manifest['commit']}) is in {destination}") +def main(): + workspace = Path(os.environ.get("GITHUB_WORKSPACE", ".")) + parser = argparse.ArgumentParser() + parser.add_argument("--settings", required=True) + parser.add_argument("--key", default="AnnoBase.Version") + parser.add_argument("--destination", default=str(workspace / "AnnoBase")) + parser.add_argument("--frontend-packages", default="") + args = parser.parse_args() + token = os.environ.get("ANNOBASE_TOKEN", "").strip() + if not token: + sys.exit("ANNOBASE_TOKEN is empty") + settings = Path(args.settings) + if not settings.is_absolute(): + settings = workspace / settings + destination = Path(args.destination) + if not destination.is_absolute(): + destination = workspace / destination + fetch(setting(settings, args.key), destination, token) + packages = args.frontend_packages.replace(",", " ").split() + if packages: + build_frontend(destination, packages) + + if __name__ == "__main__": main()