Skip to content

Use solely dotnet nuget instead of nuget, because it is not avail… #248

Use solely dotnet nuget instead of nuget, because it is not avail…

Use solely dotnet nuget instead of nuget, because it is not avail… #248

Workflow file for this run

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 --output './nuget.config' --force
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
}
- 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'