Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 76 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,112 @@
name: Build
name: Build & Publish

on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
workflow_dispatch:
push:
branches: [ 'main' ] # Run the workflow when pushing to the main branch
branches: [ main ]
pull_request:
branches: [ '*' ] # Run the workflow for all pull requests
branches: [ '*' ]
release:
types: [ published ] # Run the workflow when a new GitHub release is published
types: [ published ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
NuGetDirectory: ${{ github.workspace }}/nuget

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
contents: read
packages: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for MinVer

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Cache NuGet
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj') }}
restore-keys: |
nuget-${{ runner.os }}-

- name: Restore dependencies
run: dotnet restore
- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --no-restore
- name: Build
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
- name: Test
run: dotnet test -c Release --no-build --verbosity normal

create_nuget:
name: create nuget package
needs: [ build ]
pack:
runs-on: ubuntu-latest
needs: build
permissions:
contents: read

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
filter: tree:0

# Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v4

# Create the NuGet package in the folder from the environment variable NuGetDirectory
- name: Create package
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}

# Publish the NuGet package as an artifact, so they can be used in the following jobs
- uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg

deploy:
# Publish only when creating a GitHub Release
# You can update this logic if you want to manage releases differently
# github.ref == 'refs/heads/main'
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for MinVer

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Pack
run: dotnet pack -c Release --no-build --output ${{ env.NuGetDirectory }}

- uses: actions/upload-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}/*.nupkg
if-no-files-found: error
retention-days: 7

publish:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ create_nuget ]
needs: pack
permissions:
contents: read
packages: write

steps:
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}

# Install the .NET SDK indicated in the global.json file
- name: Setup .NET Core
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish NuGet package
- name: Push to NuGet
run: |
cd ${{ env.NuGetDirectory }}
dotnet nuget push "*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source ${{ vars.NUGET_REPO_URL }} --skip-duplicate
dotnet nuget push "*.nupkg" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source ${{ vars.NUGET_REPO_URL }} \
--skip-duplicate
1 change: 0 additions & 1 deletion src/SimpleBitware.AspectNet/SimpleBitware.AspectNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PropertyGroup>
<PackageId>SimpleBitware.AspectNet</PackageId>
<Description>AspectNet enables aspect oriented programming</Description>
<Version>1.0.0</Version>
<Authors>Lucian Bornaz</Authors>
<Company>Simple Bitware</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
15 changes: 8 additions & 7 deletions tests/ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.3"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\SimpleBitware.AspectNet\SimpleBitware.AspectNet.csproj" />
<ProjectReference Include="..\..\src\SimpleBitware.AspectNet\SimpleBitware.AspectNet.csproj"/>
</ItemGroup>

<UsingTask
TaskName="AspectNetWeaverTask"
AssemblyFile="$(ProjectDir)bin\$(Configuration)\$(TargetFramework)\SimpleBitware.AspectNet.dll" />
AssemblyFile="$(ProjectDir)bin\$(Configuration)\$(TargetFramework)\SimpleBitware.AspectNet.dll"/>

<Target Name="RunAspectNetWeaver" AfterTargets="Build">
<AspectNetWeaverTask
AssemblyPath="$(TargetPath)"
References="@(ReferencePath)"
Debug="True"
<AspectNetWeaverTask
AssemblyPath="$(TargetPath)"
References="@(ReferencePath)"
Debug="True"
GenerateDebugFiles="False"/>
</Target>

Expand Down
Loading