Skip to content

Commit 9718225

Browse files
authored
Merge pull request #4583 from LuckyPennySoftware/fix-releases
Fix release pipelines
2 parents c67bc5f + 49d6de4 commit 9718225

31 files changed

+147
-132
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,7 @@ indent_size = 2
9797
indent_size = 2
9898

9999
[*.csproj]
100+
indent_size = 2
101+
102+
[*.yml]
100103
indent_size = 2

.github/workflows/ci.yml

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,7 @@ concurrency:
1515
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1616
cancel-in-progress: true
1717
jobs:
18-
build-windows:
19-
strategy:
20-
fail-fast: false
21-
runs-on: windows-latest
22-
steps:
23-
- name: Checkout
24-
uses: actions/[email protected]
25-
with:
26-
fetch-depth: 0
27-
- name: Setup dotnet
28-
uses: actions/setup-dotnet@v4
29-
with:
30-
dotnet-version: |
31-
8.0.x
32-
9.0.x
33-
- name: Build and Test
34-
run: |
35-
dotnet build --configuration Release
36-
37-
dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\UnitTests
38-
39-
dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\AutoMapper.DI.Tests
40-
41-
shell: pwsh
4218
build:
43-
needs: build-windows
4419
strategy:
4520
fail-fast: false
4621
runs-on: ubuntu-latest
@@ -58,15 +33,34 @@ jobs:
5833
- name: Build and Test
5934
run: ./Build.ps1
6035
shell: pwsh
61-
- name: Push to MyGet
62-
if: github.ref == 'refs/heads/master'
63-
env:
64-
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
65-
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
66-
run: ./Push.ps1
67-
shell: pwsh
68-
- name: Artifacts
69-
uses: actions/upload-artifact@v4
70-
with:
71-
name: artifacts
72-
path: artifacts/**/*
36+
build-windows:
37+
needs: build
38+
strategy:
39+
fail-fast: false
40+
runs-on: windows-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/[email protected]
44+
with:
45+
fetch-depth: 0
46+
- name: Setup dotnet
47+
uses: actions/setup-dotnet@v4
48+
with:
49+
dotnet-version: |
50+
8.0.x
51+
9.0.x
52+
- name: Build and Test
53+
run: ./Build.ps1
54+
shell: pwsh
55+
- name: Push to MyGet
56+
if: github.ref == 'refs/heads/master'
57+
env:
58+
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
59+
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
60+
run: ./Push.ps1
61+
shell: pwsh
62+
- name: Artifacts
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: artifacts
66+
path: artifacts/**/*

.github/workflows/release.yml

Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,62 @@
11
name: Release
2-
32
on:
43
push:
54
tags:
6-
- '*.*.*'
5+
- "*.*.*"
76
permissions:
87
contents: read
9-
108
jobs:
11-
build-windows:
9+
build:
1210
strategy:
1311
fail-fast: false
14-
runs-on: windows-latest
12+
runs-on: ubuntu-latest
1513
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
20-
- name: Setup dotnet
21-
uses: actions/setup-dotnet@v4
22-
with:
23-
dotnet-version: |
24-
8.0.x
25-
9.0.x
26-
- name: Build and Test
27-
run: |
28-
dotnet build --configuration Release
29-
30-
dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\UnitTests
31-
32-
dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\AutoMapper.DI.Tests
33-
34-
shell: pwsh
35-
build:
36-
needs: build-windows
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Setup dotnet
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: |
22+
8.0.x
23+
9.0.x
24+
- name: Build and Test
25+
run: ./Build.ps1
26+
shell: pwsh
27+
build-windows:
28+
needs: build
3729
strategy:
3830
fail-fast: false
39-
runs-on: ubuntu-latest
31+
runs-on: windows-latest
4032
steps:
41-
- name: Checkout
42-
uses: actions/checkout@v4
43-
with:
44-
fetch-depth: 0
45-
- name: Setup dotnet
46-
uses: actions/setup-dotnet@v4
47-
with:
48-
dotnet-version: |
49-
8.0.x
50-
9.0.x
51-
- name: Build and Test
52-
run: ./Build.ps1
53-
shell: pwsh
54-
- name: Push to MyGet
55-
env:
56-
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
57-
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
58-
run: ./Push.ps1
59-
shell: pwsh
60-
- name: Push to NuGet
61-
env:
62-
NUGET_URL: https://api.nuget.org/v3/index.json
63-
NUGET_API_KEY: ${{ secrets.AUTOMAPPER_NUGET_API_KEY }}
64-
run: ./Push.ps1
65-
shell: pwsh
66-
- name: Artifacts
67-
uses: actions/upload-artifact@v4
68-
with:
69-
name: artifacts
70-
path: artifacts/**/*
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Setup dotnet
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: |
41+
8.0.x
42+
9.0.x
43+
- name: Build and Test
44+
run: ./Build.ps1
45+
shell: pwsh
46+
- name: Push to MyGet
47+
env:
48+
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
49+
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
50+
run: ./Push.ps1
51+
shell: pwsh
52+
- name: Push to NuGet
53+
env:
54+
NUGET_URL: https://api.nuget.org/v3/index.json
55+
NUGET_API_KEY: ${{ secrets.AUTOMAPPER_NUGET_API_KEY }}
56+
run: ./Push.ps1
57+
shell: pwsh
58+
- name: Artifacts
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: artifacts
62+
path: artifacts/**/*

