Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
63 changes: 0 additions & 63 deletions .github/workflows/nuget-preview.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish NuGet

# Run manually to build the package with the version in Python.Runtime.csproj and push it to nuget.org
on: workflow_dispatch

jobs:
publish:
# Only publish what is merged, a pushed version can't be replaced
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # lets NuGet/login exchange the GitHub OIDC token for a short-lived nuget.org API key
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false

- uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

# The temporary API key expires after 1 hour, plenty for the build below
- name: NuGet login
id: login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}

- name: Build and push
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
run: ./build_push_nuget.sh
25 changes: 25 additions & 0 deletions build_push_nuget.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Builds Python.Runtime, packs the QuantConnect.pythonnet NuGet and symbol packages into ./artifacts
# with the <Version> in Python.Runtime.csproj and pushes them to nuget.org when NUGET_API_KEY is set
#
# Requires git and the .NET 10 SDK.
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT="$ROOT/src/runtime/Python.Runtime.csproj"
OUTPUT="$ROOT/artifacts"

# Everything under pythonnet/ is packed as content, so drop stale build outputs and __pycache__ first
git -C "$ROOT" clean -fdXq -- pythonnet

echo "Packing NuGet package"
rm -rf "$OUTPUT"
dotnet pack "$PROJECT" --configuration Release --output "$OUTPUT"

ls "$OUTPUT"

if [[ -n "${NUGET_API_KEY:-}" ]]; then
echo "Pushing to nuget.org"
# Also pushes the .snupkg symbol package next to it
dotnet nuget push "$OUTPUT"/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
fi
2 changes: 1 addition & 1 deletion src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<PackagePath>contentFiles/any/any/</PackagePath>
<PackageCopyToOutput>true</PackageCopyToOutput>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="../../pythonnet/**">
<TfmSpecificPackageFile Include="../../pythonnet/**" Exclude="../../pythonnet/**/.*">
<PackagePath>contentFiles/any/any/pythonnet</PackagePath>
<PackageCopyToOutput>true</PackageCopyToOutput>
</TfmSpecificPackageFile>
Expand Down
Loading