-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (85 loc) · 3.43 KB
/
Copy pathPublishTestAdapter.yml
File metadata and controls
96 lines (85 loc) · 3.43 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
name: Publish Test Adapter
on:
workflow_dispatch:
inputs:
push:
description: "Push RevitDevTool.TestAdapter to nuget.org (OIDC Trusted Publishing)"
type: boolean
default: true
nuget_user:
description: "nuget.org username (profile name, not email). Required when pushing unless NUGET_USER secret exists."
required: false
type: string
concurrency:
group: publish-test-adapter
cancel-in-progress: false
permissions:
contents: read
id-token: write
jobs:
windows:
name: windows-2025
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-test-adapter-${{ hashFiles('source/DevTools.TestAdapter/**/*.csproj', 'source/DevTools.NUnit.MTP/**/*.csproj', 'source/DevTools.Testing.Abstractions/**/*.csproj', 'source/DevTools.Testing.Transport/**/*.csproj', 'source/DevTools.Ipc/**/*.csproj', 'Directory.Build.props', 'Directory.Packages.props') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Pack RevitDevTool.TestAdapter
id: pack
shell: pwsh
run: |
$csproj = "source/DevTools.TestAdapter/DevTools.TestAdapter.csproj"
$version = (dotnet msbuild $csproj -nologo -v:q -getProperty:Version).Trim()
if ([string]::IsNullOrWhiteSpace($version)) {
throw "Could not read Version from $csproj"
}
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
Write-Host "Package version from csproj: $version"
./scripts/pack-test-adapter.ps1
- name: Upload nupkg
uses: actions/upload-artifact@v4
with:
name: RevitDevTool.TestAdapter.${{ steps.pack.outputs.version }}
path: output/nuget/RevitDevTool.TestAdapter.${{ steps.pack.outputs.version }}.nupkg
if-no-files-found: error
retention-days: 14
- name: Resolve nuget.org user
id: nuget-user
if: ${{ github.event.inputs.push == 'true' }}
shell: pwsh
env:
NUGET_USER_SECRET: ${{ secrets.NUGET_USER }}
NUGET_USER_INPUT: ${{ inputs.nuget_user }}
run: |
$user = if (-not [string]::IsNullOrWhiteSpace($env:NUGET_USER_SECRET)) {
$env:NUGET_USER_SECRET
} else {
$env:NUGET_USER_INPUT
}
if ([string]::IsNullOrWhiteSpace($user)) {
throw "Enter nuget.org profile name in the nuget_user input (not email), or set repository secret NUGET_USER."
}
"user=$user" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: NuGet login (OIDC)
if: ${{ github.event.inputs.push == 'true' }}
uses: NuGet/login@v1
id: login
with:
user: ${{ steps.nuget-user.outputs.user }}
- name: Push nuget.org
if: ${{ github.event.inputs.push == 'true' }}
shell: pwsh
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
PACKAGE_VERSION: ${{ steps.pack.outputs.version }}
run: |
$nupkg = "output/nuget/RevitDevTool.TestAdapter.$($env:PACKAGE_VERSION).nupkg"
if (-not (Test-Path -LiteralPath $nupkg)) {
throw "Missing $nupkg"
}
dotnet nuget push $nupkg --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY