Skip to content

Commit

Permalink
feat(package): updated package settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zhifenglee-aelf committed Oct 9, 2024
1 parent f02c202 commit 058fe0f
Show file tree
Hide file tree
Showing 21 changed files with 542 additions and 303 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/publish-package-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest
env:
WORKING_DIRECTORY: AElf.ExceptionHandler/
environment: prod
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensure the full history is fetched so we can check the commit history

- name: Verify tag is on master branch
id: verify_tag
run: |
# Get the commit SHA of the tag
TAG_COMMIT=$(git rev-list -n 1 $GITHUB_REF)
# Check if the commit exists on the master branch
if git merge-base --is-ancestor $TAG_COMMIT origin/master; then
echo "Tag commit is on master branch."
echo "IS_ON_MASTER=true" >> $GITHUB_ENV
else
echo "Tag commit is not on master branch."
echo "IS_ON_MASTER=false" >> $GITHUB_ENV
fi
- name: Stop if not on master
if: env.IS_ON_MASTER != 'true'
run: |
echo "This tag was not created from the master branch. Exiting."
exit 1
- name: Setup .NET
if: env.IS_ON_MASTER == 'true'
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.*' # Change this to the .NET version you're using

- name: Extract version from tag
if: env.IS_ON_MASTER == 'true'
run: |
TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
VERSION=${TAG_NAME#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Pack
if: env.IS_ON_MASTER == 'true'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: dotnet pack --configuration Release --output nupkgs /p:Version=$VERSION

- name: Publish NuGet packages
if: env.IS_ON_MASTER == 'true'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
dotnet nuget push "nupkgs/*.nupkg" --api-key ${{ secrets.TEMPLATES_NUGET_API_KEY }} --source ${{ vars.TEMPLATES_NUGET_SOURCE_URL }}
13 changes: 0 additions & 13 deletions .idea/.idea.AOPExceptionModule/.idea/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion AOPExceptionModule.sln → AElf.ExceptionHandler.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AOPExceptionModule", "AOPExceptionModule\AOPExceptionModule.csproj", "{0EE0548B-D1FF-4209-97EB-DAC11D0E210A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.ExceptionHandler", "AElf.ExceptionHandler\AElf.ExceptionHandler.csproj", "{0EE0548B-D1FF-4209-97EB-DAC11D0E210A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
33 changes: 33 additions & 0 deletions AElf.ExceptionHandler/AElf.ExceptionHandler.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageType>Contract</PackageType>
<PackageId>AElf.ExceptionHandler</PackageId>
<Title>AElf ExceptionHandler</Title>
<Authors>AElf</Authors>
<Description>An ExceptionHandler module for use in ABP and Orleans framework.</Description>
<PackageTags>abp;module;grains;orleans</PackageTags>
<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/AElfProject/AOPExceptionModule</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/AElfProject/AOPExceptionModule</PackageProjectUrl>
<RootNamespace>AElf.ExceptionHandler</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.2.6" />
<PackageReference Include="Volo.Abp.Core" Version="8.0.5" />
</ItemGroup>

<PropertyGroup>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="" />
<None Include="../LICENSE" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
34 changes: 34 additions & 0 deletions AElf.ExceptionHandler/AOPExceptionModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Collections.Concurrent;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;

namespace AElf.ExceptionHandler;

public class AOPExceptionModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddTransient<ExceptionHandlerInterceptor>()
.AddTransient<IInterceptor, ExceptionHandler>()
.AddSingleton<ConcurrentDictionary<string, ExceptionHandlerInfo>>()
.AddSingleton<ConcurrentDictionary<string, Func<object, object[], Task>>>();

context.Services.OnRegistered(options =>
{
var methodInfos = options.ImplementationType.GetMethods();
// Check if any of the class methods is decorated with the ExceptionHandlerAttribute
foreach (var methodInfo in methodInfos)
{
if (methodInfo.IsDefined(typeof(ExceptionHandlerAttribute), true))
{
var result = options.Interceptors.TryAdd<ExceptionHandlerInterceptor>();
if (!result)
{
throw new AbpException("ExceptionHandlingInterceptor is already registered.");
}
}
}
});
}
}
Loading

0 comments on commit 058fe0f

Please sign in to comment.