AutoMapper.WindowsCI.slnf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"solution": {
3+
"path": "AutoMapper.sln",
4+
"projects": [
5+
"src\\AutoMapper\\AutoMapper.csproj",
6+
"src\\AutoMapper.DI.Tests\\AutoMapper.DI.Tests.csproj",
7+
"src\\UnitTests\\AutoMapper.UnitTests.csproj"
8+
]
9+
}
10+
}

Build.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ $artifacts = ".\artifacts"
2626

2727
if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }
2828

29-
exec { & dotnet test -c Release --results-directory $artifacts -l trx }
29+
if ($env:GITHUB_ACTIONS -eq 'true' -and $env:RUNNER_OS -eq 'Windows') {
30+
Write-Host "✅ Running inside GitHub Actions on a Windows runner"
31+
$solution = "./AutoMapper.WindowsCI.slnf"
32+
}
33+
else {
34+
Write-Host "🖥️ Running locally or on a different platform"
35+
$solution = "./AutoMapper.sln"
36+
}
3037

31-
exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj -c Release -o $artifacts --no-build }
38+
exec { & dotnet test $solution --configuration Release --results-directory $artifacts --logger trx }
39+
40+
# Only pack AutoMapper project on Windows runners in GitHub Actions
41+
if ($env:GITHUB_ACTIONS -eq 'true' -and $env:RUNNER_OS -eq 'Windows') {
42+
exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj --configuration Release --output $artifacts --no-build }
43+
}

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
<ImplicitUsings>enable</ImplicitUsings>
1010
</PropertyGroup>
1111

12+
<PropertyGroup>
13+
<IsMac>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_OSX())))</IsMac>
14+
<IsWindows>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_Windows())))</IsWindows>
15+
</PropertyGroup>
16+
17+
<PropertyGroup Condition="'$(TargetFramework)' == 'net471' Or '$(TargetFramework)' == 'netstandard2.0'">
18+
<DefineConstants>$(DefineConstants);FULL_OR_STANDARD</DefineConstants>
19+
</PropertyGroup>
20+
1221
<ItemGroup>
1322
<Using Include="System.Reflection"/>
1423
<Using Include="System.Diagnostics"/>

src/AutoMapper/AutoMapper.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</PropertyGroup>
3131

3232
<PropertyGroup Condition=" '$(IsWindows)' == 'true' ">
33-
<TargetFrameworks>$(TargetFrameworks);net462</TargetFrameworks>
33+
<TargetFrameworks>$(TargetFrameworks);net471</TargetFrameworks>
3434
</PropertyGroup>
3535

