-
Notifications
You must be signed in to change notification settings - Fork 0
306 lines (251 loc) · 10.5 KB
/
release-cli.yml
File metadata and controls
306 lines (251 loc) · 10.5 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
name: Release CLI
on:
push:
tags:
- "cli/v*"
- "cli-v*"
env:
DOTNET_VERSION: "10.0.x"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
extract-version:
name: Extract Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
major: ${{ steps.extract.outputs.major }}
minor: ${{ steps.extract.outputs.minor }}
patch: ${{ steps.extract.outputs.patch }}
steps:
- name: Extract version from tag
id: extract
run: |
if [[ "${{ github.ref }}" =~ ^refs/tags/cli/v(.+)$ ]]; then
VERSION="${BASH_REMATCH[1]}"
elif [[ "${{ github.ref }}" =~ ^refs/tags/cli-v(.+)$ ]]; then
VERSION="${BASH_REMATCH[1]}"
else
echo "Invalid tag format"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Extract major, minor, patch
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
echo "major=$MAJOR" >> $GITHUB_OUTPUT
echo "minor=$MINOR" >> $GITHUB_OUTPUT
echo "patch=$PATCH" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
echo "Major: $MAJOR, Minor: $MINOR, Patch: $PATCH"
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
needs: extract-version
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build CLI
run: dotnet build src/Lintellect.Cli/Lintellect.Cli.csproj --no-restore --configuration Release
- name: Build CLI tests
run: dotnet build tests/Lintellect.Cli.UnitTests/Lintellect.Cli.UnitTests.csproj --no-restore --configuration Release
- name: Run CLI unit tests
run: dotnet test tests/Lintellect.Cli.UnitTests/Lintellect.Cli.UnitTests.csproj --no-build --configuration Release --verbosity normal
- name: Verify version in project file
run: |
VERSION_IN_FILE=$(grep -oP '<Version>\K[^<]+' src/Lintellect.Cli/Lintellect.Cli.csproj)
PACKAGE_VERSION_IN_FILE=$(grep -oP '<PackageVersion>\K[^<]+' src/Lintellect.Cli/Lintellect.Cli.csproj)
if [ "$VERSION_IN_FILE" != "${{ needs.extract-version.outputs.version }}" ]; then
echo "Version mismatch: project file has $VERSION_IN_FILE, tag has ${{ needs.extract-version.outputs.version }}"
exit 1
fi
if [ "$PACKAGE_VERSION_IN_FILE" != "${{ needs.extract-version.outputs.version }}" ]; then
echo "PackageVersion mismatch: project file has $PACKAGE_VERSION_IN_FILE, tag has ${{ needs.extract-version.outputs.version }}"
exit 1
fi
echo "Version verification passed: $VERSION_IN_FILE"
build-nuget-package:
name: Build NuGet Package
runs-on: ubuntu-latest
needs: [extract-version, build-and-test]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build CLI
run: dotnet build src/Lintellect.Cli/Lintellect.Cli.csproj --no-restore --configuration Release
- name: Pack CLI
run: dotnet pack src/Lintellect.Cli/Lintellect.Cli.csproj --no-build --configuration Release --output ./packages
- name: Upload NuGet package
uses: actions/upload-artifact@v5
with:
name: nuget-package
path: ./packages
retention-days: 30
publish-nuget:
name: Publish to NuGet
runs-on: ubuntu-latest
needs: [extract-version, build-nuget-package]
steps:
- name: Download NuGet package
uses: actions/download-artifact@v6
with:
name: nuget-package
path: ./packages
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Publish to NuGet
run: |
dotnet nuget push ./packages/*.nupkg \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
build-binaries:
name: Build Binaries
runs-on: ${{ matrix.os }}
needs: [extract-version, build-and-test]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
platform: linux-x64
extension: tar.gz
executable: lintellect
- os: windows-latest
platform: win-x64
extension: zip
executable: lintellect.exe
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Publish CLI
run: |
dotnet publish src/Lintellect.Cli/Lintellect.Cli.csproj --configuration Release --runtime ${{ matrix.platform }} --self-contained true --output ./publish/cli --force
- name: Create binary archive (Windows)
if: runner.os == 'Windows'
run: Compress-Archive -Path "./publish/cli" -DestinationPath "./lintellect-cli-${{ needs.extract-version.outputs.version }}-${{ matrix.platform }}.${{ matrix.extension }}"
- name: Create binary archive (Linux)
if: runner.os == 'Linux'
run: tar -czf "./lintellect-cli-${{ needs.extract-version.outputs.version }}-${{ matrix.platform }}.${{ matrix.extension }}" -C ./publish/cli .
- name: Upload binary
uses: actions/upload-artifact@v5
with:
name: lintellect-cli-${{ matrix.platform }}
path: ./lintellect-cli-${{ needs.extract-version.outputs.version }}-${{ matrix.platform }}.${{ matrix.extension }}
retention-days: 30
generate-release-notes:
name: Generate Release Notes
runs-on: ubuntu-latest
needs: [extract-version]
outputs:
release-notes: ${{ steps.notes.outputs.release-notes }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate release notes
id: notes
run: |
# Extract CLI section from CHANGELOG.md
VERSION="${{ needs.extract-version.outputs.version }}"
# Find the CLI section for this version
CLI_SECTION=$(awk "/## \[CLI v$VERSION\]/,/^## \[/ {if (!/^## \[/) print}" CHANGELOG.md)
if [ -z "$CLI_SECTION" ]; then
echo "No CLI section found for version $VERSION in CHANGELOG.md"
CLI_SECTION="## CLI v$VERSION\n\nNo release notes available."
fi
# Create release notes
RELEASE_NOTES="## Lintellect CLI v$VERSION\n\n$CLI_SECTION\n\n### Installation\n\n#### NuGet Package\n\n\`\`\`bash\n# Install globally\ndotnet tool install --global lintellect --version $VERSION\n\n# Verify installation\nlintellect --version\n\`\`\`\n\n#### Binary Downloads\n\n- **Linux x64**: \`lintellect-cli-$VERSION-linux-x64.tar.gz\`\n- **Windows x64**: \`lintellect-cli-$VERSION-win-x64.zip\`\n\n### Usage\n\n\`\`\`bash\n# Basic analysis\nlintellect analyze --solution ./MyProject.sln\n\n# With API integration\nlintellect analyze \\\n --solution ./MyProject.sln \\\n --api-url \"https://api.example.com\" \\\n --api-key \"your-api-key\"\n\`\`\`"
echo "release-notes<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
[extract-version, publish-nuget, build-binaries, generate-release-notes]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Download all binaries
uses: actions/download-artifact@v6
with:
path: ./binaries
- name: Write release notes to file
run: |
cat > release-notes.md << 'RELEASE_NOTES_EOF'
${{ needs.generate-release-notes.outputs.release-notes }}
RELEASE_NOTES_EOF
- name: Create release with GitHub CLI
run: |
gh release create ${{ github.ref_name }} \
--title "Lintellect CLI v${{ needs.extract-version.outputs.version }}" \
--notes-file release-notes.md \
./binaries/lintellect-cli-linux-x64/lintellect-cli-${{ needs.extract-version.outputs.version }}-linux-x64.tar.gz \
./binaries/lintellect-cli-win-x64/lintellect-cli-${{ needs.extract-version.outputs.version }}-win-x64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-completion:
name: Notify Completion
runs-on: ubuntu-latest
needs: [extract-version, create-release, publish-nuget]
if: always()
steps:
- name: Notify success
if: needs.create-release.result == 'success' && needs.publish-nuget.result == 'success'
run: |
echo "✅ CLI v${{ needs.extract-version.outputs.version }} released successfully!"
echo "📦 NuGet package published to NuGet.org"
echo "📦 Binary archives attached to GitHub Release"
echo "📝 Release notes published"
- name: Notify failure
if: needs.create-release.result == 'failure' || needs.publish-nuget.result == 'failure'
run: |
echo "❌ CLI v${{ needs.extract-version.outputs.version }} release failed!"
echo "Please check the logs and retry the release process."
exit 1