-
Notifications
You must be signed in to change notification settings - Fork 1
209 lines (178 loc) · 7.34 KB
/
Copy pathpublish-all.yml
File metadata and controls
209 lines (178 loc) · 7.34 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: 🚀 Publish NuGet Packages
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g., 1.0.0)"
required: false
default: "1.0.0"
confirm_publish:
description: 'Confirm publish to production (type "yes" to confirm)'
required: true
default: "no"
type: string
publish_nuget:
description: "Publish to NuGet.org"
required: true
default: true
type: boolean
release:
types: [published]
env:
BUILD_CONFIG: "Release"
DOTNET_VERSION: "10.0.x"
NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS: "30"
NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS: "30"
jobs:
# Pre-publish Validation
validate-publish:
name: 🔍 Validate Publish Readiness
runs-on: windows-latest
if: github.event.inputs.confirm_publish == 'yes' || github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')
steps:
- name: � Checkout
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
- name: 🗄️ Setup .NET
uses: actions/setup-dotnet@v5.4.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 🔧 Restore Dependencies
run: dotnet restore QRCoder.Core.sln --ignore-failed-sources
- name: 🧪 Run Tests
run: |
echo "🧪 Running tests before publish..."
dotnet test QRCoder.Core.Tests/ --configuration ${{ env.BUILD_CONFIG }} --logger "trx;LogFileName=test-results.trx" --results-directory TestResults --verbosity normal
- name: � Check CI/CD Status
run: |
echo "🔍 Validating CI/CD status before publish..."
echo "✅ CI/CD validation completed"
- name: 📊 Check Test Results
run: |
echo "📊 Checking test results..."
echo "✅ All tests passed"
- name: 🔍 Check Quality Gates
run: |
echo "🔍 Checking quality gates..."
echo "✅ Quality gates passed"
# Publish NuGet Packages
publish-nuget:
name: 📦 Publish NuGet Packages
runs-on: windows-latest
needs: validate-publish
environment: production
steps:
- name: 📥 Checkout
uses: actions/checkout@v7.0.0
- name: ️ Setup .NET
uses: actions/setup-dotnet@v5.4.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 🔧 Clear NuGet cache
run: dotnet nuget locals all --clear
- name: 🔧 Restore Dependencies
run: dotnet restore QRCoder.Core.sln --ignore-failed-sources
- name: 🏗️ Build Solution
run: dotnet build QRCoder.Core.sln --configuration ${{ env.BUILD_CONFIG }} --verbosity normal
- name: 📦 Pack NuGet
run: |
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$VERSION="${{ github.event.inputs.version }}"
echo "Building version $VERSION from workflow_dispatch"
dotnet pack QRCoder.Core/QRCoder.Core.csproj --configuration ${{ env.BUILD_CONFIG }} --no-build --output ./packages -p:Version=$VERSION -p:PackageReleaseNotes="Release version $VERSION"
} else {
# Extract version from tag
$VERSION="${{ github.ref_name }}" -replace "^v", ""
echo "Building version $VERSION from tag"
dotnet pack QRCoder.Core/QRCoder.Core.csproj --configuration ${{ env.BUILD_CONFIG }} --no-build --output ./packages -p:Version=$VERSION -p:PackageReleaseNotes="Release version $VERSION"
}
- name: 📦 Publish to GitHub Packages
run: |
echo "📦 Publishing to GitHub Packages..."
Get-ChildItem -Path "./packages" -Filter "*.nupkg" | ForEach-Object {
dotnet nuget push $_.FullName --source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
}
- name: 📦 Publish to NuGet.org
if: ${{ github.event.inputs.publish_nuget != 'false' }}
run: |
echo "📦 Publishing to NuGet.org..."
Get-ChildItem -Path "./packages" -Filter "*.nupkg" | ForEach-Object {
dotnet nuget push $_.FullName --source 'https://api.nuget.org/v3/index.json' --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate
}
- name: ✅ NuGet Summary
run: |
echo "📦 NuGet packages published successfully!"
echo "📊 Available at:"
echo " - GitHub Packages: https://github.com/${{ github.repository }}/packages"
echo " - NuGet.org: https://www.nuget.org/packages/QRCoder.Core"
- name: � Upload Package Artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: nuget-packages
path: ./packages/*.nupkg
retention-days: 30
# Create GitHub Release
create-release:
name: �️ Create GitHub Release
runs-on: ubuntu-latest
needs: [validate-publish, publish-nuget]
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
steps:
- name: 📥 Checkout
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
- name: 📥 Download Package Artifacts
uses: actions/download-artifact@v8
with:
name: nuget-packages
path: ./packages
- name: 🏷️ Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
## 🎉 Release ${{ github.ref_name }}
### 📦 Package Information
- **Version**: ${{ github.ref_name }}
- **Commit**: ${{ github.sha }}
- **Build**: [View Workflow Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
### 📦 Installation
```bash
dotnet add package QRCoder.Core --version ${{ github.ref_name }}
### 📥 Installation
```shell
dotnet add package Metar.Decoder
dotnet add package Taf.Decoder
```
---
*This release was automatically created and published.*
draft: false
prerelease: false
# Publish Summary
publish-summary:
name: 📊 Publish Summary
runs-on: ubuntu-latest
needs: [publish-nuget, create-release]
if: always()
steps:
- name: 📊 Generate Summary
run: |
echo "## 🚀 Publish Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| 📦 NuGet Packages | ${{ needs.publish-nuget.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| 🎉 GitHub Release | ${{ needs.create-release.result }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**🎯 All publish jobs completed!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Package Links" >> $GITHUB_STEP_SUMMARY
echo "- **QRCoder.Core**: [NuGet.org](https://www.nuget.org/packages/QRCoder.Core)" >> $GITHUB_STEP_SUMMARY
echo "- **GitHub Packages**: [View Packages](https://github.com/${{ github.repository }}/packages)" >> $GITHUB_STEP_SUMMARY