Skip to content

Commit 776359c

Browse files
committed
Use build/publish scripts
1 parent cba6f42 commit 776359c

File tree

7 files changed

+71
-52
lines changed

7 files changed

+71
-52
lines changed

.github/workflows/generic-build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/[email protected]
22+
- name: Checkout repo
23+
uses: actions/[email protected]
2324
- name: Setup .NET Core 9.0
2425
uses: actions/[email protected]
2526
with:
2627
dotnet-version: '9.0.x'
2728
- name: Build
28-
run: dotnet build -c Release FastData.sln
29+
shell: pwsh
30+
run: |
31+
./Scripts/Build.ps1

.github/workflows/nuget-release.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- uses: actions/[email protected]
20+
- name: Checkout repo
21+
uses: actions/[email protected]
2122
- name: Setup .NET Core 9.0
2223
uses: actions/[email protected]
2324
with:
2425
dotnet-version: '9.0.x'
25-
- name: Pack release
26-
run: dotnet pack -c Release -o tmp FastData.sln
27-
- name: Upload to nuget
28-
run: dotnet nuget push --skip-duplicate -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json tmp/*
26+
- name: Publish
27+
shell: pwsh
28+
env:
29+
NUGET_KEY: ${{secrets.NUGET_KEY}}
30+
PWSHG_KEY: ${{secrets.PWSHG_KEY}}
31+
run: |
32+
./Scripts/Publish.ps1

FastData.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PowerShell", "PowerShell",
110110
EndProject
111111
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Scripts", "_Scripts", "{6257D463-0651-404E-8440-BD7AD4EC89F4}"
112112
ProjectSection(SolutionItems) = preProject
113-
Publish.ps1 = Publish.ps1
113+
Scripts\Build.ps1 = Scripts\Build.ps1
114+
Scripts\Publish.ps1 = Scripts\Publish.ps1
114115
EndProjectSection
115116
EndProject
116117
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastData.Generator.Rust", "Src\FastData.Generator.Rust\FastData.Generator.Rust.csproj", "{8880847E-5007-4845-91D5-CCEB1A96B97C}"

Publish.ps1

Lines changed: 0 additions & 42 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ in many different languages (C#, C++, Rust, etc.), ready for inclusion in your p
1212

1313
## Download
1414

15-
[![C# library](https://img.shields.io/nuget/v/Genbox.FastData.Generator.CSharp.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Genbox.FastData.Generator.CSharp/)
16-
[![.NET Tool](https://img.shields.io/nuget/v/Genbox.FastData.Cli.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Genbox.FastData.Cli/)
15+
* C# library: [![C# library](https://img.shields.io/nuget/v/Genbox.FastData.Generator.CSharp.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Genbox.FastData.Generator.CSharp/)
16+
* .NET Tool: [![.NET Tool](https://img.shields.io/nuget/v/Genbox.FastData.Cli.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Genbox.FastData.Cli/)
1717

1818

1919
## Use case

Scripts/Build.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$Config = "Debug"
2+
$Root = "$PSScriptRoot/.."
3+
$Color = "DarkBlue"
4+
5+
Write-Host -BackgroundColor $Color "Building solution"
6+
dotnet build $Root/FastData.sln -c $Config

Scripts/Publish.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
$Config = "Release"
2+
$Framework = "net9.0"
3+
$Root = "$PSScriptRoot/../"
4+
$PublishDir = "$Root/Publish"
5+
$ArtifactsDir = "$Root/Publish/Artifacts"
6+
$Color = "DarkBlue"
7+
8+
Write-Host -BackgroundColor $Color "Clean up from previous publishes"
9+
Remove-Item -Path $PublishDir/* -Recurse -Force -ErrorAction Ignore | Out-Null
10+
11+
Write-Host -BackgroundColor $Color "Publish the dll files"
12+
dotnet publish $Root/Src/FastData/FastData.csproj -c $Config -f $Framework -p:GenerateDependencyFile=false -o $ArtifactsDir
13+
dotnet publish $Root/Src/FastData.Generator.CSharp/FastData.Generator.CSharp.csproj -c $Config -f $Framework -p:GenerateDependencyFile=false -o $ArtifactsDir
14+
dotnet publish $Root/Src/FastData.Generator.CPlusPlus/FastData.Generator.CPlusPlus.csproj -c $Config -f $Framework -p:GenerateDependencyFile=false -o $ArtifactsDir
15+
dotnet publish $Root/Src/FastData.Generator.Rust/FastData.Generator.Rust.csproj -c $Config -f $Framework -p:GenerateDependencyFile=false -o $ArtifactsDir
16+
17+
Write-Host -BackgroundColor $Color "Pack the PowerShell variant"
18+
New-Item -ItemType Directory -Path $PublishDir/PowerShell | Out-Null
19+
New-Item -ItemType Directory -Path $PublishDir/PowerShell/lib | Out-Null
20+
21+
Write-Host -BackgroundColor $Color "Get the version number of the generator dll file"
22+
$ver = [System.Reflection.AssemblyName]::GetAssemblyName("$ArtifactsDir\Genbox.FastData.dll").Version
23+
$semver = "$($ver.Major).$($ver.Minor).$($ver.Build)"
24+
25+
Write-Host -BackgroundColor $Color "Version: $semver"
26+
27+
Write-Host -BackgroundColor $Color "Copy over the psd1 file, and update the version number in the process"
28+
(Get-Content $Root/Misc/PowerShell/FastData.psd1) -replace "TODO-VERSION", "$semver" | Set-Content $PublishDir/PowerShell/FastData.psd1
29+
30+
Write-Host -BackgroundColor $Color "Copy over the other PowerShell files"
31+
Copy-Item $Root/Misc/PowerShell/FastData.psm1 $PublishDir/PowerShell/FastData.psm1
32+
Copy-Item $ArtifactsDir/*.dll $PublishDir/PowerShell/lib/
33+
34+
Write-Host -BackgroundColor $Color "Pack the CLI tool as executable"
35+
dotnet publish $Root/Src/FastData.Cli/FastData.Cli.csproj -c $Config -f $Framework -r win-x64 -p:PublishSingleFile=true -p:SelfContained=true -p:PublishTrimmed=true -p:TargetFrameworks=$Framework -p:DebugType=none -p:GenerateDocumentationFile=false -p:EnableCompressionInSingleFile=true -p:InvariantGlobalization=true -o $PublishDir
36+
37+
Write-Host -BackgroundColor $Color "Pack the CLI tool as a dotnet tool (NuGet)"
38+
dotnet pack $Root/Src/FastData.Cli/FastData.Cli.csproj -c $Config -p:PackAsTool=true -p:ToolCommandName=fastdata -p:PackageVersion=$semver -o $PublishDir
39+
40+
Write-Host -BackgroundColor $Color "Pack the source generator"
41+
dotnet pack $Root/Src/FastData.SourceGenerator/FastData.SourceGenerator.csproj -c $Config -p:PackageVersion=$semver -o $PublishDir
42+
43+
#Write-Host -BackgroundColor $Color "Publish PowerShell module to PowerShellGallery"
44+
#Publish-Module -Path "$PublishDir/PowerShell/" -NuGetApiKey $env:PWSHG_KEY
45+
46+
#Write-Host -BackgroundColor $Color "Publish dotnet tool to NuGet"
47+
#dotnet nuget push $PublishDir/*.nupkg --api-key $env:NUGET_KEY

0 commit comments

Comments
 (0)