Skip to content

Commit d2a802f

Browse files
authored
Merge pull request #2 from pictos/publish-nuget
Update CI/CD workflows for MAUI and NuGet packaging
2 parents 4e883f8 + a801eb8 commit d2a802f

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

.github/workflows/dotnet-macos.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,28 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v4
25+
2526
- name: Setup .NET
2627
uses: actions/setup-dotnet@v4
2728
with:
2829
dotnet-version: 9.0.x
30+
2931
- name: Setup Xcode
3032
uses: maxim-lobanov/setup-xcode@v1
3133
with:
3234
xcode-version: '16.3'
35+
3336
- name: Workload install
3437
run: dotnet workload install maui
38+
3539
- name: Restore library dependencies
3640
run: dotnet restore ${{env.LIB_CSPROJ}}
41+
3742
- name: Restore sample dependencies
3843
run: dotnet restore
44+
3945
- name: Build library
4046
run: dotnet build ${{env.LIB_CSPROJ}} -c Release -f net9.0-ios --no-restore
47+
4148
- name: Build Sample app
4249
run: dotnet build ${{env.SAMPLE_CSPROJ}} -c Release -f net9.0-ios --no-restore

.github/workflows/dotnet-windows.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
env:
1515
LIB_CSPROJ: PJ.NavigationTrans.Maui/PJ.NavigationTrans.Maui.csproj
1616
SAMPLE_CSPROJ: PJ.NavigationTrans.Sample/PJ.NavigationTrans.Sample.csproj
17+
NugetPackageVersion: '99.0.0-preview${{ github.run_number }}'
18+
CurrentSemanticVersionBase: '99.0.0'
1719

1820
jobs:
1921
build:
@@ -22,17 +24,50 @@ jobs:
2224

2325
steps:
2426
- uses: actions/checkout@v4
27+
2528
- name: Setup .NET
2629
uses: actions/setup-dotnet@v4
2730
with:
2831
dotnet-version: 9.0.x
32+
33+
- name: Get Nuget version and Name for PR
34+
if: ${{ github.event_name == 'pull_request' }}
35+
run: |
36+
echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
37+
shell: bash
38+
2939
- name: Workload install
3040
run: dotnet workload install maui
41+
3142
- name: Restore library dependencies
3243
run: dotnet restore ${{env.LIB_CSPROJ}}
44+
3345
- name: Restore sample dependencies
3446
run: dotnet restore
47+
3548
- name: Build library
36-
run: dotnet build ${{env.LIB_CSPROJ}} -c Release --no-restore
49+
run: dotnet build ${{env.LIB_CSPROJ}} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }} --no-restore
50+
3751
- name: Build Sample app
3852
run: dotnet build ${{env.SAMPLE_CSPROJ}} -c Release --no-restore
53+
54+
- name: Create Nuget
55+
run: dotnet pack ${{env.LIB_CSPROJ}} -c Release --no-restore --no-build --include-symbols --include-source
56+
57+
- name: Copy NuGet Packages to Staging Directory
58+
if: ${{ runner.os == 'Windows' && !startsWith(github.ref, 'refs/tags/') }}
59+
run: |
60+
mkdir -p ${{ github.workspace }}/nuget
61+
Get-ChildItem -Path "./PJ.NavigationTrans.Maui/" -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget"
62+
shell: pwsh
63+
64+
- name: List NuGet packages found
65+
run: |
66+
Get-ChildItem -Path "${{ github.workspace }}/nuget" | Format-Table Name
67+
shell: pwsh
68+
69+
- name: Publish Packages
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: packages
73+
path: ${{ github.workspace }}/nuget/

PJ.NavigationTrans.Sample/PJ.NavigationTrans.Sample.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
<OutputType>Exe</OutputType>
1717
<RootNamespace>PJ.NavigationTrans.Sample</RootNamespace>
18+
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
1819

1920
<!-- Display name -->
2021
<ApplicationTitle>PJ.NavigationTrans.Sample</ApplicationTitle>

0 commit comments

Comments
 (0)