-
Notifications
You must be signed in to change notification settings - Fork 386
167 lines (156 loc) · 7.59 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build
on:
push:
branches:
- '**'
paths-ignore:
- '**.md'
pull_request:
branches:
- '**'
paths-ignore:
- '**.md'
release:
types:
- published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
mysqlCurrentSqlMode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
mysqlLegacySqlMode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
# Currently no ONLY_FULL_GROUP_BY, see #1167:
mariadbSqlMode: STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
maxConnections: 512
skipAllTests: false
skipWindowsTests: false
jobs:
NuGet:
if: (github.event_name == 'push' || github.event_name == 'release') && github.repository == 'PomeloFoundation/Pomelo.EntityFrameworkCore.MySql'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: .NET Information
shell: pwsh
run: |
dotnet --info
- name: NuGet Pack
shell: pwsh
run: |
$officialBuild = '${{ github.ref }}' -match '(?<=^refs/tags/)\d+\.\d+\.\d+.*$'
$officialVersion = $Matches.0
$wipBuild = '${{ github.ref }}' -match '^refs/heads/.*-wip$'
$ciBuildOnly = $wipBuild -or ('${{ github.ref }}' -match '^refs/heads/(?:main|.+-maint|release/.+)$')
$continuousIntegrationTimestamp = Get-Date -Format yyyyMMddHHmmss
$buildSha = '${{ github.sha }}'.SubString(0, 7);
$pack = $officialBuild -or $ciBuildOnly
$pushToAzureArtifacts = $pack
$pushToMygetOrg = $pack
$pushToNugetOrg = $pack -and $officialBuild
echo "pushToAzureArtifacts: $pushToAzureArtifacts"
echo "pushToMygetOrg: $pushToMygetOrg"
echo "pushToNugetOrg: $pushToNugetOrg"
echo "officialBuild: $officialBuild"
echo "officialVersion: $officialVersion"
echo "wipBuild: $wipBuild"
echo "ciBuildOnly: $ciBuildOnly"
echo "continuousIntegrationTimestamp: $continuousIntegrationTimestamp"
echo "buildSha: $buildSha"
echo "pack: $pack"
if ($pack)
{
$projectFiles = Get-ChildItem src/*/*.csproj -Recurse | % { $_.FullName }
$combinations = @('default', @('Release')), @('withPdbs', @('Release', 'Debug')) #, @('embeddedPdbs', @('Release', 'Debug'))
foreach ($combination in $combinations)
{
$type = $combination[0]
$configurations = $combination[1]
foreach ($configuration in $configurations)
{
$arguments = 'pack', '-c', $configuration, '-o', "nupkgs/$configuration/$type", '-p:ContinuousIntegrationBuild=true'
if ($officialBuild)
{
$arguments += "-p:OfficialVersion=$officialVersion"
}
if ($ciBuildOnly)
{
$arguments += "-p:ContinuousIntegrationTimestamp=$continuousIntegrationTimestamp"
$arguments += "-p:BuildSha=$buildSha"
}
switch ($type)
{
'withPdbs' { $arguments += '-p:PackPdb=true', '-p:IncludeSymbols=false' }
'embeddedPdbs' { $arguments += '-p:DebugType=embedded', '-p:IncludeSymbols=false' }
}
foreach ($projectFile in $projectFiles)
{
echo "Type: $type, Configuration: $configuration, Project: $projectFile"
echo "Pack command: dotnet $(($arguments + $projectFile) -join ' ')"
& dotnet ($arguments + $projectFile)
}
}
}
}
echo "pushToAzureArtifacts=$pushToAzureArtifacts" >> $env:GITHUB_ENV
echo "pushToMygetOrg=$pushToMygetOrg" >> $env:GITHUB_ENV
echo "pushToNugetOrg=$pushToNugetOrg" >> $env:GITHUB_ENV
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: nupkgs
- name: "NuGet Push - AZDO Feed - Debug"
if: ${{ env.pushToAzureArtifacts == 'true' }}
working-directory: nupkgs
shell: pwsh
run: |
# https://learn.microsoft.com/en-us/azure/devops/artifacts/nuget/dotnet-exe?view=azure-devops#publish-packages-from-external-sources
dotnet new nugetconfig --force
Get-ChildItem -Recurse -Force | Select-Object -ExpandProperty FullName
Get-Content ./nuget.config
try
{
dotnet nuget add source 'https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-debug/nuget/v3/index.json' --name 'azdo-pomelo-efcore-debug' --username '${{ vars.AZUREDEVOPS_POMELO_ALLPACKAGES_PUSHNEW_USERNAME }}' --password '${{ secrets.AZUREDEVOPS_POMELO_ALLPACKAGES_PUSHNEW_PASSWORD }}' --store-password-in-clear-text --configfile './nuget.config'
dotnet nuget push './Debug/withPdbs/**/*.nupkg' --api-key 'foo' --source 'azdo-pomelo-efcore-debug' --skip-duplicate
}
finally
{
Remove-Item './nuget.config' -Recurse -Force
Get-ChildItem -Recurse -Force | Select-Object -ExpandProperty FullName
}
# - name: "NuGet Push - AZDO Feed - Release"
# if: ${{ env.pushToAzureArtifacts == 'true' }}
# working-directory: nupkgs
# shell: pwsh
# run: |
# # https://learn.microsoft.com/en-us/azure/devops/artifacts/nuget/dotnet-exe?view=azure-devops#publish-packages-from-external-sources
# dotnet new nugetconfig --output './nuget.config' --force
# try
# {
# dotnet nuget add source 'https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-public/nuget/v3/index.json' --name 'azdo-pomelo-efcore-public' --username '${{ vars.AZUREDEVOPS_POMELO_ALLPACKAGES_PUSHNEW_USERNAME }}' --password '${{ secrets.AZUREDEVOPS_POMELO_ALLPACKAGES_PUSHNEW_PASSWORD }}' --store-password-in-clear-text --configfile './nuget.config'
#
# dotnet nuget push './Release/withPdbs/**/*.nupkg' --api-key 'foo' --source 'azdo-pomelo-efcore-public' --skip-duplicate
# }
# finally
# {
# Remove-Item './nuget.config' -Recurse -Force
# }
- name: "NuGet Push - myget.org - Debug"
if: ${{ env.pushToMygetOrg == 'true' }}
working-directory: nupkgs
shell: pwsh
run: dotnet nuget push './Debug/withPdbs/**/*.nupkg' --api-key '${{ secrets.MYGETORG_POMELO_ALLPACKAGES_DEBUG_PUSHNEW }}' --source 'https://www.myget.org/F/pomelo-debug/api/v3/index.json' --skip-duplicate
- name: "NuGet Push - myget.org - Release"
if: ${{ env.pushToMygetOrg == 'true' }}
working-directory: nupkgs
shell: pwsh
run: dotnet nuget push './Release/default/**/*.nupkg' --api-key '${{ secrets.MYGETORG_POMELO_ALLPACKAGES_PUSHNEW }}' --source 'https://www.myget.org/F/pomelo/api/v3/index.json' --skip-duplicate
- name: "NuGet Push - nuget.org - Release"
if: ${{ env.pushToNugetOrg == 'true' }}
working-directory: nupkgs
shell: pwsh
run: dotnet nuget push './Release/default/**/*.nupkg' --api-key '${{ secrets.NUGETORG_POMELO_ALLPACKAGES_PUSHNEW }}' --source 'https://api.nuget.org/v3/index.json'