Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-

Expand All @@ -56,13 +56,12 @@ jobs:
with:
dotnet-version: '9.0.x'

- name: 🔨 Build and Pack
- name: 📁 Create artifacts directory
run: mkdir -p artifacts/packages

- name: 🔨 Build
run: |
dotnet build source/timewarp-source-generators/timewarp-source-generators.csproj --configuration Release
dotnet pack source/timewarp-source-generators/timewarp-source-generators.csproj `
--configuration Release `
--no-build `
-p:NoWarn=NU5128

# TODO: Enable tests when ready
# - name: 🧪 Run Tests
Expand All @@ -75,13 +74,13 @@ jobs:
- name: 🔍 Check if version already published (Releases only)
if: github.event_name == 'release'
run: |
$version = (Select-Xml -Path "Directory.Build.props" -XPath "//PackageVersion/text()").Node.Value
$version = (Select-Xml -Path "source/Directory.Build.props" -XPath "//Version/text()").Node.Value
Write-Host "Checking if TimeWarp.SourceGenerators $version is already published on NuGet.org..."

$searchResult = dotnet package search TimeWarp.SourceGenerators --exact-match --prerelease --source https://api.nuget.org/v3/index.json
if ($searchResult -match "TimeWarp\.SourceGenerators.*$version") {
Write-Host "⚠️ WARNING: TimeWarp.SourceGenerators $version is already published to NuGet.org"
Write-Host "❌ This version cannot be republished. Please increment the version in Directory.Build.props"
Write-Host "❌ This version cannot be republished. Please increment the version in source/Directory.Build.props"
exit 1
} else {
Write-Host "✅ TimeWarp.SourceGenerators $version is not yet published on NuGet.org"
Expand All @@ -90,7 +89,7 @@ jobs:
- name: 🚀 Publish to NuGet.org (Releases only)
if: github.event_name == 'release'
run: |
dotnet nuget push source/timewarp-source-generators/bin/Release/TimeWarp.SourceGenerators.*.nupkg `
dotnet nuget push artifacts/packages/TimeWarp.SourceGenerators.*.nupkg `
--api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }} `
--source https://api.nuget.org/v3/index.json `
--skip-duplicate
Expand All @@ -100,7 +99,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Packages-${{ github.run_number }}
path: source/timewarp-source-generators/bin/Release/*.nupkg
path: artifacts/packages/*.nupkg

- name: ✅ Job Status
run: echo "This job's status is ${{ job.status }}."
81 changes: 39 additions & 42 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
<Project>
<!-- Set common properties regarding assembly information and nuget packages -->

<PropertyGroup>
<Authors>Steven T. Cramer</Authors>
<Product>TimeWarp.SourceGenerators</Product>
<PackageId>TimeWarp.SourceGenerators</PackageId>
<PackageVersion>1.0.0-beta.4</PackageVersion>
<PackageProjectUrl>https://timewarpengineering.github.io/timewarp-source-generators/</PackageProjectUrl>
<PackageTags>TimeWarp; Source Generator;SourceGenerators; Delegate</PackageTags>
<PackageIcon>logo.png</PackageIcon>
<RepositoryUrl>https://github.com/TimeWarpEngineering/timewarp-source-generators.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
<PackageReleaseNotes>
For detailed release notes and changelog, please visit: https://github.com/TimeWarpEngineering/timewarp-source-generators/releases
</PackageReleaseNotes>
<PackageReadmeFile>read-me.md</PackageReadmeFile>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<!-- Custom path definitions for repository structure -->
<PropertyGroup Label="Custom Repository Variables">
<RepositoryName>timewarp-source-generators</RepositoryName>
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
<SourceDirectory>$(RepositoryRoot)source/</SourceDirectory>
<TestsDirectory>$(RepositoryRoot)tests/</TestsDirectory>
<ArtifactsDirectory>$(RepositoryRoot)artifacts/</ArtifactsDirectory>
<PackagesDirectory>$(ArtifactsDirectory)packages/</PackagesDirectory>
</PropertyGroup>

<!-- Deterministic Builds https://devblogs.microsoft.com/dotnet/producing-packages-with-source-link/#deterministic-builds -->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<!-- MSBuild and NuGet behavior configuration -->
<PropertyGroup Label="MSBuild/NuGet Configuration">
<!-- Output packages to our local feed directory -->
<PackageOutputPath>$(PackagesDirectory)</PackageOutputPath>

<!-- Suppress .NET preview SDK message -->
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<!-- Common compile parameters -->
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<!-- Default language and framework settings for all projects -->
<PropertyGroup Label="Project Defaults">
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<NoWarn>CS7035;NU1503;1503;1591</NoWarn>
<Nullable>enable</Nullable>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<!-- Code quality, analyzers, and warning configuration -->
<PropertyGroup Label="Code Quality and Analysis">
<!-- Treat all warnings as errors -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>CS7035;NU1503;1503;1591</NoWarn>

<!-- Enable compiler-generated files output -->
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

<!-- https://devblogs.microsoft.com/nuget/enable-repeatable-package-restores-using-a-lock-file/ supports caching of nugets in CI builds -->
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
<!-- Central Package Management -->
<PropertyGroup Label="NuGet Configuration">
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<PropertyGroup>
<!-- Source Link Settings -->
<PropertyGroup Label="Source Link Settings">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>false</IncludeSymbols>
<DebugType>portable</DebugType>
</PropertyGroup>

<!--This is to add the CommitDate and CommitHash to your assemblyinfo -->
<Target Name="SetAssemblyMetaData" BeforeTargets="PreBuildEvent" >
<!-- Git commit metadata for assembly info -->
<Target Name="SetAssemblyMetaData" BeforeTargets="PreBuildEvent">
<Exec Command="git log -1 --format=%%ct" ConsoleToMSBuild="true" Condition="'$(OS)' == 'Windows_NT'">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitTimestamp"/>
</Exec>
Expand All @@ -61,10 +62,6 @@
<Exec Command="pwsh -ExecutionPolicy Bypass -NoProfile -File &quot;$(MSBuildThisFileDirectory)convert-timestamp.ps1&quot; -GitCommitTimestamp $(GitCommitTimestamp)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="CommitDate"/>
</Exec>
<PropertyGroup>
<!-- In Visual Studio the below line crashes if they fix VS then we can use this and no need for the powershell script -->
<!--<LastCommitDate>$([System.DateTime]::UnixEpoch.AddSeconds($(GitCommitTimestamp)).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK"))</LastCommitDate>-->
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>CommitDate</_Parameter1>
Expand All @@ -73,8 +70,8 @@
</ItemGroup>
</Target>

<!-- Common analyzers and code fixes-->
<ItemGroup>
<!-- Common analyzers for all projects -->
<ItemGroup Label="Code Analyzers">
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<ItemGroup>
<PackageVersion Include="TimeWarp.SourceGenerators" Version="$(Version)" />
<PackageVersion Include="FakeItEasy" Version="7.3.1" />
<PackageVersion Include="Fixie" Version="3.2.0" />
<PackageVersion Include="Fixie.TestAdapter" Version="3.3.0" />
Expand Down
Loading