-
Notifications
You must be signed in to change notification settings - Fork 1
Create deterministic build process with GitHub Actions and fix Central Package Management #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
13
commits into
main
Choose a base branch
from
copilot/fix-30
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4397f49
Initial plan
Copilot c0e7625
Add deterministic build configuration and workflow
Copilot b393b46
Enhance deterministic build settings and verification
Copilot b05acef
Fix Central Package Management and add GitHub Actions permissions
Copilot b430f2b
Refactor package versions and central management
christiannagel 7b004ea
Add documentation for NuGet package management
christiannagel 6822f45
Update logging package versioning for target frameworks
christiannagel 7472c40
Fix NU1506 warnings and improve multi-targeting setup
christiannagel 5947e43
Remove ManagePackageVersionsCentrally property
christiannagel cb2b80c
Fix NU5017 error in Analyzers package by adding minimal dependency
Copilot a920a84
Remove --no-build flag and clean up project dependencies
christiannagel 0f7961f
Update CPM docs to clarify stable vs preview package sources
Copilot b8d89c4
Merge branch 'main' into copilot/fix-30
christiannagel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| name: Deterministic Build | ||
|
|
||
| on: | ||
| # Trigger on push and pull requests to main branch | ||
| push: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'src/**' | ||
| - '.github/workflows/deterministic-build.yml' | ||
| pull_request: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'src/**' | ||
| - '.github/workflows/deterministic-build.yml' | ||
|
|
||
| # Allow manual trigger | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| DOTNET_VERSION: '9.0.x' | ||
| CI: true | ||
|
|
||
| jobs: | ||
| deterministic-build: | ||
| name: Deterministic Build | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| solution: | ||
| - name: Analyzers | ||
| path: src/Codebreaker.Analyzers.slnx | ||
| project: src/services/common/Codebreaker.GameAPIs.Analyzers/Codebreaker.Analyzers.csproj | ||
| - name: Backend-Models | ||
| path: src/Codebreaker.Backend.Models.slnx | ||
| project: src/services/common/Codebreaker.GameAPIs.Models/Codebreaker.GameAPIs.Models.csproj | ||
| - name: Cosmos | ||
| path: src/Codebreaker.Backend.Cosmos.slnx | ||
| project: src/services/common/Codebreaker.Data.Cosmos/Codebreaker.Data.Cosmos.csproj | ||
| - name: SqlServer | ||
| path: src/Codebreaker.Backend.SqlServer.slnx | ||
| project: src/services/common/Codebreaker.Data.SqlServer/Codebreaker.Data.SqlServer.csproj | ||
| - name: Postgres | ||
| path: src/Codebreaker.Backend.Postgres.slnx | ||
| project: src/services/common/Codebreaker.Data.Postgres/Codebreaker.Data.Postgres.csproj | ||
| - name: GameAPIs-Client | ||
| path: src/Codebreaker.GameAPIs.Client.slnx | ||
| project: src/clients/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| # Fetch all history for proper source control information | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore ${{ matrix.solution.path }} | ||
|
|
||
| - name: Build solution (deterministic) | ||
| run: | | ||
| echo "Building ${{ matrix.solution.name }} with deterministic settings..." | ||
| dotnet build ${{ matrix.solution.path }} \ | ||
| --configuration Release \ | ||
| --no-restore \ | ||
| --verbosity normal \ | ||
| /p:ContinuousIntegrationBuild=true \ | ||
| /p:Deterministic=true \ | ||
| /p:EmbedUntrackedSources=true \ | ||
| /p:DebugType=embedded \ | ||
| /p:PublishRepositoryUrl=true | ||
|
|
||
| - name: Run tests | ||
| run: dotnet test ${{ matrix.solution.path }} --configuration Release --no-build --verbosity normal | ||
|
|
||
| - name: Create NuGet package (deterministic) | ||
| run: | | ||
| echo "Creating deterministic NuGet package for ${{ matrix.solution.name }}..." | ||
| dotnet pack ${{ matrix.solution.project }} \ | ||
| --configuration Release \ | ||
| --no-build \ | ||
| --output ./packages \ | ||
| /p:ContinuousIntegrationBuild=true \ | ||
| /p:Deterministic=true \ | ||
| /p:EmbedUntrackedSources=true \ | ||
| /p:DebugType=embedded \ | ||
| /p:PublishRepositoryUrl=true | ||
|
|
||
| - name: Verify deterministic build | ||
| shell: bash | ||
| run: | | ||
| echo "Verifying deterministic build for ${{ matrix.solution.name }}..." | ||
|
|
||
| # Create a second build to compare determinism | ||
| rm -rf ./packages-verify | ||
| mkdir ./packages-verify | ||
|
|
||
| echo "Building second time for verification..." | ||
| dotnet pack ${{ matrix.solution.project }} \ | ||
| --configuration Release \ | ||
| --no-build \ | ||
| --output ./packages-verify \ | ||
| /p:ContinuousIntegrationBuild=true \ | ||
| /p:Deterministic=true \ | ||
| /p:EmbedUntrackedSources=true \ | ||
| /p:DebugType=embedded \ | ||
| /p:PublishRepositoryUrl=true | ||
|
|
||
| # Compare the packages (basic check - file sizes should be identical) | ||
| echo "Comparing package files..." | ||
| ls -la ./packages/ | ||
| ls -la ./packages-verify/ | ||
|
|
||
| # Check if the files have the same size | ||
| for file in ./packages/*.nupkg; do | ||
| filename=$(basename "$file") | ||
| if [ -f "./packages-verify/$filename" ]; then | ||
| size1=$(stat -c%s "./packages/$filename") | ||
| size2=$(stat -c%s "./packages-verify/$filename") | ||
| echo "Package $filename: Original size=$size1, Verify size=$size2" | ||
| if [ "$size1" != "$size2" ]; then | ||
| echo "ERROR: Package sizes differ! Build is not deterministic." | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "ERROR: Verification package $filename not found!" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| echo "✅ Deterministic build verification passed for ${{ matrix.solution.name }}" | ||
|
|
||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: deterministic-packages-${{ matrix.solution.name }} | ||
| path: | | ||
| ./packages/*.nupkg | ||
| ./packages/*.snupkg | ||
| retention-days: 7 | ||
| compression-level: 6 | ||
|
|
||
| summary: | ||
| name: Build Summary | ||
| runs-on: ubuntu-latest | ||
| needs: deterministic-build | ||
| if: always() | ||
|
|
||
| steps: | ||
| - name: Build Summary | ||
| run: | | ||
| echo "## Deterministic Build Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "All library solutions have been built with deterministic settings:" >> $GITHUB_STEP_SUMMARY | ||
| echo "- ✅ ContinuousIntegrationBuild=true" >> $GITHUB_STEP_SUMMARY | ||
| echo "- ✅ Deterministic=true" >> $GITHUB_STEP_SUMMARY | ||
| echo "- ✅ EmbedUntrackedSources=true" >> $GITHUB_STEP_SUMMARY | ||
| echo "- ✅ DebugType=embedded" >> $GITHUB_STEP_SUMMARY | ||
| echo "- ✅ PublishRepositoryUrl=true" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Build artifacts have been uploaded and are available for download." >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Solutions Built:" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Analyzers" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Backend Models" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Cosmos DB Library" >> $GITHUB_STEP_SUMMARY | ||
| echo "- SQL Server Library" >> $GITHUB_STEP_SUMMARY | ||
| echo "- PostgreSQL Library" >> $GITHUB_STEP_SUMMARY | ||
| echo "- GameAPIs Client Library" >> $GITHUB_STEP_SUMMARY | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.