3636
<ItemGroup>
@@ -47,9 +47,9 @@
4747
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="[8.0.0, )"/>
4848
<PackageReference Include="Microsoft.Extensions.Options" Version="[8.0.0, )"/>
4949
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="[8.14.0, )"/>
50-
<PackageReference Include="Microsoft.Bcl.HashCode" Version="[6.0.0, )" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
50+
<PackageReference Include="Microsoft.Bcl.HashCode" Version="[6.0.0, )" Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'net471'" />
5151
<PackageReference Include="System.Reflection.Emit" Version="[4.7.0, )" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
52-
<PackageReference Include="PolySharp" Version="1.15.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" PrivateAssets="All" />
52+
<PackageReference Include="PolySharp" Version="1.15.0" Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'net471'" PrivateAssets="All" />
5353

5454
<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All"/>
5555
<!-- <PackageReference Include="Microsoft.DotNet.ApiCompat" Version="7.0.0-beta.22074.1" PrivateAssets="All" /> -->

src/AutoMapper/Configuration/PathConfigurationExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal static IPropertyMapConfiguration Create(LambdaExpression destination, L
6666
public LambdaExpression SourceExpression => _sourceExpression;
6767
public LambdaExpression GetDestinationExpression() => _destinationExpression;
6868
public IPropertyMapConfiguration Reverse() => Create(_sourceExpression, _destinationExpression);
69-
#if NETSTANDARD2_0
69+
#if FULL_OR_STANDARD
7070
public bool Ignored => false;
7171
#endif
7272

src/AutoMapper/Execution/TypeMapPlanBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ public IValueResolver CloseGenerics(TypeMap typeMap) => _members[0].DeclaringTyp
589589
Array.ConvertAll(_members, m => m.Name), typeMap))
590590
: this;
591591

592-
#if NETSTANDARD2_0
592+
#if FULL_OR_STANDARD
593593
public string SourceMemberName => null;
594594
#endif
595595
}
@@ -607,7 +607,7 @@ public Expression GetExpression(IGlobalConfiguration configuration, MemberMap me
607607
configuration.ConvertReplaceParameters(Lambda, [source, destination, destinationMember, ContextParameter]);
608608

609609
public MemberInfo GetSourceMember(MemberMap _) => null;
610-
#if NETSTANDARD2_0
610+
#if FULL_OR_STANDARD
611611
public string SourceMemberName => null;
612612
public LambdaExpression ProjectToExpression => null;
613613
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
@@ -634,7 +634,7 @@ public Expression GetExpression(IGlobalConfiguration configuration, MemberMap me
634634
public MemberInfo GetSourceMember(MemberMap _) => Lambda.GetMember();
635635
public LambdaExpression ProjectToExpression => Lambda;
636636

637-
#if NETSTANDARD2_0
637+
#if FULL_OR_STANDARD
638638
public string SourceMemberName => null;
639639
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
640640
#endif
@@ -701,7 +701,7 @@ AutoMapperConfigurationException BuildExceptionMessage()
701701
_ => memberMap.SourceMembers.Length == 1 ? memberMap.SourceMembers[0] : null
702702
};
703703

704-
#if NETSTANDARD2_0
704+
#if FULL_OR_STANDARD
705705
public LambdaExpression ProjectToExpression => null;
706706
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
707707
#endif
@@ -760,7 +760,7 @@ public Expression GetExpression(IGlobalConfiguration configuration, MemberMap me
760760

761761
public MemberInfo GetSourceMember(MemberMap _) => SourceMemberLambda?.GetMember();
762762

763-
#if NETSTANDARD2_0
763+
#if FULL_OR_STANDARD
764764
public LambdaExpression ProjectToExpression => null;
765765
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
766766
#endif

src/AutoMapper/Internal/Polyfill.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Diagnostics.CodeAnalysis;
33
using System.Runtime.CompilerServices;
44

5-
#if NETSTANDARD2_0
5+
#if FULL_OR_STANDARD
66
namespace AutoMapper;
77

88
internal static class Polyfill

0 commit comments

Comments
 (0)