Skip to content

Add GitHub workflow to build and publish the NuGet package - #155

Merged
Martin-Molinero merged 2 commits into
QuantConnect:masterfrom
Martin-Molinero:feature-nuget-publish-workflow
Oct 29, 2026
Merged

Martin-Molinero merged 2 commits into
QuantConnect:masterfrom
Martin-Molinero:feature-nuget-publish-workflow

Conversation

@Martin-Molinero

@Martin-Molinero Martin-Molinero commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Publishes QuantConnect.pythonnet to nuget.org from a manual GitHub Actions run, instead of packing and pushing it by hand.

To release: bump <Version> in src/runtime/Python.Runtime.csproj, merge, then run Publish NuGet from the Actions tab. nuget.org rejects versions that already exist, so a run without a version bump fails. The job only runs on master.

Changes

  • build_push_nuget.sh: packs the NuGet and symbol packages into artifacts/ with the csproj version and pushes them when NUGET_API_KEY is set. It first removes ignored files under pythonnet/ (build outputs, __pycache__), since everything in that folder is packed as content.
  • .github/workflows/publish.yml: manual workflow that gets a short-lived API key through nuget.org Trusted Publishing (NuGet/login) and runs the script.
  • Removed nuget-preview.yml: the upstream monthly preview job. It failed on every scheduled run (Aug, Sep and Oct 2026), never published a preview, and relied on a long-lived NUGET_MONTHLY key.
  • Python.Runtime.csproj: excludes dot-files from the packed pythonnet/** content. NuGet already leaves .gitignore and .gitkeep out of the package, but the nuspec still listed them; this also removes the two NU5119 warnings.
  • .gitattributes: *.sh is always checked out with LF so the script runs from Git Bash on Windows.

Why now

nuget.org API keys created before August 17, 2026 expire on November 1, 2026 and new keys only last 30 days (announcement).

Verification

Ran the script on a clean checkout of ba1b2ea (the commit 2.0.67 was built from) and compared it with the 2.0.67 package on nuget.org:

  • Same file list, and clr.py, the pythonnet Python files, deps.json, README, LICENSE and icon are byte-identical
  • The nuspec is identical except the branch attribute, which comes from the locally checked-out branch name (my test checkout was detached). actions/checkout creates a local master branch, so runs from master write the same refs/heads/master
  • Python.Runtime.dll has the same size; the 420 differing bytes are the build path, MVID, PE timestamp and strong-name signature (2.0.67 was built in C:\Users\jhona\...)

The workflow itself has not run yet.

Required setup before the first run

  • A Trusted Publishing policy on nuget.org, created by the package owner: repository owner QuantConnect, repository pythonnet, workflow file publish.yml
  • A NUGET_USER repository secret with the owner's nuget.org profile name

🤖 Generated with Claude Code

Martin-Molinero and others added 2 commits October 29, 2026 17:03
- Add build_push_nuget.sh, which packs the QuantConnect.pythonnet NuGet and
  symbol packages and pushes them when NUGET_API_KEY is set
- Add a workflow that runs it on published releases, using the release tag
  as the version and nuget.org Trusted Publishing (OIDC) instead of a
  long-lived API key. Manual runs only build the package
- Remove the upstream monthly preview workflow, which has been failing on
  every scheduled run and never published a package
- Exclude dot-files from the packed pythonnet/ content so the nuspec does
  not list the .gitignore and .gitkeep files NuGet leaves out
- Keep *.sh files with LF line endings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the version in the csproj instead of a release tag, so publishing is a
single manual run of the workflow from master. nuget.org rejects versions
that already exist, so a run without a version bump fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Martin-Molinero
Martin-Molinero merged commit bf7d5b5 into QuantConnect:master Oct 29, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant