Skip to content

Commit a4bf776

Browse files
JusterZhuclaude
andcommitted
feat: add .slnx solution file and NuGet publish workflow
- Create GeneralUpdate.Avalonia.slnx to manage library and test projects - Add Directory.Build.props for centralized versioning (SemVer 2.0) - Update global.json rollForward to latestMajor for .slnx support - Update ci-cd.yml to use .slnx and add .NET 10 SDK - Add publish-nuget.yml for manual workflow with version input, git tag, GitHub Release, and optional NuGet.org push Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b7e4e18 commit a4bf776

7 files changed

Lines changed: 129 additions & 7 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ jobs:
2323
- name: Setup .NET
2424
uses: actions/setup-dotnet@v4
2525
with:
26-
dotnet-version: 8.0.x
26+
dotnet-version: |
27+
8.0.x
28+
10.0.x
2729
28-
- name: Restore test project
29-
run: dotnet restore tests/GeneralUpdate.Avalonia.Android.Tests/GeneralUpdate.Avalonia.Android.Tests.csproj
30+
- name: Restore
31+
run: dotnet restore GeneralUpdate.Avalonia.slnx
3032

3133
- name: Run unit tests
3234
run: dotnet test tests/GeneralUpdate.Avalonia.Android.Tests/GeneralUpdate.Avalonia.Android.Tests.csproj --configuration Release --no-restore
@@ -43,13 +45,15 @@ jobs:
4345
- name: Setup .NET
4446
uses: actions/setup-dotnet@v4
4547
with:
46-
dotnet-version: 8.0.x
48+
dotnet-version: |
49+
8.0.x
50+
10.0.x
4751
4852
- name: Install Android workload
4953
run: dotnet workload install android
5054

51-
- name: Restore Android project
52-
run: dotnet restore src/GeneralUpdate.Avalonia.Android/GeneralUpdate.Avalonia.Android.csproj
55+
- name: Restore
56+
run: dotnet restore GeneralUpdate.Avalonia.slnx
5357

5458
- name: Build Android project
5559
run: dotnet build src/GeneralUpdate.Avalonia.Android/GeneralUpdate.Avalonia.Android.csproj --configuration Release --no-restore
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish NuGet
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'NuGet package version (SemVer 2.0, e.g. 1.0.0, 1.0.0-beta.1)'
8+
required: true
9+
type: string
10+
push-to-nuget:
11+
description: 'Push package to NuGet.org'
12+
required: false
13+
type: boolean
14+
default: true
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
publish:
21+
name: Build and Publish
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Validate SemVer 2.0
31+
run: |
32+
if ! echo "${{ inputs.version }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$' > /dev/null; then
33+
echo "::error::Invalid SemVer 2.0 version: '${{ inputs.version }}'"
34+
exit 1
35+
fi
36+
echo "Version ${{ inputs.version }} is valid SemVer 2.0"
37+
38+
- name: Setup .NET
39+
uses: actions/setup-dotnet@v4
40+
with:
41+
dotnet-version: 8.0.x
42+
43+
- name: Install Android workload
44+
run: dotnet workload install android
45+
46+
- name: Restore
47+
run: dotnet restore GeneralUpdate.Avalonia.slnx
48+
49+
- name: Build
50+
run: dotnet build GeneralUpdate.Avalonia.slnx --configuration Release --no-restore /p:Version=${{ inputs.version }}
51+
52+
- name: Run tests
53+
run: dotnet test GeneralUpdate.Avalonia.slnx --configuration Release --no-restore --no-build /p:Version=${{ inputs.version }}
54+
55+
- name: Pack NuGet
56+
run: dotnet pack GeneralUpdate.Avalonia.slnx --configuration Release --no-restore --no-build -o artifacts /p:Version=${{ inputs.version }}
57+
58+
- name: List artifacts
59+
run: ls -la artifacts/
60+
61+
- name: Create git tag
62+
run: |
63+
git config user.name "github-actions"
64+
git config user.email "github-actions@github.com"
65+
TAG="v${{ inputs.version }}"
66+
git tag "$TAG"
67+
git push origin "$TAG"
68+
69+
- name: Create GitHub Release
70+
env:
71+
GH_TOKEN: ${{ github.token }}
72+
run: |
73+
TAG="v${{ inputs.version }}"
74+
gh release create "$TAG" \
75+
artifacts/*.nupkg \
76+
--title "$TAG" \
77+
--notes "Release of GeneralUpdate.Avalonia version **${{ inputs.version }}**" \
78+
--verify-tag
79+
80+
- name: Push NuGet package
81+
if: ${{ inputs.push-to-nuget == true }}
82+
run: |
83+
dotnet nuget push artifacts/*.nupkg \
84+
--api-key ${{ secrets.NUGET_API_KEY }} \
85+
--source https://api.nuget.org/v3/index.json \
86+
--skip-duplicate

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Version Condition="'$(Version)' == ''">0.0.0-dev</Version>
4+
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">$(Version)</AssemblyVersion>
5+
<FileVersion Condition="'$(FileVersion)' == ''">$(Version)</FileVersion>
6+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
7+
<RepositoryType>git</RepositoryType>
8+
</PropertyGroup>
9+
</Project>

GeneralUpdate.Avalonia.slnx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Solution>
2+
<Project Path="src/GeneralUpdate.Avalonia.Android/GeneralUpdate.Avalonia.Android.csproj" />
3+
<Project Path="tests/GeneralUpdate.Avalonia.Android.Tests/GeneralUpdate.Avalonia.Android.Tests.csproj" />
4+
</Solution>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"rollForward": "latestMajor",
55
"allowPrerelease": true
66
}
7-
}
7+
}

src/.idea/.idea.GeneralUpdate.Avalonia/.idea/.gitignore

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/.idea/.idea.GeneralUpdate.Avalonia/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)