Skip to content

Commit ba793a1

Browse files
committed
Update sync standards and workflows
1 parent f5def9a commit ba793a1

File tree

5 files changed

+113
-21
lines changed

5 files changed

+113
-21
lines changed

.github/workflows/CD.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ name: CD
77

88
on:
99
workflow_dispatch:
10+
inputs:
11+
skip-assets-publishing:
12+
description: 'Skip assets publishing'
13+
required: false
14+
type: boolean
15+
default: false
1016

1117
jobs:
1218
publish:
@@ -22,8 +28,8 @@ jobs:
2228
runtime-identifier: "" # Runtime identifier (win-x64, linux-x64, etc.)
2329
build-configuration: "Release" # Build configuration (Release, Debug, etc.)
2430
revision: ${{ github.run_number }} # Revision for date-based version (bindings style). Use with bindings.
25-
publish-enabled: false
26-
enable-email-notifications: false
31+
publish-enabled: ${{ !inputs.skip-assets-publishing }}
32+
enable-email-notifications: true
2733
secrets:
2834
NUGET_UPLOAD_TOKEN: ${{ secrets.EVERGINE_NUGETORG_TOKEN }}
2935
WAVE_SENDGRID_TOKEN: ${{ secrets.WAVE_SENDGRID_TOKEN }}

.github/workflows/CI.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ name: CI
77

88
on:
99
workflow_dispatch:
10+
inputs:
11+
publish-artifacts:
12+
description: 'Publish artifacts'
13+
required: false
14+
type: boolean
15+
default: false
1016
push:
1117
branches: [ "master" ]
1218
pull_request:
@@ -22,7 +28,7 @@ jobs:
2228
target-framework: "net8.0" # Target framework for generator/binding
2329
runtime-identifier: "" # Runtime identifier (win-x64, linux-x64, etc.)
2430
build-configuration: "Release" # Build configuration (Release, Debug, etc.)
25-
nuget-artifacts: false # Upload NuGets as workflow artifacts
31+
nuget-artifacts: ${{ inputs.publish-artifacts || false }} # Upload NuGets as workflow artifacts
2632
revision: ${{ github.run_number }} # Revision for date-based version (bindings style). Use with bindings.
2733

2834
# Tips:

.github/workflows/sync-standards.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
required: false
1414
ref:
1515
description: "Branch/tag/commit of standards"
16-
default: "main"
16+
default: "v2"
1717
required: false
1818
target_branch:
1919
description: "Target branch to apply changes"
@@ -37,7 +37,7 @@ on:
3737
required: false
3838

3939
schedule:
40-
- cron: "0 2 1 * *" # 02:00 UTC on the 1st of every month
40+
- cron: "0 1 1 * *" # 01:00 UTC on the 1st of every month
4141

4242
jobs:
4343
sync:

build/scripts/Generate-NuGets-DotNet.ps1

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
Direct version string to use for packages (used by add-ons)
1010
.PARAMETER Revision
1111
Revision number to append to date-based version (used by bindings)
12+
.PARAMETER VersionSuffix
13+
Optional suffix to append to the final version (e.g., "nightly" for "2025.11.3.123-nightly")
1214
.PARAMETER Projects
1315
Array of .csproj paths to pack. For single project, can be a string.
16+
.PARAMETER DependencyProjects
17+
Array of .csproj paths that need to be built first (dependencies) but won't generate NuGet packages.
1418
.PARAMETER OutputFolderBase
1519
Base folder for NuGet package output
1620
.PARAMETER BuildVerbosity
@@ -35,14 +39,25 @@
3539
.EXAMPLE
3640
# Using legacy symbol format
3741
.\Generate-NuGets-DotNet.ps1 -Version "1.0.0" -Projects "test.csproj" -SymbolsFormat "symbols.nupkg"
42+
.EXAMPLE
43+
# Using version suffix for nightly builds
44+
.\Generate-NuGets-DotNet.ps1 -Revision 123 -Projects "test.csproj" -VersionSuffix "nightly"
45+
.EXAMPLE
46+
# Using version suffix with direct version
47+
.\Generate-NuGets-DotNet.ps1 -Version "2025.1.0.0-alpha" -Projects "test.csproj" -VersionSuffix "nightly"
48+
.EXAMPLE
49+
# Building dependency projects but only packing main projects
50+
.\Generate-NuGets-DotNet.ps1 -Revision 123 -Projects "Main.csproj" -DependencyProjects "Dependency1.csproj","Dependency2.csproj"
3851
.LINK
3952
https://evergine.com/
4053
#>
4154

