Skip to content

Commit 214cddd

Browse files
committed
build file updated
1 parent fc1ec88 commit 214cddd

1 file changed

Lines changed: 31 additions & 63 deletions

File tree

.github/workflows/dotnet-desktop.yml

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -36,80 +36,48 @@
3636
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
3737
# refer to https://github.com/microsoft/github-actions-for-desktop-apps
3838

39-
name: .NET Core Desktop
39+
name: .NET Build, Test and Publish
4040

4141
on:
4242
push:
43-
branches: [ "main" ]
43+
branches: ["main"]
44+
tags: ["v*"]
4445
pull_request:
45-
branches: [ "main" ]
46+
branches: ["main"]
4647

47-
jobs:
48-
49-
build:
50-
51-
strategy:
52-
matrix:
53-
configuration: [Debug, Release]
54-
55-
runs-on: windows-latest # For a list of available runner types, refer to
56-
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
48+
env:
49+
SOLUTION_PATH: SimpleMapper/SimpleMapper.sln
50+
TEST_PROJECT_PATH: SimpleMapper/UnitTestXUnitNet6/UnitTestXUnitNet6.csproj
51+
PACKAGE_PROJECT_PATH: SimpleMapper/SimpleMapper/SimpleMapper.csproj
52+
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output
53+
NUGET_SOURCE_URL: https://api.nuget.org/v3/index.json
5754

58-
env:
59-
Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln.
60-
Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
61-
Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package.
62-
Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj.
55+
jobs:
56+
build-test-publish:
57+
runs-on: ubuntu-latest
6358

6459
steps:
65-
- name: Checkout
66-
uses: actions/checkout@v4
67-
with:
68-
fetch-depth: 0
69-
70-
# Install the .NET Core workload
71-
- name: Install .NET Core
72-
uses: actions/setup-dotnet@v4
73-
with:
74-
dotnet-version: 8.0.x
75-
76-
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
77-
- name: Setup MSBuild.exe
78-
uses: microsoft/setup-msbuild@v2
60+
- uses: actions/checkout@v3
7961

80-
# Execute all unit tests in the solution
81-
- name: Execute unit tests
82-
run: dotnet test
62+
- name: Setup .NET
63+
uses: actions/setup-dotnet@v3
64+
with:
65+
dotnet-version: 6.0.x
8366

84-
# Restore the application to populate the obj folder with RuntimeIdentifiers
85-
- name: Restore the application
86-
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
87-
env:
88-
Configuration: ${{ matrix.configuration }}
67+
- name: Restore dependencies
68+
run: dotnet restore ${{ env.SOLUTION_PATH }}
8969

90-
# Decode the base 64 encoded pfx and save the Signing_Certificate
91-
- name: Decode the pfx
92-
run: |
93-
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
94-
$certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
95-
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
70+
- name: Build
71+
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore
9672

97-
# Create the app package by building and packaging the Windows Application Packaging project
98-
- name: Create the app package
99-
run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
100-
env:
101-
Appx_Bundle: Always
102-
Appx_Bundle_Platforms: x86|x64
103-
Appx_Package_Build_Mode: StoreUpload
104-
Configuration: ${{ matrix.configuration }}
73+
- name: Test
74+
run: dotnet test ${{ env.TEST_PROJECT_PATH }} --configuration Release --no-build --verbosity normal
10575

106-
# Remove the pfx
107-
- name: Remove the pfx
108-
run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx
76+
# Only run the packaging and publishing steps if we're pushing a tag
77+
- name: Pack
78+
if: startsWith(github.ref, 'refs/tags/v')
79+
run: dotnet pack ${{ env.PACKAGE_PROJECT_PATH }} --configuration Release --no-build --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
10980

110-
# Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact
111-
- name: Upload build artifacts
112-
uses: actions/upload-artifact@v4
113-
with:
114-
name: MSIX Package
115-
path: ${{ env.Wap_Project_Directory }}\AppPackages
81+
- name: Publish to NuGet
82+
if: startsWith(github.ref, 'refs/tags/v')
83+
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg --source ${{ env.NUGET_SOURCE_URL }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate

0 commit comments

Comments
 (0)