Skip to content

Commit 0c17f06

Browse files
authored
REFACTOR: Move away from appveyor build and use standard GitHub actions and dotnet nuget packing (#306)
1 parent bd848da commit 0c17f06

25 files changed

Lines changed: 350 additions & 2327 deletions

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Check PR
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
run-ci:
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Get latest code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: |
23+
8.x
24+
10.x
25+
26+
- name: Set XrmMockup365 version from RELEASE_NOTES.md
27+
shell: pwsh
28+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./RELEASE_NOTES.md -CsprojPath ./src/XrmMockup365/XrmMockup365.csproj
29+
30+
- name: Set MetadataGenerator.Tool version from CHANGELOG.md
31+
shell: pwsh
32+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./src/MetadataGen/MetadataGenerator.Tool/CHANGELOG.md -CsprojPath ./src/MetadataGen/MetadataGenerator.Tool/MetadataGenerator.Tool.csproj
33+
34+
- name: Set MetadataGenerator.Core version from CHANGELOG.md
35+
shell: pwsh
36+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./src/MetadataGen/MetadataGenerator.Tool/CHANGELOG.md -CsprojPath ./src/MetadataGen/MetadataGenerator.Core/MetadataGenerator.Core.csproj
37+
38+
- name: Set MetadataGenerator.Context version from CHANGELOG.md
39+
shell: pwsh
40+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./src/MetadataGen/MetadataGenerator.Tool/CHANGELOG.md -CsprojPath ./src/MetadataGen/MetadataGenerator.Context/MetadataGenerator.Context.csproj
41+
42+
- name: Install dependencies
43+
run: dotnet restore
44+
45+
- name: Build solution
46+
run: dotnet build --configuration Release --no-restore
47+
48+
- name: Run tests
49+
run: dotnet test --configuration Release --no-build --verbosity normal
50+
51+
- name: Pack XrmMockup365
52+
run: dotnet pack src/XrmMockup365/XrmMockup365.csproj --configuration Release --no-build --output ./nupkg
53+
54+
- name: Pack MetadataGenerator.Tool
55+
run: dotnet pack src/MetadataGen/MetadataGenerator.Tool/MetadataGenerator.Tool.csproj --configuration Release --no-build --output ./nupkg
56+
57+
- name: Upload artifacts
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: packages
61+
path: ./nupkg

.github/workflows/release.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [released]
6+
workflow_dispatch:
7+
inputs:
8+
dry_run:
9+
description: 'Perform a dry run (skip actual NuGet publish)'
10+
required: false
11+
default: true
12+
type: boolean
13+
14+
jobs:
15+
build:
16+
runs-on: windows-latest
17+
permissions:
18+
contents: write # For release asset upload
19+
id-token: write # Required for OIDC token (NuGet Trusted Publishing)
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: |
28+
8.x
29+
10.x
30+
31+
- name: Set XrmMockup365 version from RELEASE_NOTES.md
32+
shell: pwsh
33+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./RELEASE_NOTES.md -CsprojPath ./src/XrmMockup365/XrmMockup365.csproj
34+
35+
- name: Set MetadataGenerator.Tool version from CHANGELOG.md
36+
shell: pwsh
37+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./src/MetadataGen/MetadataGenerator.Tool/CHANGELOG.md -CsprojPath ./src/MetadataGen/MetadataGenerator.Tool/MetadataGenerator.Tool.csproj
38+
39+
- name: Set MetadataGenerator.Core version from CHANGELOG.md
40+
shell: pwsh
41+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./src/MetadataGen/MetadataGenerator.Tool/CHANGELOG.md -CsprojPath ./src/MetadataGen/MetadataGenerator.Core/MetadataGenerator.Core.csproj
42+
43+
- name: Set MetadataGenerator.Context version from CHANGELOG.md
44+
shell: pwsh
45+
run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath ./src/MetadataGen/MetadataGenerator.Tool/CHANGELOG.md -CsprojPath ./src/MetadataGen/MetadataGenerator.Context/MetadataGenerator.Context.csproj
46+
47+
- name: Restore dependencies
48+
run: dotnet restore
49+
50+
- name: Build
51+
run: dotnet build --configuration Release --no-restore
52+
53+
- name: Run tests
54+
run: dotnet test --configuration Release --no-build --verbosity normal
55+
56+
- name: Pack XrmMockup365
57+
run: dotnet pack src/XrmMockup365/XrmMockup365.csproj --configuration Release --no-build --output ./nupkg
58+
59+
- name: Pack MetadataGenerator.Tool
60+
run: dotnet pack src/MetadataGen/MetadataGenerator.Tool/MetadataGenerator.Tool.csproj --configuration Release --no-build --output ./nupkg
61+
62+
- name: Upload artifacts
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: packages
66+
path: ./nupkg
67+
68+
- name: Add packages to release
69+
uses: softprops/action-gh-release@v2
70+
if: github.event_name == 'release'
71+
with:
72+
files: |
73+
./nupkg/*.nupkg
74+
./nupkg/*.snupkg
75+
76+
- name: Login to NuGet (OIDC)
77+
id: nuget-login
78+
uses: nuget/login@v1
79+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run != 'true')
80+
with:
81+
user: ${{ secrets.NUGET_USER }}
82+
83+
- name: Publish to NuGet
84+
shell: pwsh
85+
run: |
86+
Write-Host "Looking for nupkg files..."
87+
$nupkgFiles = Get-ChildItem -Path "./nupkg/*.nupkg" -File
88+
89+
if ($nupkgFiles.Count -eq 0) {
90+
Write-Host "No nupkg files found in nupkg"
91+
exit 1
92+
}
93+
94+
Write-Host "Found $($nupkgFiles.Count) nupkg file(s):"
95+
foreach ($file in $nupkgFiles) {
96+
Write-Host " Full path: $($file.FullName)"
97+
Write-Host " Size: $([math]::Round($file.Length / 1KB, 2)) KB"
98+
}
99+
100+
# For automatic triggers (release events), always publish
101+
# For manual triggers, only publish if dry_run is explicitly set to false
102+
$isDryRun = "${{ github.event_name }}" -eq "workflow_dispatch" -and "${{ github.event.inputs.dry_run }}" -ne "false"
103+
104+
if ($isDryRun) {
105+
Write-Host "Dry run mode - skipping NuGet publish"
106+
} else {
107+
Write-Host "Publishing to NuGet..."
108+
foreach ($file in $nupkgFiles) {
109+
Write-Host "Publishing: $($file.FullName)"
110+
dotnet nuget push "$($file.FullName)" --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
111+
}
112+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ TestResults.xml
185185

186186
# Nuget outputs
187187
nuget/*.nupkg
188+
nupkg/
188189
release.cmd
189190
release.sh
190191
localpackages/

0 commit comments

Comments
 (0)