4255
param (
4356
[string]$Version,
4457
[string]$Revision,
58+
[string]$VersionSuffix,
4559
[Parameter(Mandatory = $true)]$Projects,
60+
$DependencyProjects = @(),
4661
[string]$OutputFolderBase = "nupkgs",
4762
[string]$BuildVerbosity = "normal",
4863
[string]$BuildConfiguration = "Release",
@@ -61,14 +76,6 @@ else {
6176
}
6277

6378
# Parameter validation
64-
if ([string]::IsNullOrEmpty($Version) -and [string]::IsNullOrEmpty($Revision)) {
65-
throw "Either -Version or -Revision parameter must be provided"
66-
}
67-
68-
if (![string]::IsNullOrEmpty($Version) -and ![string]::IsNullOrEmpty($Revision)) {
69-
throw "Cannot specify both -Version and -Revision parameters"
70-
}
71-
7279
if ($Projects -eq $null -or $Projects.Count -eq 0 -or ($Projects -is [array] -and $Projects.Length -eq 0)) {
7380
throw "Projects parameter cannot be empty"
7481
}
@@ -78,21 +85,23 @@ if ($Projects -is [string]) {
7885
$Projects = @($Projects)
7986
}
8087

81-
# Calculate version
82-
if (![string]::IsNullOrEmpty($Revision)) {
83-
$Version = "$(Get-Date -Format "yyyy.M.d").$Revision"
88+
# Convert DependencyProjects to array if it's a single string or null
89+
if ($null -eq $DependencyProjects) {
90+
$DependencyProjects = @()
8491
}
85-
86-
# Validate version format (NuGet semantic versioning)
87-
# See: https://docs.microsoft.com/en-us/nuget/concepts/package-versioning
88-
if ($Version -notmatch '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-([a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)(?:\.([a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?))*)?$') {
89-
throw "Invalid version format: '$Version'. NuGet version must follow semantic versioning (e.g., '1.0.0', '1.0.0-alpha', '1.0.0.123')."
92+
elseif ($DependencyProjects -is [string]) {
93+
$DependencyProjects = @($DependencyProjects)
9094
}
9195

96+
# Resolve version from parameters (including suffix)
97+
$Version = Resolve-Version -version $Version -revision $Revision -versionSuffix $VersionSuffix
98+
9299
# Show variables
93100
$parameters = @{
94101
"Version" = $Version
102+
"VersionSuffix" = if ([string]::IsNullOrWhiteSpace($VersionSuffix)) { "(none)" } else { $VersionSuffix }
95103
"Projects" = ($Projects -join ", ")
104+
"DependencyProjects" = if ($DependencyProjects.Count -eq 0) { "(none)" } else { ($DependencyProjects -join ", ") }
96105
"BuildConfiguration" = $BuildConfiguration
97106
"BuildVerbosity" = $BuildVerbosity
98107
"OutputFolderBase" = $OutputFolderBase
@@ -105,6 +114,24 @@ ShowVariables $parameters
105114
# Create output folder
106115
$absoluteOutputFolder = CreateOutputFolder $OutputFolderBase
107116

117+
# Build all projects (dependencies + main projects) first to resolve dependencies automatically
118+
$allProjectsToBuild = $DependencyProjects + $Projects
119+
LogDebug "START building all projects to resolve dependencies"
120+
foreach ($projectPath in $allProjectsToBuild) {
121+
LogDebug "Building project: $projectPath"
122+
123+
if (!(Test-Path $projectPath)) {
124+
throw "Project file not found: $projectPath"
125+
}
126+
127+
& dotnet build $projectPath --verbosity $BuildVerbosity --configuration $BuildConfiguration
128+
129+
if ($LASTEXITCODE -ne 0) {
130+
throw "dotnet build failed for $projectPath"
131+
}
132+
}
133+
LogDebug "END building all projects"
134+
108135
# Generate packages
109136
LogDebug "START packaging process"
110137

build/scripts/Helpers.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,57 @@ function ShowVariablesLegacy($version, $buildConfiguration, $buildVerbosity, $ou
4747
LogDebug "Build verbosity.....: $buildVerbosity"
4848
LogDebug "Output folder.......: $outputFolderBase"
4949
LogDebug "#######################################"
50+
}
51+
52+
# Calculate version from revision using date-based format
53+
function Get-VersionFromRevision($revision) {
54+
if ([string]::IsNullOrWhiteSpace($revision)) {
55+
throw "Revision parameter cannot be null or empty"
56+
}
57+
return "$(Get-Date -Format "yyyy.M.d").$revision"
58+
}
59+
60+
# Validate version format using NuGet semantic versioning rules
61+
function Test-VersionFormat($version) {
62+
if ([string]::IsNullOrWhiteSpace($version)) {
63+
return $false
64+
}
65+
# NuGet semantic versioning pattern
66+
# See: https://docs.microsoft.com/en-us/nuget/concepts/package-versioning
67+
return $version -match '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-([a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)(?:\.([a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?))*)?$'
68+
}
69+
70+
# Resolve version from Version, Revision, and optional VersionSuffix parameters
71+
function Resolve-Version($version, $revision, $versionSuffix = "") {
72+
# Validate parameters
73+
if ([string]::IsNullOrEmpty($version) -and [string]::IsNullOrEmpty($revision)) {
74+
throw "Either Version or Revision parameter must be provided"
75+
}
76+
77+
if (![string]::IsNullOrEmpty($version) -and ![string]::IsNullOrEmpty($revision)) {
78+
throw "Cannot specify both Version and Revision parameters"
79+
}
80+
81+
# Calculate version if revision is provided
82+
if (![string]::IsNullOrEmpty($revision)) {
83+
$resolvedVersion = Get-VersionFromRevision $revision
84+
}
85+
else {
86+
$resolvedVersion = $version
87+
}
88+
89+
# Validate version format (before applying suffix)
90+
if (-not (Test-VersionFormat $resolvedVersion)) {
91+
throw "Invalid version format: '$resolvedVersion'. Version must follow semantic versioning (e.g., '1.0.0', '1.0.0-alpha', '1.0.0.123')."
92+
}
93+
94+
# Apply version suffix if provided
95+
if (-not [string]::IsNullOrWhiteSpace($versionSuffix)) {
96+
# Remove leading dash from suffix if present to avoid double dashes
97+
$cleanSuffix = $versionSuffix.TrimStart('-')
98+
# Always append with dash separator for clean, consistent versioning
99+
$resolvedVersion = "$resolvedVersion-$cleanSuffix"
100+
}
101+
102+
return $resolvedVersion
50103
}

0 commit comments

Comments
 (0)