File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,14 +184,45 @@ jobs:
184184 publish-pypi :
185185 name : Publish PyPI
186186 runs-on : ubuntu-24.04
187- needs : publish-release
187+ needs :
188+ - publish-release
188189 steps :
189190 - name : Checkout repository
190191 uses : actions/checkout@v6
191192 with :
192193 fetch-depth : 0
193194 ref : ${{ inputs.ref || github.ref }}
194195
196+ - name : Resolve tag
197+ id : tag
198+ shell : bash
199+ run : |
200+ if [ "${{ github.event_name }}" = "push" ]; then
201+ tag="${GITHUB_REF_NAME}"
202+ elif [ -n "${{ inputs.tag }}" ]; then
203+ tag="${{ inputs.tag }}"
204+ else
205+ tag="$(git describe --tags --abbrev=0)"
206+ fi
207+ if [ -z "$tag" ]; then
208+ echo "Failed to resolve tag." >&2
209+ exit 1
210+ fi
211+ echo "tag=$tag" >> "$GITHUB_OUTPUT"
212+
213+ - name : Download dashboard artifact
214+ uses : actions/download-artifact@v8
215+ with :
216+ name : Dashboard-${{ steps.tag.outputs.tag }}
217+ path : dashboard-artifact
218+
219+ - name : Unpack dashboard dist into package tree
220+ shell : bash
221+ run : |
222+ mkdir -p astrbot/dashboard/dist
223+ unzip -q "dashboard-artifact/AstrBot-${{ steps.tag.outputs.tag }}-dashboard.zip" -d dashboard-artifact/unpacked
224+ cp -r dashboard-artifact/unpacked/dist/. astrbot/dashboard/dist/
225+
195226 - name : Set up Python
196227 uses : actions/setup-python@v6
197228 with :
@@ -203,6 +234,8 @@ jobs:
203234
204235 - name : Build package
205236 shell : bash
237+ # Dashboard assets are already in astrbot/dashboard/dist/;
238+ # ASTRBOT_BUILD_DASHBOARD is intentionally unset so the hatch hook skips npm.
206239 run : uv build
207240
208241 - name : Publish to PyPI
Original file line number Diff line number Diff line change 11"""
22Custom Hatchling build hook.
33
4- During `hatch build` (or `pip wheel`), this hook:
4+ Only runs when the environment variable ASTRBOT_BUILD_DASHBOARD=1 is set,
5+ so that `uv sync` / editable installs are never affected.
6+
7+ Usage:
8+ ASTRBOT_BUILD_DASHBOARD=1 uv build
9+
10+ When enabled, this hook:
5111. Runs `npm run build` inside the `dashboard/` directory.
6122. Copies the resulting `dashboard/dist/` tree into
713 `astrbot/dashboard/dist/` so the static assets are shipped
814 inside the Python wheel.
915"""
1016
17+ import os
1118import shutil
1219import subprocess
1320import sys
@@ -20,6 +27,11 @@ class CustomBuildHook(BuildHookInterface):
2027 PLUGIN_NAME = "custom"
2128
2229 def initialize (self , version : str , build_data : dict ) -> None :
30+ # Only run when explicitly requested (e.g. during CI / release builds).
31+ # This prevents `uv sync` / editable installs from triggering npm.
32+ if os .environ .get ("ASTRBOT_BUILD_DASHBOARD" , "" ).strip () != "1" :
33+ return
34+
2335 root = Path (self .root )
2436 dashboard_src = root / "dashboard"
2537 dist_src = dashboard_src / "dist"
You can’t perform that action at this time.
0 commit comments