Skip to content

Commit

Permalink
Release: V2.0.0
Browse files Browse the repository at this point in the history
Upgraded to latest versions
  • Loading branch information
nfMalde authored Oct 11, 2024
2 parents 98299d7 + 9876d90 commit 89be17c
Showing 7 changed files with 193 additions and 23 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Deploy
on:
push:
branches: [ master ]

jobs:
test:
runs-on: windows-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: "Build and Test"
run: |
dotnet build
dotnet test
version:
needs: test
runs-on: windows-latest
outputs:
version: ${{ steps.newversion.outputs.version }}
tag: ${{ steps.newversion.outputs.tag }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set New Version
id: newversion
shell: pwsh
run: |
$currentVersion = git describe --abbrev=0 --tags --match "v[0-9]*.[0-9]*.[0-9]*-Release"
if ($currentVersion) {
$v = $currentVersion.Split('-')[0].TrimStart('v')
Write-Output "RELEASE: New Version: $($v)"
Write-Output "version=$($v)" >> $Env:GITHUB_OUTPUT
Write-Output "tag=$($currentVersion)" >> $Env:GITHUB_OUTPUT
} else {
$currentVersion = git describe --abbrev=0 --tags --match "v[0-9]*.[0-9]*.[0-9]*"
$currentVersion = git describe --match "$($currentVersion)" --long
$versionParts = $currentVersion.Split('-')
$v = $versionParts[0]
$increment = [int]$versionParts[1]

if ($increment -gt 0) {
$increment = 1
}

$vparts = $v.Split('.')
$vparts[2] = "$([int]$vparts[2] + [int]$increment)"
$v = $vparts -join '.'
$v = "$($v)".TrimStart("v")
Write-Output "New Version: $($v)"
Write-Output "version=$($v)" >> $Env:GITHUB_OUTPUT
Write-Output "tag=" >> $Env:GITHUB_OUTPUT
}
prepublish:
needs: [test, version]
runs-on: windows-latest
outputs:
description: ${{ steps.meta.outputs.description }}
changeinfo: ${{ steps.meta.outputs.changeinfo }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
fetch-depth: 0
- name : Get Meta Data
shell: pwsh
id: meta
run: |
[xml]$xml = get-content "src/Autofac.EasyPropInject.csproj"
$description = $xml.SelectSingleNode("//Description").InnerText;
$changes = $xml.SelectSingleNode("//PackageReleaseNotes").InnerText;
Write-Output "description=$($description.Trim().Replace("`t", '') | ConvertTo-Json)" >> $Env:GITHUB_OUTPUT
Write-Output "changeinfo=$($changes.Trim().Replace("`t", '') | ConvertTo-Json)" >> $Env:GITHUB_OUTPUT
publish:
needs: [test, version, prepublish]
runs-on: windows-latest
steps:
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Checkout Sources
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create Package
run: |
dotnet build src/Autofac.EasyPropInject.csproj -c Release -p:AssemblyVersion=${{ needs.version.outputs.version }} -p:PackageVersion=${{ needs.version.outputs.version }}
dotnet pack src/Autofac.EasyPropInject.csproj -c Release -p:AssemblyVersion=${{ needs.version.outputs.version }} -p:PackageVersion=${{ needs.version.outputs.version }} --output nget_pkg
- name: Create Release and Tag
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: v${{ needs.version.outputs.version }}
release_name: Release v${{ needs.version.outputs.version }}
body: |
# Release Info Version ${{ needs.version.outputs.version }}
## Info
${{fromJSON(needs.prepublish.outputs.description)}}
## Changes in v${{ needs.version.outputs.version }}
${{fromJSON(needs.prepublish.outputs.changeinfo)}}
draft: false
prerelease: false
- name: Delete Release Tag
if: ${{needs.version.outputs.tag}}
uses: dev-drprasad/[email protected]
with:
tag_name: ${{needs.version.outputs.tag}}
github_token: ${{ secrets.GITHUB_TOKEN }}
delete_release: false
- name: Upload Release Asset Pkg
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./nget_pkg/Autofac.EasyPropInject.${{ needs.version.outputs.version }}.nupkg
asset_name: Autofac.EasyPropInject.${{ needs.prepublish.version.version }}.nupkg
asset_content_type: application/zip
- name: Upload Release Asset DLL
id: upload-release-asset2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: src/bin/Release/net8.0/Autofac.EasyPropInject.dll
asset_name: Autofac.EasyPropInject.dll
asset_content_type: application/octet-stream
- name: Publish package to nuget
id: nugetpush
run: dotnet nuget push "nget_pkg/Autofac.EasyPropInject.${{ needs.version.outputs.version }}.nupkg" -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json



21 changes: 21 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull Request Check
on:
pull_request:
branches:
- master
jobs:
test:
runs-on: windows-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET 68
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: "Build and Test"
run: |
dotnet build
dotnet test
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,11 +3,10 @@


# Important!
Due to breaking changes to Autofac API with version 6.x older Autofac.EasyPropInject Readme can be found in 1.0.x (Autofac <=4>) and 1.1.x (Autofac >=5 < 6>).
master and 1.2.x will show code examples and info only for Autofac >= 6.
Due to new Autofac v.8 Version - older versions stay as they are. Updates only occur to latest version released.

# Autofac.EasyPropInject
An extension i created to make it possible to to inject properties by attribute, without any other helper libs in .NET Core for [Autofac](https://github.com/autofac/Autofac).
An extension i created to make it possible to to inject properties by attribute, without any other helper libs in .NET Standard for [Autofac](https://github.com/autofac/Autofac).

# Install
## Nuget
@@ -73,6 +72,7 @@ Since the type casting feature new in 1.2.x of EasyPropInject is handy sometimes


# Whats new?
* 2.0.0 - Upgraded to latest Autofac (8.x)
* 1.2.5 - Upgraded to Autofac 6.3.x, Added support for private and protected properties See tests for example (https://github.com/nfMalde/Autofac.EasyPropInject/blob/1.2.x/tests/Autofac.EasyPropInject.Testing/InjectionTests.cs)
* 1.2.4 - Upgraded to Autofac 6.2.x
* 1.2.3 - Upgraded to Autofac 6.1.x
5 changes: 3 additions & 2 deletions nugetdocs/README.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@


# Important!
Due to breaking changes to Autofac API with version 6.x older Autofac.EasyPropInject Readme can be found in 1.0.x (Autofac <=4>) and 1.1.x (Autofac >=5 < 6>).
master and 1.2.x will show code examples and info only for Autofac >= 6.
Due to new Autofac v.8 Version - older versions stay as they are. Updates only occur to latest version released.


# Autofac.EasyPropInject
An extension i created to make it possible to to inject properties by attribute, without any other helper libs in .NET Core for [Autofac](https://github.com/autofac/Autofac).
@@ -74,6 +74,7 @@ Since the type casting feature new in 1.2.x of EasyPropInject is handy sometimes


# Whats new?
* 2.0.0 - Upgraded to latest Autofac (8.x)
* 1.2.5 - Upgraded to Autofac 6.3.x, Added support for private and protected properties See tests for example (https://github.com/nfMalde/Autofac.EasyPropInject/blob/1.2.x/tests/Autofac.EasyPropInject.Testing/InjectionTests.cs)
* 1.2.4 - Upgraded to Autofac 6.2.x
* 1.2.3 - Upgraded to Autofac 6.1.x
9 changes: 4 additions & 5 deletions src/Autofac.EasyPropInject.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Allows to inject properties of classes by using annotations.</Description>
<Authors>Malte Peters</Authors>
@@ -11,14 +11,13 @@
<PackageProjectUrl>https://github.com/nfMalde/Autofac.EasyPropInject</PackageProjectUrl>
<RepositoryUrl>https://github.com/nfMalde/Autofac.EasyPropInject</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
<PackageReleaseNotes>Upgraded to Autofac 6.3.x
Added support for private and protected properties</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>Upgraded to Autofac 8.x</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Autofac" Version="8.1.1" />
<None Include="..\nugetdocs\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>

@@ -11,11 +11,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="nunit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Autofac" Version="8.1.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="nunit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
</ItemGroup>

<ItemGroup>
14 changes: 7 additions & 7 deletions tests/Autofac.EasyPropInject.Testing/InjectionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Autofac.EasyPropInject.Testing.mocks;
using NUnit.Framework;

using Autofac.EasyPropInject;
namespace Autofac.EasyPropInject.Testing
{
/// <summary>
@@ -38,26 +38,26 @@ public void ItShouldInjectPropertiesOfInstanceAndChildInstances()
{
var m1 = this.container.Resolve<IMock1>();

Assert.NotNull(m1.Mock2Property);
Assert.NotNull(m1.Mock2Property.Mock3Property);
Assert.NotNull(m1.Mock2Property.Mock3Property.Mock4ResolvedAsMainType);
Assert.That(m1.Mock2Property != null);
Assert.That(m1.Mock2Property.Mock3Property != null);
Assert.That(m1.Mock2Property.Mock3Property.Mock4ResolvedAsMainType != null);
}

[Test]
public void ItShouldResolvePrivateProperties()
{
var mPrivate = this.container.Resolve<IMockPrivate>();

Assert.NotNull(mPrivate.Mock1Test());
Assert.That(mPrivate.Mock1Test() != null);
}

[Test]
public void ItShouldResolveProtectedProperties()
{
var mPrivate = this.container.Resolve<IMockProtected>();

Assert.NotNull(mPrivate.GetMockPrivate());
Assert.NotNull(mPrivate.GetMockPrivate().Mock1Test());
Assert.That(mPrivate.GetMockPrivate() != null);
Assert.That(mPrivate.GetMockPrivate().Mock1Test() != null);
}
}
}

0 comments on commit 89be17c

Please sign in to comment.