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
142 changes: 49 additions & 93 deletions .github/workflows/nuget.publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,85 @@ name: Build and Publish

on:
push:
tags:
- "v*"
branches:
- main
- develop
workflow_dispatch:

permissions:
contents: write # Needed for tagging
contents: read

env:
DOTNET_VERSION: "8.x" # Using .NET 8 as per Bee project requirements
DOTNET_VERSION: "8.x"

jobs:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
package_version: ${{ steps.set_package_version.outputs.package_version }}
is_release: ${{ steps.set_package_version.outputs.is_release }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history and tags
uses: actions/checkout@v4

- name: Set up .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Extract Central Version
id: extract_version
- name: Determine Package Version
id: set_package_version
run: |
if [ ! -f "Directory.Build.props" ]; then
echo "Error: Directory.Build.props not found in the repository root."
exit 1
fi

VERSION=$(grep -oP '(?<=<Version>)[^<]+' Directory.Build.props)

if [ -z "$VERSION" ]; then
echo "Error: <Version> tag not found in Directory.Build.props."
exit 1
fi

echo "Central Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
# Release: use version from Directory.Build.props as-is
PACKAGE_VERSION="${VERSION}"
IS_RELEASE="true"
else
# Pre-release: append preview suffix
PACKAGE_VERSION="${VERSION}-preview.${GITHUB_RUN_NUMBER}"
IS_RELEASE="false"
fi

echo "Package Version: $PACKAGE_VERSION"
echo "package_version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
echo "is_release=${IS_RELEASE}" >> $GITHUB_OUTPUT

- name: Validate Semantic Versioning
run: |
VERSION_REGEX="^[0-9]+\.[0-9]+\.[0-9]+$"
if [[ "${{ env.VERSION }}" =~ $VERSION_REGEX ]]; then
echo "Version '${{ env.VERSION }}' is valid."
VERSION="${{ steps.set_package_version.outputs.package_version }}"
# Match release (1.2.3) or pre-release (1.2.3-preview.42)
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "Version '$VERSION' is valid."
else
echo "Error: Version '${{ env.VERSION }}' does not follow semantic versioning (e.g., 1.0.0)."
echo "Error: Version '$VERSION' does not follow semantic versioning."
exit 1
fi

- name: Determine Package Version
id: set_package_version
run: |
# Determine the current branch
CURRENT_BRANCH="${GITHUB_REF#refs/heads/}"
echo "Current Branch: $CURRENT_BRANCH"
test:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Define release or pre-release based on branch
if [ "$CURRENT_BRANCH" == "main" ]; then
PACKAGE_VERSION="${VERSION}"
else
BUILD_NUMBER="${GITHUB_RUN_NUMBER}"
PACKAGE_VERSION="${VERSION}-preview.${BUILD_NUMBER}"
fi
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

echo "package_version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
- name: Restore
run: dotnet restore

# Debug statement
echo "Determined Package Version: $PACKAGE_VERSION"
- name: Build
run: dotnet build --configuration Release --no-restore

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

build-pack-publish:
needs: setup
needs: [setup, test]
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -90,65 +90,21 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Set up .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Create nupkg Directory
run: mkdir -p ./nupkg

- name: Restore
run: dotnet restore "${{ matrix.project }}"

- name: Build
run: dotnet build "${{ matrix.project }}" --configuration Release /p:PackageVersion=${{ needs.setup.outputs.package_version }}

- name: Test
run: dotnet test --configuration Release --no-build
run: dotnet build "${{ matrix.project }}" --configuration Release --no-restore /p:PackageVersion=${{ needs.setup.outputs.package_version }}

- name: Pack
run: dotnet pack "${{ matrix.project }}" --configuration Release /p:PackageVersion=${{ needs.setup.outputs.package_version }} --output ./nupkg
run: dotnet pack "${{ matrix.project }}" --configuration Release --no-build /p:PackageVersion=${{ needs.setup.outputs.package_version }} --output ./nupkg

- name: Publish
if: github.event_name != 'pull_request'
run: dotnet nuget push "./nupkg/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json

tag:
needs: [setup, build-pack-publish]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' # Only create tags on main branch
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Create and Push Git Tag
run: |
PACKAGE_VERSION="${{ needs.setup.outputs.package_version }}"

echo "PACKAGE_VERSION is '$PACKAGE_VERSION'"

if [ -z "$PACKAGE_VERSION" ]; then
echo "Error: PACKAGE_VERSION is empty."
exit 1
fi

# Check if tag already exists
if git rev-parse "$PACKAGE_VERSION" >/dev/null 2>&1; then
echo "Tag $PACKAGE_VERSION already exists. Skipping tagging."
else
git tag "$PACKAGE_VERSION"
git push origin "$PACKAGE_VERSION"
echo "Tag $PACKAGE_VERSION created and pushed successfully."
fi
run: dotnet nuget push "./nupkg/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
16 changes: 3 additions & 13 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

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

Expand All @@ -26,14 +26,4 @@ jobs:
run: dotnet build --configuration Release --no-restore

- name: Run tests
run: dotnet test --no-restore --verbosity normal

- name: Check build warnings as errors
run: |
# This step ensures that TreatWarningsAsErrors is respected
dotnet build --configuration Release --no-restore --verbosity detailed | tee build.log
if grep -q "warning" build.log; then
echo "Build warnings found. Check the build log for details."
cat build.log | grep -i warning
exit 1
fi
run: dotnet test --configuration Release --no-build --verbosity normal
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- New `IWorkflowStep` and `IWorkflowStep<TPayload, TError>` interfaces to replace `IWorkflowActivity`
- New `IWorkflowSteps` and `IWorkflowSteps<TPayload, TError>` interfaces to replace `IWorkflowActivities`
- New `WorkflowStepsExtensions` class with `AddWorkflowSteps*` extension methods for dependency injection

### Deprecated

- `IWorkflowActivity` and `IWorkflowActivity<TPayload, TError>` — use `IWorkflowStep` / `IWorkflowStep<TPayload, TError>` instead
- `IWorkflowActivities` and `IWorkflowActivities<TPayload, TError>` — use `IWorkflowSteps` / `IWorkflowSteps<TPayload, TError>` instead
- `WorkflowActivitiesExtensions` class and all `AddWorkflowActivities*` methods — use `WorkflowStepsExtensions` and `AddWorkflowSteps*` instead

### Compatibility

- All existing code using the deprecated types and methods will continue to work but will show deprecation warnings
- To migrate, replace:

```csharp
services.AddWorkflowActivities();
```

With:

```csharp
services.AddWorkflowSteps();
```

And replace interface implementations:

```csharp
public class MyStep : IWorkflowActivity<MyPayload, MyError>
```

With:

```csharp
public class MyStep : IWorkflowStep<MyPayload, MyError>
```

## 3.3.0 - 2025.04.24

### Added
Expand Down
8 changes: 4 additions & 4 deletions Zooper.Bee/BranchBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal BranchBuilder(
/// <returns>The branch builder for fluent chaining</returns>
public BranchBuilder<TRequest, TPayload, TSuccess, TError> Do(Func<TPayload, CancellationToken, Task<Either<TError, TPayload>>> activity)
{
_branch.Activities.Add(new WorkflowActivity<TPayload, TError>(activity));
_branch.Activities.Add(new WorkflowStep<TPayload, TError>(activity));
return this;
}

Expand All @@ -40,7 +40,7 @@ public BranchBuilder<TRequest, TPayload, TSuccess, TError> Do(Func<TPayload, Can
/// <returns>The branch builder for fluent chaining</returns>
public BranchBuilder<TRequest, TPayload, TSuccess, TError> Do(Func<TPayload, Either<TError, TPayload>> activity)
{
_branch.Activities.Add(new WorkflowActivity<TPayload, TError>((payload, _) =>
_branch.Activities.Add(new WorkflowStep<TPayload, TError>((payload, _) =>
Task.FromResult(activity(payload))
));
return this;
Expand All @@ -55,7 +55,7 @@ public BranchBuilder<TRequest, TPayload, TSuccess, TError> DoAll(params Func<TPa
{
foreach (var activity in activities)
{
_branch.Activities.Add(new WorkflowActivity<TPayload, TError>(activity));
_branch.Activities.Add(new WorkflowStep<TPayload, TError>(activity));
}
return this;
}
Expand All @@ -69,7 +69,7 @@ public BranchBuilder<TRequest, TPayload, TSuccess, TError> DoAll(params Func<TPa
{
foreach (var activity in activities)
{
_branch.Activities.Add(new WorkflowActivity<TPayload, TError>((payload, _) =>
_branch.Activities.Add(new WorkflowStep<TPayload, TError>((payload, _) =>
Task.FromResult(activity(payload))
));
}
Expand Down
Loading