Refactor memory allocation system to use generic MemoryPool<TAllocator, TOpts> for arena, stack, and free list allocators, replacing custom allocator structs. Introduce MemoryBlock as a safer, more robust replacement for UnTypedArray. Improve thread safety, safety checks, and documentation. Reorder and clarify Allocator enum. Add comprehensive unit tests for all allocators and pointer assertion utilities. Update project to enable safety checks in Debug builds. Remove obsolete interfaces and ensure consistent deallocation with MemoryUtility.Free. BREAKING CHANGE: Custom allocator structs are removed and replaced with MemoryPool-based abstraction. UnTypedArray is replaced by MemoryBlock. Allocator enum order and semantics are changed. Public API changes may require code updates.
104 lines
3.4 KiB
YAML
104 lines
3.4 KiB
YAML
name: Publish NuGet Packages
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v3
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Run tests
|
|
# Run all test projects in the repository. If any test fails, this step will exit non-zero
|
|
# and subsequent packaging/publish steps will not run.
|
|
run: |
|
|
echo "Running all tests..."
|
|
dotnet test --configuration Release --no-restore
|
|
|
|
- name: Check, Build, and Pack Projects
|
|
env:
|
|
NUGET_API_KEY: ${{ secrets.NUGET_TOKEN }}
|
|
SOURCE_URL: "https://git.personalnas.com/api/packages/Misaki/nuget"
|
|
run: |
|
|
mkdir -p ./artifacts
|
|
|
|
for projfile in $(find . -name "*.csproj"); do
|
|
# 1. Check if the project generates a package
|
|
GENERATE_PKG=$(dotnet build "$projfile" --getProperty:GeneratePackageOnBuild)
|
|
if [[ "$GENERATE_PKG" != "true" && "$GENERATE_PKG" != "True" ]]; then
|
|
continue
|
|
fi
|
|
|
|
# 2. Get Package ID and Version
|
|
PACKAGE_ID=$(dotnet build "$projfile" --getProperty:PackageId)
|
|
VERSION=$(dotnet build "$projfile" --getProperty:Version)
|
|
|
|
if [ -z "$PACKAGE_ID" ]; then
|
|
PACKAGE_ID=$(basename "$projfile" .csproj)
|
|
fi
|
|
|
|
echo "Checking $PACKAGE_ID version $VERSION..."
|
|
|
|
# 3. Check Gitea Registry
|
|
LOWER_ID=$(echo "$PACKAGE_ID" | tr '[:upper:]' '[:lower:]')
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
-H "Authorization: token $NUGET_API_KEY" \
|
|
"${SOURCE_URL}/registration/${LOWER_ID}/${VERSION}.json")
|
|
|
|
if [ "$HTTP_CODE" -eq 200 ]; then
|
|
echo "✅ Version $VERSION of $PACKAGE_ID already exists. Skipping..."
|
|
else
|
|
echo "🆕 Version $VERSION of $PACKAGE_ID is new."
|
|
|
|
# 4. EXPLICIT BUILD (Creates the DLLs)
|
|
echo "Building $projfile..."
|
|
if ! dotnet build "$projfile" -c Release; then
|
|
echo "❌ Failed to build $projfile"
|
|
exit 1
|
|
fi
|
|
|
|
# 5. PACK (Packages the DLLs created above)
|
|
echo "Packing $projfile..."
|
|
# We use --no-build because we just built it in step 4
|
|
if ! dotnet pack "$projfile" -c Release -o ./artifacts --no-build; then
|
|
echo "❌ Failed to pack $projfile"
|
|
exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
- name: Publish new packages
|
|
env:
|
|
NUGET_API_KEY: ${{ secrets.NUGET_TOKEN }}
|
|
run: |
|
|
if [ ! -d "./artifacts" ] || [ -z "$(ls -A ./artifacts/*.nupkg 2>/dev/null)" ]; then
|
|
echo "No new packages to publish."
|
|
exit 0
|
|
fi
|
|
|
|
for pkg in ./artifacts/*.nupkg; do
|
|
if [[ "$pkg" == *".symbols.nupkg" ]]; then
|
|
continue
|
|
fi
|
|
|
|
echo "Pushing $pkg..."
|
|
dotnet nuget push "$pkg" \
|
|
--source "https://git.personalnas.com/api/packages/Misaki/nuget/index.json" \
|
|
--api-key "$NUGET_API_KEY" \
|
|
--skip-duplicate
|
|
done
|