Skip to content

Commit 127cbd7

Browse files
authored
Merge pull request #46 from buildersoftio/v1/feature/42
V1/feature/42
2 parents 5591dcc + f30b479 commit 127cbd7

File tree

4 files changed

+149
-32
lines changed

4 files changed

+149
-32
lines changed

.github/workflows/build-and-test.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/sdk-release.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Cortex Package Release Pipeline
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- 'v*/main'
8+
9+
jobs:
10+
build-and-publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up .NET
20+
uses: actions/setup-dotnet@v3
21+
with:
22+
dotnet-version: '9.0.x'
23+
24+
- name: Check if PR was merged
25+
id: check_merge
26+
run: |
27+
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
28+
echo "merged=true" >> $GITHUB_OUTPUT
29+
else
30+
echo "merged=false" >> $GITHUB_OUTPUT
31+
fi
32+
33+
- name: Determine version increment
34+
id: versioning
35+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
36+
run: |
37+
labels=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name')
38+
echo "PR labels: $labels"
39+
increment="patch"
40+
if echo "$labels" | grep -q "feature"; then
41+
increment="minor"
42+
fi
43+
echo "increment=$increment" >> $GITHUB_OUTPUT
44+
45+
- name: Get current version
46+
id: get_version
47+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
48+
run: |
49+
branchName='${{ github.ref_name }}' # e.g., v1/main
50+
echo "Branch name: $branchName"
51+
if [[ $branchName =~ ^v([0-9]+)/main$ ]]; then
52+
majorVersion="${BASH_REMATCH[1]}"
53+
echo "Major version: $majorVersion"
54+
git fetch --tags
55+
latestTag=$(git tag --list "v$majorVersion.*.*" | sort -V | tail -n1)
56+
if [ -n "$latestTag" ]; then
57+
currentVersion="${latestTag#v}"
58+
else
59+
currentVersion="$majorVersion.0.0"
60+
fi
61+
else
62+
echo "Branch name does not match expected pattern"
63+
exit 1
64+
fi
65+
echo "Current version: $currentVersion"
66+
echo "major=$majorVersion" >> $GITHUB_OUTPUT
67+
echo "currentVersion=$currentVersion" >> $GITHUB_OUTPUT
68+
69+
- name: Bump version
70+
id: bump_version
71+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
72+
run: |
73+
increment='${{ steps.versioning.outputs.increment }}'
74+
currentVersion='${{ steps.get_version.outputs.currentVersion }}'
75+
IFS='.' read -ra versionParts <<< "$currentVersion"
76+
major=${versionParts[0]}
77+
minor=${versionParts[1]}
78+
patch=${versionParts[2]}
79+
if [ "$increment" == 'minor' ]; then
80+
minor=$((minor + 1))
81+
patch=0
82+
elif [ "$increment" == 'patch' ]; then
83+
patch=$((patch + 1))
84+
else
85+
echo "Unknown increment type: $increment"
86+
exit 1
87+
fi
88+
newVersion="$major.$minor.$patch"
89+
echo "New version: $newVersion"
90+
echo "newVersion=$newVersion" >> $GITHUB_OUTPUT
91+
92+
- name: Install xmlstarlet
93+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
94+
run: sudo apt-get install -y xmlstarlet
95+
96+
- name: Update project versions
97+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
98+
run: |
99+
newVersion='${{ steps.bump_version.outputs.newVersion }}'
100+
find . -name '*.csproj' -not -path '*/Cortex.Tests/*' | while read csproj; do
101+
echo "Updating version in $csproj"
102+
xmlstarlet ed -P -L -u "//Project/PropertyGroup/Version" -v "$newVersion" "$csproj" || \
103+
xmlstarlet ed -P -L -s "//Project/PropertyGroup" -t elem -n "Version" -v "$newVersion" "$csproj"
104+
done
105+
106+
- name: Build solution
107+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
108+
run: dotnet build --configuration Release
109+
110+
- name: Pack projects
111+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
112+
run: |
113+
dotnet pack --configuration Release --no-build --output ./artifacts
114+
115+
- name: Publish to NuGet
116+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
117+
env:
118+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
119+
run: |
120+
dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
121+
122+
- name: Configure Git
123+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
124+
run: |
125+
git config user.name "GitHub Actions"
126+
git config user.email "actions@github.com"
127+
128+
- name: Create Git tag
129+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
130+
run: |
131+
newVersion='${{ steps.bump_version.outputs.newVersion }}'
132+
git tag -a "v$newVersion" -m "Release v$newVersion"
133+
git push origin "v$newVersion"
134+
135+
- name: Create GitHub Release
136+
if: ${{ steps.check_merge.outputs.merged == 'true' }}
137+
uses: actions/create-release@v1
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
with:
141+
tag_name: "v${{ steps.bump_version.outputs.newVersion }}"
142+
release_name: "v${{ steps.bump_version.outputs.newVersion }}"
143+
draft: false
144+
prerelease: false
145+
body: "Release of version v${{ steps.bump_version.outputs.newVersion }}"

src/Cortex.States.RocksDb/RocksDbStateStore.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Generic;
44
using System.Text.Json;
55
using System.Threading;
6-
using System.Xml.Linq;
76

87
namespace Cortex.States.RocksDb
98
{
@@ -18,10 +17,11 @@ public class RocksDbStateStore<TKey, TValue> : IStateStore<TKey, TValue>
1817
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
1918
public string Name { get; }
2019

21-
public RocksDbStateStore(string name, string dbPath)
20+
public RocksDbStateStore(string name, string dbPath, DbOptions rocksDbOptions = null)
2221
{
2322
Name = name;
24-
var options = new DbOptions().SetCreateIfMissing(true);
23+
var options = rocksDbOptions ?? new DbOptions().SetCreateIfMissing(true);
24+
2525
_db = RocksDbSharp.RocksDb.Open(options, dbPath);
2626

2727
// Default serializers using JSON

src/Cortex.Streams.Files/Cortex.Streams.Files.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<Version>1.0.0</Version>
2020
<PackageLicenseFile>license.md</PackageLicenseFile>
2121
<PackageIcon>cortex.png</PackageIcon>
22-
<PackageId>Cortex.Streams.S3</PackageId>
22+
<PackageId>Cortex.Streams.Files</PackageId>
2323
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2424
<IsPublishable>True</IsPublishable>
2525
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>

0 commit comments

Comments
 (0)