Build the listed AnnoBase frontend packages after the download; settings and destination relative to the workspace
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bcb77261f4
commit
3a58c974d4
3 changed files with 39 additions and 12 deletions
|
|
@ -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/<name> build`), for example `api react map`. Empty for backend jobs.
|
||||
- `destination`: default `<workspace>/AnnoBase`, which is where the `AnnoBaseBackendPath` and frontend `link:` paths of the products point.
|
||||
|
||||
The step reads release `v<version>` 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.
|
||||
|
|
|
|||
|
|
@ -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[@]}"
|
||||
|
|
|
|||
43
fetch.py
43
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue