-
Notifications
You must be signed in to change notification settings - Fork 57
114 lines (99 loc) · 4.29 KB
/
release-publish.yml
File metadata and controls
114 lines (99 loc) · 4.29 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Release and Publish NuGet
on:
release:
types: [created]
workflow_dispatch:
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_AUTH_TOKEN: ${{secrets.PUBLISH_TO_NUGET_ORG}}
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v5
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.403'
- name: Extract version from Directory.Build.props
id: extract_version
run: |
[xml]$xml = Get-Content -Path "Directory.Build.props"
$version = $xml.SelectSingleNode("//TimeWarpStateVersion").InnerText
echo "Extracted version (raw): '$version'"
$version = $version.Trim()
echo "Extracted version (trimmed): '$version'"
echo "version=$version" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Validate release version matches tag
run: |
$releaseVersion = "${{ steps.extract_version.outputs.version }}"
$tagName = "${{ github.event.release.tag_name }}"
echo "Release version: $releaseVersion"
echo "Tag name: $tagName"
echo "Event name: ${{ github.event_name }}"
# Only validate tag match for actual release events, not manual dispatch
if ("${{ github.event_name }}" -eq "release") {
if ($releaseVersion -ne $tagName) {
throw "Release version ($releaseVersion) does not match tag name ($tagName)"
}
echo "✅ Release version matches tag name"
} else {
echo "⚠️ Manual dispatch - skipping tag validation"
}
shell: pwsh
- name: Run BuildNuGets.ps1
run: |
.\BuildNuGets.ps1
working-directory: ${{ github.workspace }}
- name: Publish TimeWarp.State
run: |
cd Source/TimeWarp.State/bin/Release
if (!(Test-Path "TimeWarp.State.*.nupkg")) {
throw "NuGet package not found for TimeWarp.State"
}
dotnet nuget push TimeWarp.State.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
if ($LASTEXITCODE -ne 0) {
throw "Failed to publish TimeWarp.State"
}
working-directory: ${{ github.workspace }}
- name: Publish TimeWarp.State.Plus
run: |
cd Source/TimeWarp.State.Plus/bin/Release
if (!(Test-Path "TimeWarp.State.Plus.*.nupkg")) {
throw "NuGet package not found for TimeWarp.State.Plus"
}
dotnet nuget push TimeWarp.State.Plus.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
if ($LASTEXITCODE -ne 0) {
throw "Failed to publish TimeWarp.State.Plus"
}
working-directory: ${{ github.workspace }}
- name: Publish TimeWarp.State.Policies
run: |
cd Source/TimeWarp.State.Policies/bin/Release
if (!(Test-Path "TimeWarp.State.Policies.*.nupkg")) {
throw "NuGet package not found for TimeWarp.State.Policies"
}
dotnet nuget push TimeWarp.State.Policies.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
if ($LASTEXITCODE -ne 0) {
throw "Failed to publish TimeWarp.State.Policies"
}
working-directory: ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."