Skip to content

Commit 9f652e7

Browse files
author
ChristianHaase
committed
test
1 parent 3395ce7 commit 9f652e7

File tree

2 files changed

+60
-70
lines changed

2 files changed

+60
-70
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,20 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v5
25-
# - name: Setup .NET
26-
# uses: actions/setup-dotnet@v5
27-
# with:
28-
# dotnet-version: 10.0.x
29-
# - name: Compute and set build number
30-
# shell: bash
31-
# run: |
32-
# echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV
33-
- name: TEST PR RUN CHECK
25+
- name: Setup .NET
26+
uses: actions/setup-dotnet@v5
27+
with:
28+
dotnet-version: 10.0.x
29+
- name: Compute and set build number
3430
shell: bash
3531
run: |
36-
echo "$PR_TRIGGER"
32+
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV
3733
- name: Build & Push
3834
env:
3935
DOTNET_CLI_TELEMTRY_OPTOUT: true
4036
PR_TRIGGER: ${{ env.PR_TRIGGER }}
41-
#NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
42-
#GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4339
shell: pwsh
4440
run: |
4541
./Build.ps1

Build.ps1

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,85 +7,79 @@ Write-Output "build: Build started"
77

88
Push-Location $PSScriptRoot
99

10-
Write-Output "build: PR_TRIGGER value: $env:PR_TRIGGER"
11-
1210
if($env:PR_TRIGGER -eq "true") {
13-
Write-Output "build: This is a PR build - skipping packaging and publishing steps"
1411
$skipPackaging = $true
1512
} else {
1613
$skipPackaging = $false
1714
}
1815

19-
# try {
20-
# if(Test-Path .\artifacts) {
21-
# Write-Output "build: Cleaning ./artifacts"
22-
# Remove-Item ./artifacts -Force -Recurse
23-
# }
24-
25-
# & dotnet restore --no-cache
26-
27-
# $dvp = [Xml] (Get-Content .\Directory.Version.props)
28-
# $versionPrefix = $dvp.Project.PropertyGroup.VersionPrefix
16+
try {
17+
if(Test-Path .\artifacts) {
18+
Write-Output "build: Cleaning ./artifacts"
19+
Remove-Item ./artifacts -Force -Recurse
20+
}
2921

30-
# Write-Output "build: Package base version is $versionPrefix"
22+
& dotnet restore --no-cache
3123

32-
# $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
33-
# $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
34-
# $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "master" -and $revision -ne "local"]
35-
# $commitHash = $(git rev-parse --short HEAD)
36-
# $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
24+
$dvp = [Xml] (Get-Content .\Directory.Version.props)
25+
$versionPrefix = $dvp.Project.PropertyGroup.VersionPrefix
3726

38-
# Write-Output "build: Package version suffix is $suffix"
39-
# Write-Output "build: Build version suffix is $buildSuffix"
27+
Write-Output "build: Package base version is $versionPrefix"
4028

41-
# & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
42-
# if($LASTEXITCODE -ne 0) { throw "Build failed" }
29+
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
30+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
31+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "master" -and $revision -ne "local"]
32+
$commitHash = $(git rev-parse --short HEAD)
33+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
4334

44-
# foreach ($src in Get-ChildItem src/*) {
45-
# Push-Location $src
35+
Write-Output "build: Package version suffix is $suffix"
36+
Write-Output "build: Build version suffix is $buildSuffix"
4637

47-
# Write-Output "build: Packaging project in $src"
38+
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
39+
if($LASTEXITCODE -ne 0) { throw "Build failed" }
4840

49-
# if ($suffix) {
50-
# & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
51-
# } else {
52-
# & dotnet pack -c Release --no-build --no-restore -o ../../artifacts
53-
# }
54-
# if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
41+
foreach ($src in Get-ChildItem src/*) {
42+
Push-Location $src
5543

56-
# Pop-Location
57-
# }
44+
Write-Output "build: Packaging project in $src"
5845

59-
# foreach ($test in Get-ChildItem tests/) {
60-
# Push-Location $test
46+
if ($suffix) {
47+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
48+
} else {
49+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts
50+
}
51+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
6152

62-
# Write-Output "build: Testing project in $test"
53+
Pop-Location
54+
}
6355

64-
# & dotnet test -c Release --no-build --no-restore
65-
# if($LASTEXITCODE -ne 0) { throw "Testing failed" }
56+
foreach ($test in Get-ChildItem tests/) {
57+
Push-Location $test
6658

67-
# Pop-Location
68-
# }
59+
Write-Output "build: Testing project in $test"
6960

70-
# if ($env:DUMMY) {
71-
# # GitHub Actions will only supply this to branch builds and not PRs. We publish
72-
# # builds from any branch this action targets (i.e. master and dev).
61+
& dotnet test -c Release --no-build --no-restore
62+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
7363

74-
# Write-Output "DUMMY value: $env:DUMMY"
64+
Pop-Location
65+
}
7566

76-
# # Write-Output "build: Publishing NuGet package"
67+
if ($skipPackaging -eq $false) {
68+
Write-Output "build: Publishing NuGet package"
7769

78-
# # foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
79-
# # & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
80-
# # if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
81-
# # }
70+
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
71+
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
72+
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
73+
}
8274

83-
# # if (!($suffix)) {
84-
# # Write-Output "build: Creating release for version $versionPrefix"
75+
if (!($suffix)) {
76+
Write-Output "build: Creating release for version $versionPrefix"
8577

86-
# # iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
87-
# # }
88-
# }
89-
# } finally {
90-
# Pop-Location
91-
# }
78+
iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
79+
}
80+
} else {
81+
Write-Output "build: Skipping publishing steps for PR build"
82+
}
83+
} finally {
84+
Pop-Location
85+
}

0 commit comments

Comments
 (0)