-
Notifications
You must be signed in to change notification settings - Fork 321
97 lines (79 loc) · 3.42 KB
/
nuget-publish.yml
File metadata and controls
97 lines (79 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Publish a NuGet package
on:
push:
branches:
- main
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .
# Configuration type to build.
# You can convert this to a build matrix if you need coverage of multiple configuration types.
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Release
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
# Add additional configurations if needed.
configuration: [Release, Debug]
# If you need to build for multiple platforms, you can add them here.
platform: [x64, x86, ARM64]
steps:
- uses: actions/checkout@v3
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Build
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} ${{env.SOLUTION_FILE_PATH}}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.configuration }}-${{ matrix.platform }}
path: |
${{ matrix.platform == 'x86' && 'Win32' || matrix.platform }}/${{ matrix.configuration }}/api/pict.lib
${{ matrix.platform == 'x86' && 'Win32' || matrix.platform }}/${{ matrix.configuration }}/cli/*.exe
${{ matrix.platform == 'x86' && 'Win32' || matrix.platform }}/${{ matrix.configuration }}/cli/*.pdb
${{ matrix.platform == 'x86' && 'Win32' || matrix.platform }}/${{ matrix.configuration }}/clidll/*.dll
${{ matrix.platform == 'x86' && 'Win32' || matrix.platform }}/${{ matrix.configuration }}/clidll/*.pdb
retention-days: 1
package:
runs-on: windows-latest
needs: build
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Restore build structure
run: |
# Copy artifacts back to original build structure
Get-ChildItem -Path "artifacts" -Directory | ForEach-Object {
$artifactName = $_.Name
if ($artifactName -match "build-artifacts-(.+)-(.+)") {
$config = $matches[1]
$platform = $matches[2]
# Map platform names to match directory structure
$platformDir = $platform
if ($platform -eq "x86") {
$platformDir = "Win32"
}
# Create the target directory structure (platform/configuration)
$targetDir = "$platformDir/$config"
if (!(Test-Path $targetDir)) {
New-Item -ItemType Directory -Path $targetDir -Force
}
# Copy contents preserving structure
Copy-Item -Path "$($_.FullName)/*" -Destination $targetDir -Recurse -Force
}
}
- name: Add NUGET to PATH
uses: NuGet/setup-nuget@v2
- name: Create a package
run: nuget pack
- name: Publish NuGet package
run: dotnet nuget push "Microsoft.Test.Pict.*.nupkg" -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/microsoft/index.json --skip-duplicate