Visitar URL original
Add release workflow for automatic PyPI and NuGet publishing on tags · pythonnet/pythonnet@8923e9b · GitHub
Skip to content

Commit 8923e9b

Browse files
Copilotfilmor
andauthored
Add release workflow for automatic PyPI and NuGet publishing on tags
Co-authored-by: filmor <30848+filmor@users.noreply.github.com>
1 parent deca529 commit 8923e9b

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 30
14+
15+
env:
16+
PYTHONNET_SHUTDOWN_MODE: Normal
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v7
21+
22+
- name: Setup .NET
23+
uses: actions/setup-dotnet@v6
24+
with:
25+
dotnet-version: '10.0.x'
26+
27+
- name: Set up Python
28+
uses: astral-sh/setup-uv@v7
29+
with:
30+
python-version: cpython-3.11
31+
cache-python: true
32+
activate-environment: true
33+
enable-cache: true
34+
35+
- name: Install dependencies
36+
run: uv sync --managed-python
37+
38+
- name: Set Python DLL path
39+
run: |
40+
echo PYTHONNET_PYDLL=$(python -m find_libpython) >> $GITHUB_ENV
41+
42+
- name: Python Tests
43+
run: pytest
44+
45+
- name: Embedding tests
46+
run: dotnet test --runtime any-ubuntu src/embed_tests/
47+
48+
- name: Build wheels and sdist
49+
run: |
50+
uv build
51+
uv build --wheel -C="--global-option=--net46-support"
52+
53+
- name: Build NuGet package
54+
run: |
55+
dotnet pack --configuration Release --output nuget-dist
56+
57+
- name: Upload PyPI artifacts
58+
uses: actions/upload-artifact@v7
59+
with:
60+
name: pypi-artifacts
61+
path: dist/
62+
if-no-files-found: error
63+
64+
- name: Upload NuGet artifacts
65+
uses: actions/upload-artifact@v7
66+
with:
67+
name: nuget-artifacts
68+
path: nuget-dist/
69+
if-no-files-found: error
70+
71+
publish-pypi:
72+
name: Publish to PyPI
73+
needs: build
74+
runs-on: ubuntu-latest
75+
permissions:
76+
id-token: write
77+
steps:
78+
- name: Download PyPI artifacts
79+
uses: actions/download-artifact@v8
80+
with:
81+
name: pypi-artifacts
82+
path: dist/
83+
84+
- name: Deploy to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1
86+
with:
87+
password: ${{ secrets.PYPI_API_TOKEN }}
88+
89+
publish-nuget:
90+
name: Publish to NuGet
91+
needs: build
92+
runs-on: ubuntu-latest
93+
environment: NuGet
94+
steps:
95+
- name: Download NuGet artifacts
96+
uses: actions/download-artifact@v8
97+
with:
98+
name: nuget-artifacts
99+
path: nuget-dist/
100+
101+
- name: Setup .NET
102+
uses: actions/setup-dotnet@v6
103+
with:
104+
dotnet-version: '10.0.x'
105+
106+
- name: Deploy to NuGet
107+
run: |
108+
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY || secrets.NUGET_MONTHLY }} --skip-duplicate nuget-dist/*.nupkg
109+
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY || secrets.NUGET_MONTHLY }} --skip-duplicate nuget-dist/*.snupkg

‎pythonnet.slnx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<File Path=".github/workflows/ARM.yml" />
1515
<File Path=".github/workflows/main.yml" />
1616
<File Path=".github/workflows/nuget-preview.yml" />
17+
<File Path=".github/workflows/release.yml" />
1718
</Folder>
1819
<Folder Name="/Repo/">
1920
<File Path=".editorconfig" />

0 commit comments

Comments
 (0)