Skip to content

Commit 6c81c4e

Browse files
committed
ci: add github actions and nuget publish pipeline
1 parent 8a82720 commit 6c81c4e

File tree

3 files changed

+122
-4
lines changed

3 files changed

+122
-4
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: windows-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: 8.0.x
24+
25+
- name: Restore
26+
run: dotnet restore YCode.Designer.Fluxo.sln
27+
28+
- name: Build
29+
run: dotnet build YCode.Designer.Fluxo.sln --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
30+
31+
- name: Pack library
32+
run: dotnet pack YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj --configuration Release --no-build --output artifacts /p:ContinuousIntegrationBuild=true /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg
33+
34+
- name: Upload package artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: nuget-package
38+
path: |
39+
artifacts/*.nupkg
40+
artifacts/*.snupkg
41+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Publish NuGet
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
runs-on: windows-latest
15+
permissions:
16+
contents: read
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: 8.0.x
27+
28+
- name: Restore
29+
run: dotnet restore YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj
30+
31+
- name: Build
32+
run: dotnet build YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
33+
34+
- name: Pack
35+
run: dotnet pack YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj --configuration Release --no-build --output artifacts /p:ContinuousIntegrationBuild=true /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg
36+
37+
- name: Validate publishing configuration
38+
shell: bash
39+
run: |
40+
if [[ -z "${{ vars.NUGET_USER }}" && -z "${{ secrets.NUGET_API_KEY }}" ]]; then
41+
echo "Configure either repo variable NUGET_USER for Trusted Publishing or secret NUGET_API_KEY for classic publishing."
42+
exit 1
43+
fi
44+
45+
- name: NuGet login with Trusted Publishing
46+
if: ${{ vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '' }}
47+
id: nuget-login
48+
uses: NuGet/login@v1
49+
with:
50+
user: ${{ vars.NUGET_USER }}
51+
52+
- name: Push package with Trusted Publishing
53+
if: ${{ vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '' }}
54+
run: |
55+
dotnet nuget push "artifacts/*.nupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
56+
dotnet nuget push "artifacts/*.snupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
57+
58+
- name: Push package with classic API key
59+
if: ${{ secrets.NUGET_API_KEY != '' }}
60+
run: |
61+
dotnet nuget push "artifacts/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
62+
dotnet nuget push "artifacts/*.snupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
63+
64+
- name: Upload published artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: published-nuget-package
68+
path: |
69+
artifacts/*.nupkg
70+
artifacts/*.snupkg

YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
<Nullable>enable</Nullable>
66
<UseWPF>true</UseWPF>
77
<ImplicitUsings>enable</ImplicitUsings>
8+
<PackageId>YCode.Designer.Fluxo</PackageId>
89
<Title>YCode.Designer.Fluxo</Title>
910
<Authors>YCode</Authors>
1011
<Description>YCode.Designer.Fluxo aims to explore graphical visual development in WPF, providing WPF developers with insights into implementing features like node dragging, flow editing, and other visual software development concepts.</Description>
1112
<Copyright>Copyright (c) 2024 YCode</Copyright>
12-
<PackageProjectUrl>https://github.com/lyq-lin/YCode.Designer.Fluxo</PackageProjectUrl>
13-
<PackageLicenseUrl>https://licenses.nuget.org/MIT</PackageLicenseUrl>
13+
<PackageProjectUrl>https://github.com/ycode-lin/YCode.Designer.Fluxo</PackageProjectUrl>
14+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1415
<PackageIcon>Fluxo.png</PackageIcon>
15-
<RepositoryUrl>https://github.com/lyq-lin/YCode.Designer.Fluxo.git</RepositoryUrl>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<RepositoryUrl>https://github.com/ycode-lin/YCode.Designer.Fluxo.git</RepositoryUrl>
1618
<RepositoryType>git</RepositoryType>
1719
<PackageTags>WPF;MVVM;Controls;Node Editor;</PackageTags>
1820
<PackageReleaseNotes>This version is the Preview version.</PackageReleaseNotes>
19-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
21+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2022
<Version>1.1.1048</Version>
2123
</PropertyGroup>
2224

@@ -33,6 +35,11 @@
3335
<PackagePath></PackagePath>
3436
<Link>Fluxo.png</Link>
3537
</None>
38+
<None Include="..\README.md">
39+
<Pack>True</Pack>
40+
<PackagePath>\</PackagePath>
41+
<Link>README.md</Link>
42+
</None>
3643
</ItemGroup>
3744

3845
</Project>

0 commit comments

Comments
 (0)