diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bed8dba..bb23d82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,17 +29,42 @@ jobs: New-Item -ItemType Directory -Force -Path dist | Out-Null $exe = "marqdo-$ver-$target.exe" $zip = "marqdo-$ver-$target.zip" + $stdlib = "marqdo-$ver-stdlib.zip" Copy-Item target/release/marqdo.exe "dist/$exe" - Compress-Archive -Path "dist/$exe" -DestinationPath "dist/$zip" -Force + $stage = "dist/stage-bundle" + if (Test-Path $stage) { Remove-Item $stage -Recurse -Force } + New-Item -ItemType Directory -Force -Path $stage | Out-Null + Copy-Item target/release/marqdo.exe "$stage/marqdo.exe" + Copy-Item lib "$stage/lib" -Recurse + if (Test-Path "dist/$zip") { Remove-Item "dist/$zip" -Force } + Compress-Archive -Path "$stage/*" -DestinationPath "dist/$zip" -Force + $stageLib = "dist/stage-stdlib" + if (Test-Path $stageLib) { Remove-Item $stageLib -Recurse -Force } + New-Item -ItemType Directory -Force -Path $stageLib | Out-Null + Copy-Item lib "$stageLib/lib" -Recurse + if (Test-Path "dist/$stdlib") { Remove-Item "dist/$stdlib" -Force } + Compress-Archive -Path "$stageLib/*" -DestinationPath "dist/$stdlib" -Force echo "EXE=$exe" >> $env:GITHUB_ENV echo "ZIP=$zip" >> $env:GITHUB_ENV + echo "STDLIB=$stdlib" >> $env:GITHUB_ENV - name: Upload release assets uses: softprops/action-gh-release@v2 with: + body: | + ## Downloads + + | Asset | Contents | + |-------|----------| + | `marqdo-*-windows-msvc.exe` | **Executable only** — does **not** include the standard library | + | `marqdo-*-windows-msvc.zip` | **Recommended**: `marqdo.exe` + `lib/` (keep them together) | + | `marqdo-*-stdlib.zip` | Standard library only — unpack next to the exe, or set `MARQDO_LIB` | + + > The standalone `.exe` does **not** ship `lib/`. Use the bundle zip or stdlib zip for `lib/…` imports. files: | dist/${{ env.EXE }} dist/${{ env.ZIP }} + dist/${{ env.STDLIB }} fail_on_unmatched_files: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 73fc8b7..9ad1b2b 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ powershell -File ./scripts/build-public.ps1 cargo run -- catalog tests -o .marqdo ``` +**发布包(GitHub Releases)**:单独 `.exe` **不含** `lib/`;请下载带 `lib/` 的 zip,或另下 `*-stdlib.zip` 解压到可执行文件旁(亦可设 `MARQDO_LIB`)。 + 文档:用户站 [public/](public/) · 设计 [doc/](doc/) · OKF / catalog [catalog-cli.md](doc/design/catalog-cli.md) · 调试 [view-debug.md](doc/design/view-debug.md) --- diff --git a/scripts/publish-release.py b/scripts/publish-release.py index e981295..f5a7ea9 100644 --- a/scripts/publish-release.py +++ b/scripts/publish-release.py @@ -51,19 +51,23 @@ def api(method: str, url: str, token: str, data: bytes | None = None, content_ty raise SystemExit(f"HTTP {e.code} {url}: {err}") from e -def find_assets(stem: str) -> list[Path]: +def find_assets(stem: str, ver: str) -> list[Path]: + names = [ + f"{stem}.exe", + f"{stem}.zip", + f"marqdo-{ver}-stdlib.zip", + ] assets: list[Path] = [] - for base in (Path("dist"), Path("target/dist")): - for name in (f"{stem}.exe", f"{stem}.zip"): + for name in names: + found = None + for base in (Path("dist"), Path("target/dist")): p = base / name - if p.exists() and all(p.resolve() != a.resolve() for a in assets): - assets.append(p) - if len(assets) >= 2: - break - if len(assets) < 2: - raise SystemExit( - f"missing assets for {stem}.exe/.zip under dist/ or target/dist/" - ) + if p.exists(): + found = p + break + if not found: + raise SystemExit(f"missing asset: {name} under dist/ or target/dist/") + assets.append(found) return assets @@ -71,20 +75,25 @@ def main() -> None: ver = crate_version() tag = f"v{ver}" stem = f"marqdo-{ver}-x86_64-pc-windows-msvc" - assets = find_assets(stem) + assets = find_assets(stem, ver) notes = f"""## Marqdo {tag} +### Downloads + +| Asset | Contents | +|-------|----------| +| `{stem}.exe` | **Executable only** — does **not** include the standard library | +| `{stem}.zip` | **Recommended**: `marqdo.exe` + `lib/` (keep them together; `lib/` resolves next to the binary) | +| `marqdo-{ver}-stdlib.zip` | Standard library only (`lib/*.mq.md`) — unpack next to an existing exe, or set `MARQDO_LIB` | + +> **Important:** the standalone `.exe` does **not** ship `lib/`. Importing `lib/text.mq.md` etc. needs the bundle zip or the stdlib zip. + ### Highlights - **Code as docs as knowledge**: `.mq.md` is narrative + program in one tree -- **`marqdo debug`**: dedicated debugger (breakpoints / step / locals); view stays docs-only -- **View**: wider layout, function outline + search -- Foreign code Run works in debug; math / stdlib / foreign as before -- Roadmap: deeper **OKF**-aligned catalog so docs grow into a knowledge base for human–AI collaboration - -### Assets -- `{stem}.exe` — Windows x64 binary -- `{stem}.zip` — same binary zipped +- **`marqdo debug`**: dedicated debugger; view stays docs-only +- **View**: function outline + search +- Roadmap: deeper **OKF**-aligned catalog for human–AI knowledge bases ```text marqdo --version diff --git a/scripts/release-windows.ps1 b/scripts/release-windows.ps1 index 5da1e91..d6b86db 100644 --- a/scripts/release-windows.ps1 +++ b/scripts/release-windows.ps1 @@ -1,7 +1,8 @@ -# Build Windows release assets and upload them to an existing GitHub Release tag. +# Build Windows release assets (exe, bundle zip with lib/, stdlib zip) and upload +# to an existing GitHub Release tag. # Usage (from repo root): # powershell -File ./scripts/release-windows.ps1 -# powershell -File ./scripts/release-windows.ps1 -Tag v0.0.4 +# powershell -File ./scripts/release-windows.ps1 -Tag v0.1.0 param( [string]$Tag = "" ) @@ -16,6 +17,8 @@ if (-not $Tag) { $ver = $Tag.TrimStart("v") $target = "x86_64-pc-windows-msvc" $dist = Join-Path (Get-Location) "dist" +$stage = Join-Path $dist "stage-bundle" +$stageLib = Join-Path $dist "stage-stdlib" New-Item -ItemType Directory -Force -Path $dist | Out-Null Write-Host "Building release binary for $Tag ..." @@ -23,11 +26,33 @@ cargo build --release -q $exeName = "marqdo-$ver-$target.exe" $zipName = "marqdo-$ver-$target.zip" +$stdlibName = "marqdo-$ver-stdlib.zip" $exePath = Join-Path $dist $exeName $zipPath = Join-Path $dist $zipName +$stdlibPath = Join-Path $dist $stdlibName + Copy-Item ".\target\release\marqdo.exe" $exePath -Force + +# Bundle: marqdo.exe + lib/ (stdlib resolves next to the binary) +if (Test-Path $stage) { Remove-Item $stage -Recurse -Force } +New-Item -ItemType Directory -Force -Path $stage | Out-Null +Copy-Item ".\target\release\marqdo.exe" (Join-Path $stage "marqdo.exe") -Force +Copy-Item ".\lib" (Join-Path $stage "lib") -Recurse -Force +Get-ChildItem -Path (Join-Path $stage "lib") -Recurse -Filter "*.mq.md" | Out-Null if (Test-Path $zipPath) { Remove-Item $zipPath -Force } -Compress-Archive -Path $exePath -DestinationPath $zipPath -Force +Compress-Archive -Path (Join-Path $stage "*") -DestinationPath $zipPath -Force + +# Stdlib-only zip (for users who already have the exe) +if (Test-Path $stageLib) { Remove-Item $stageLib -Recurse -Force } +New-Item -ItemType Directory -Force -Path $stageLib | Out-Null +Copy-Item ".\lib" (Join-Path $stageLib "lib") -Recurse -Force +if (Test-Path $stdlibPath) { Remove-Item $stdlibPath -Force } +Compress-Archive -Path (Join-Path $stageLib "*") -DestinationPath $stdlibPath -Force + +Write-Host "Packaged:" +Write-Host " $exePath (binary only — no stdlib)" +Write-Host " $zipPath (marqdo.exe + lib/)" +Write-Host " $stdlibPath (lib/ only)" $raw = ("protocol=https`nhost=github.com`n`n" | git credential fill 2>$null) -join "`n" $user = ([regex]::Match($raw, '(?m)^username=(.+)$')).Groups[1].Value @@ -43,12 +68,52 @@ $headers = @{ $rel = Invoke-RestMethod -Uri "https://api.github.com/repos/cflmy/marqdo/releases/tags/$Tag" -Headers $headers Write-Host "Uploading to release $($rel.html_url)" -foreach ($file in @($exeName, $zipName)) { +# Refresh release notes +$notes = @" +## Marqdo $Tag + +### Downloads + +| Asset | Contents | +|-------|----------| +| ``$exeName`` | **Executable only** — does **not** include the standard library | +| ``$zipName`` | **Recommended**: ``marqdo.exe`` + ``lib/`` (place them together; ``lib/`` is resolved next to the binary) | +| ``$stdlibName`` | Standard library only (``lib/*.mq.md``) — unpack next to an existing ``marqdo.exe``, or set ``MARQDO_LIB`` | + +> **Important:** the standalone ``.exe`` does **not** ship ``lib/``. Importing ``lib/text.mq.md`` etc. needs the bundle zip or the stdlib zip beside the binary (or ``MARQDO_LIB``). + +### Highlights +- Code as docs as knowledge: ``.mq.md`` is narrative + program +- ``marqdo debug``: breakpoints / step / locals; ``marqdo view`` stays docs-only +- View: function outline + search; wider layout +- Roadmap: deeper OKF-aligned catalog for human–AI knowledge bases + +``````text +marqdo --version +marqdo run public/00-welcome.mq.md +marqdo view public +marqdo debug public +`````` +"@ + +$body = @{ + tag_name = $Tag + name = $Tag + body = $notes + draft = $false + prerelease = $false +} | ConvertTo-Json -Depth 5 +Invoke-RestMethod -Method Patch -Uri "https://api.github.com/repos/cflmy/marqdo/releases/$($rel.id)" -Headers $headers -ContentType "application/json; charset=utf-8" -Body ([Text.Encoding]::UTF8.GetBytes($body)) | Out-Null + +# Re-fetch assets list after patch +$rel = Invoke-RestMethod -Uri "https://api.github.com/repos/cflmy/marqdo/releases/$($rel.id)" -Headers $headers + +foreach ($file in @($exeName, $zipName, $stdlibName)) { $path = Join-Path $dist $file - # Replace existing asset with same name $existing = $rel.assets | Where-Object { $_.name -eq $file } if ($existing) { Invoke-RestMethod -Method Delete -Uri $existing.url -Headers $headers | Out-Null + Write-Host " deleted old $file" } $uri = "https://uploads.github.com/repos/cflmy/marqdo/releases/$($rel.id)/assets?name=$([uri]::EscapeDataString($file))" $bytes = [System.IO.File]::ReadAllBytes($path)