chore: fix publish script

This commit is contained in:
soarqin committed 2026-10-18 22:55:30 +08:00
1 parent 7e7d91e5b2
commit 3c157d2675
4 files changed
+60 -14

No files matched your search

+5 -3
View File
@@ -52,9 +52,9 @@ Target Windows PowerShell 5.1 and PowerShell 7. The existing packaging targets i
1. Resolve the named project within the repository. Require `<Project>/<Project>.csproj`, `package/manifest.json`, `package/icon.png`, and `README.md`. Reject traversal, wildcard input, helpers, and projects with `PackPreloaderTargetDir` set. Validate `-Namespace` and the manifest's `name` before building.
2. Evaluate Release MSBuild properties instead of guessing output paths or parsing only literal XML: `Version`, `ProjectName`, `TargetPath`, `PackHasChangelog`, `PackUsePluginsLayout`, and `PackPreloaderTargetDir`. Read evaluated `ProjectReference` items to find bundled preloaders. MSBuild 17.8 or newer provides the required `-getProperty` and `-getItem` JSON output.
3. For a real publish, resolve the token before changing to the repository's build directory and check the pinned local tcli tool before the expensive build. For `-DryRun`, neither a token nor an installed tcli tool is required. Restore project NuGet assets when missing, then use `--no-restore` for packaging.
3. For a real publish, resolve the token before changing to the repository's build directory and check the pinned local tcli tool before the expensive build. tcli 0.2.4 returns exit code 1 even when `--version` successfully prints its version: accept 0 or 1 only for this check, and require recognizable version output. For `-DryRun`, neither a token nor an installed tcli tool is required. Restore project NuGet assets when missing, then use `--no-restore` for packaging.
4. For each referenced preloader whose evaluated `PackPreloaderTargetDir` belongs to the selected mod's package, run `CopyToParentPackage` in Release before packaging the main mod. This refreshes Dustbin's bundled preloader even if an old DLL already exists under `package/patchers`. Do not upload preloaders or referenced mods separately.
5. Run `dotnet build <Project>/<Project>.csproj -t:ZipMod -c Release --no-restore`. Every native command must have its exit code checked; stop immediately on a nonzero result. Retain the existing warning policy.
5. Run `dotnet build <Project>/<Project>.csproj -t:ZipMod -c Release --no-restore`. Check every native command's exit code; builds and publication must stop immediately on a nonzero result. Retain the existing warning policy.
6. Select the exact ZIP path defined by the existing target: `<Project>/package/<ProjectName>-<Version>.zip`. Do not select the newest ZIP by timestamp or a wildcard. Read the ZIP and check its root manifest identity and version, required root files, 256x256 PNG icon, expected DLL layout, and optional changelog. Compare bundled main/preloader DLLs with the current evaluated build outputs. When a separate changelog is included, require its latest English and Chinese headings to match the project version. Do not change any version automatically.
7. Write a generated, non-secret tcli configuration under `<Project>/obj/thunderstore-publish/<run-id>/thunderstore.toml`. Print the project, Team, Package Name, version, community, ZIP path, and category-preservation behavior. In `-DryRun`, stop successfully here and retain the ZIP for inspection.
8. Before a real upload, query the exact package-version endpoint using the supplied namespace, manifest package name, and evaluated project version. If the version exists, stop without uploading. Treat only HTTP 404 as an absent version; authentication, network, server, and response-format errors must remain errors. Do not automatically increment versions or retry a publish with an uncertain result.
@@ -131,6 +131,7 @@ The pinned tcli version has a Windows-specific behavior: it reads the persisted
| Missing project, malformed metadata, missing/empty/invalid namespace, preloader/helper selection, or traversal input | Stops before publication and identifies the invalid input. |
| Explicit `-EnvFile`, default caller-directory `.env`, and process token are all available | Uses the explicit file first; without it, uses the caller's `.env`; without either file, uses the process variable. Repository-local `.env` files are supported. |
| Missing token, missing explicit file, malformed selected file, or conflicting Windows User-scoped token | Stops without exposing credentials or changing persisted environment variables. |
| tcli version check prints a version with exit code 1, returns no version, or cannot start | Accepts the documented version-output case only; missing/invalid output and startup failures stop before building or publication. |
| Failed restore/build/pack or invalid ZIP | Never invokes tcli publication and never falls back to an older ZIP. |
| Generated configuration | Contains only `dyson-sphere-program`, explicitly empty categories, and no credential values. Check the parsed tcli metadata as well as the TOML text. |
| Existing remote version, unexpected HTTP failure, tcli failure, or uncertain timeout | Returns a nonzero result and provides an appropriate next step; no automatic republish or version bump. |
@@ -140,12 +141,13 @@ Use focused command stubs for publication/error-path checks with a synthetic tok
## Verified upstream behavior
Sources checked on 2026-10-17:
Sources checked on 2026-10-17; command entry point checked on 2026-10-18:
- [tcli publishing and authentication documentation](https://github.com/thunderstore-io/thunderstore-cli/wiki): `TCLI_AUTH_TOKEN`, namespace, and publishing an existing ZIP with `--file`.
- [NuGet tcli versions](https://api.nuget.org/v3-flatcontainer/tcli/index.json): currently available tool versions.
- [MSBuild property and item evaluation](https://learn.microsoft.com/en-us/visualstudio/msbuild/evaluate-items-and-properties): evaluated metadata and JSON output in MSBuild 17.8 and newer.
- [tcli 0.2.4 configuration model](https://github.com/thunderstore-io/thunderstore-cli/blob/0.2.4/ThunderstoreCLI/Models/ThunderstoreProject.cs) and [upload metadata](https://github.com/thunderstore-io/thunderstore-cli/blob/0.2.4/ThunderstoreCLI/Configuration/Config.cs): category defaults, the empty-array mapping, and publishing metadata.
- [tcli 0.2.4 environment provider](https://github.com/thunderstore-io/thunderstore-cli/blob/0.2.4/ThunderstoreCLI/Configuration/EnvironmentConfig.cs): Windows User-scope precedence.
- [tcli 0.2.4 command entry point](https://github.com/thunderstore-io/thunderstore-cli/blob/0.2.4/ThunderstoreCLI/Program.cs): parser results, including version/help output, return exit code 1.
- [Thunderstore upload form](https://github.com/thunderstore-io/Thunderstore/blob/685b2743035e0ac0786180d10813d67b72fcdc2d/django/thunderstore/repository/package_upload.py) and [listing update behavior](https://github.com/thunderstore-io/Thunderstore/blob/685b2743035e0ac0786180d10813d67b72fcdc2d/django/thunderstore/repository/models/package.py): empty submitted categories retain existing listing categories.
- [Thunderstore manifest serializer](https://github.com/thunderstore-io/Thunderstore/blob/685b2743035e0ac0786180d10813d67b72fcdc2d/django/thunderstore/repository/package_manifest.py): standard manifest fields and duplicate-version validation.