chore: initialize standalone UPM package
Publish UPM package / publish (push) Failing after 1s

This commit is contained in:
2026-08-26 02:50:25 +08:00
commit 50da51bd7f
22 changed files with 393 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
name: Publish UPM package
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
NODE_AUTH_TOKEN: ${{ secrets.SHRINKSDK_PACKAGE_TOKEN }}
steps:
- name: Fetch tagged revision
shell: bash
run: |
set -eu
ref="${{ gitea.sha }}"
test -n "$ref"
git init .
git remote add origin "https://git.crash.work/ShrinkSDK/ShrinkEventBus.Entities.git"
git fetch --depth=1 origin "$ref"
git checkout --detach FETCH_HEAD
- name: Validate immutable release version
shell: bash
run: |
set -eu
tag="$(git describe --exact-match --tags HEAD)"
version="$(node -p "require('./package.json').version")"
test "$tag" = "v$version"
npm pack --dry-run
- name: Publish to ShrinkSDK registry
shell: bash
run: |
set -eu
: "${NODE_AUTH_TOKEN:?SHRINKSDK_PACKAGE_TOKEN is required}"
npmrc="$HOME/.npmrc"
cleanup() { rm -f "$npmrc"; }
trap cleanup EXIT
printf '%s\n' \
'registry=https://git.crash.work/api/packages/ShrinkSDK/npm/' \
'//git.crash.work/api/packages/ShrinkSDK/npm/:_authToken=${NODE_AUTH_TOKEN}' > "$npmrc"
npm publish --registry=https://git.crash.work/api/packages/ShrinkSDK/npm/
+39
View File
@@ -0,0 +1,39 @@
name: Verify standalone Unity package
on:
workflow_dispatch:
jobs:
editmode:
runs-on: unity-2022.3.62f3
container:
image: docker.1panel.live/unityci/editor:ubuntu-2022.3.62f3-windows-mono-3
volumes:
- /www/dk_project/bt-recovery/gitea/runner/seedskey-unity-license:/root/.local/share/unity3d/Unity
- /www/dk_project/bt-recovery/gitea/runner/seedskey-unity-entitlements:/root/.config/unity3d/Unity/licenses
steps:
- name: Fetch selected revision
shell: bash
run: |
set -eu
ref="${{ gitea.sha }}"
git init .
git remote add origin "https://git.crash.work/ShrinkSDK/ShrinkEventBus.Entities.git"
git fetch --depth=1 origin "$ref"
git checkout --detach FETCH_HEAD
- name: Run package EditMode tests
shell: bash
run: |
set -eu
unity_bin="$(command -v unity-editor || command -v unity || command -v Unity || true)"
test -n "$unity_bin"
"$unity_bin" \
-batchmode \
-nographics \
-quit \
-projectPath "$PWD/Development~/UnityProject" \
-runTests \
-testPlatform EditMode \
-testResults "$PWD/TestResults/editmode.xml" \
-logFile "$PWD/TestResults/unity.log"
+10
View File
@@ -0,0 +1,10 @@
/Development~/UnityProject/[Ll]ibrary/
/Development~/UnityProject/[Tt]emp/
/Development~/UnityProject/[Oo]bj/
/Development~/UnityProject/[Ll]ogs/
/Development~/UnityProject/[Uu]ser[Ss]ettings/
/Development~/UnityProject/TestResults/
/Tools~/**/[Bb]in/
/Tools~/**/[Oo]bj/
*.user
*.DotSettings.user
+8
View File
@@ -0,0 +1,8 @@
.git/
.gitea/
Development~/
Tools~/
*.csproj
*.sln
*.user
*.DotSettings.user
+6
View File
@@ -0,0 +1,6 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Ll]ogs/
[Uu]ser[Ss]ettings/
TestResults/
@@ -0,0 +1,15 @@
{
"scopedRegistries": [
{
"name": "ShrinkSDK",
"url": "https://git.crash.work/api/packages/ShrinkSDK/npm/",
"scopes": [
"com.cneicy"
]
}
],
"dependencies": {
"com.unity.test-framework": "1.1.33",
"com.cneicy.shrink-eventbus-entities": "file:../../.."
}
}
@@ -0,0 +1,2 @@
m_EditorVersion: 2022.3.62f3
m_EditorVersionWithRevision: 2022.3.62f3 (96770f904ca7)
+14
View File
@@ -0,0 +1,14 @@
# ShrinkEventBus Entities
`com.cneicy.shrink-eventbus-entities` 是可选 ECS/Burst 适配包。它不创建第二套事件总线,而是让 Burst Job 把 `unmanaged IShrinkEvent` 写入 `NativeQueue<T>`,随后由主线程或 ECS playback system 发布到指定的 `IShrinkEventBus`
```csharp
using var queue = new ShrinkEcsEventQueue<MyEcsEvent>();
var writer = queue.Writer;
// Burst Job 中:writer.Post(in eventData);
// Playback 阶段:
queue.Playback(worldBus);
```
限制:Burst 端只负责事实事件生产,不能直接执行托管 handler、UniTask、取消或结果裁决。
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 02173172caac46a6bb3e586a95c6f8e1
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3c58d5bbaaf44a3dba31fe63ab32fd22
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+53
View File
@@ -0,0 +1,53 @@
#nullable enable
using System;
using ShrinkEventBus;
using Unity.Collections;
namespace ShrinkEventBus.Entities
{
/// <summary>Burst-safe producer queue; playback enters the regular Bus instance.</summary>
public sealed class ShrinkEcsEventQueue<TEvent> : IDisposable where TEvent : unmanaged, IShrinkEvent
{
private NativeQueue<TEvent> _queue;
public ShrinkEcsEventQueue(Allocator allocator = Allocator.Persistent)
{
_queue = new NativeQueue<TEvent>(allocator);
Writer = new ShrinkEcsEventWriter<TEvent>(_queue.AsParallelWriter());
}
public ShrinkEcsEventWriter<TEvent> Writer { get; }
public int Playback(IShrinkEventBus bus)
{
if (bus == null)
throw new ArgumentNullException(nameof(bus));
var count = 0;
while (_queue.TryDequeue(out var eventData))
{
bus.Post(in eventData);
count++;
}
return count;
}
public void Dispose()
{
if (_queue.IsCreated)
_queue.Dispose();
}
}
public readonly struct ShrinkEcsEventWriter<TEvent> where TEvent : unmanaged, IShrinkEvent
{
private readonly NativeQueue<TEvent>.ParallelWriter _writer;
internal ShrinkEcsEventWriter(NativeQueue<TEvent>.ParallelWriter writer)
{
_writer = writer;
}
public void Post(in TEvent eventData) => _writer.Enqueue(eventData);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 05a2db7ffefb4841bdcd63d8fd3ac6fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
{
"name": "ShrinkEventBus.Entities.Runtime",
"rootNamespace": "ShrinkEventBus.Entities",
"references": [
"ShrinkEventBus.Runtime",
"Unity.Collections",
"Unity.Entities"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"autoReferenced": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9e31f017584a4a04992bb6fa7538cb2f
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28ac62d48f4f4ba296c67b9b5985d39c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+76
View File
@@ -0,0 +1,76 @@
#nullable enable
using System;
using NUnit.Framework;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
namespace ShrinkEventBus.Entities.Tests
{
internal struct EcsPingEvent : IShrinkEvent
{
public int Value;
}
internal sealed class EcsPingSubscriber : IShrinkGeneratedSubscriber
{
public int Sum { get; private set; }
public IDisposable AttachGenerated(IShrinkBusResolver resolver, ShrinkBusKey? defaultBus = null)
{
return ShrinkGeneratedBinding.Subscribe<EcsPingEvent>(resolver, defaultBus,
string.Empty, this, OnPing, ShrinkEventPriority.Normal, 0, false);
}
private void OnPing(EcsPingEvent value) => Sum += value.Value;
}
[BurstCompile]
internal struct PostPingJob : IJob
{
public ShrinkEcsEventWriter<EcsPingEvent> Writer;
public void Execute()
{
Writer.Post(new EcsPingEvent { Value = 11 });
}
}
public sealed class ShrinkEcsEventQueueTests
{
[Test]
public void NativeWriterPlaybackUsesSameBusChannel()
{
using var host = new ShrinkEventBusHost();
var bus = host.CreateBus(ShrinkBusKey.World("tests"), ShrinkBusOptions.Inline());
var subscriber = new EcsPingSubscriber();
using var binding = host.Attach(subscriber, ShrinkBusKey.World("tests"));
using var queue = new ShrinkEcsEventQueue<EcsPingEvent>(Allocator.TempJob);
queue.Writer.Post(new EcsPingEvent { Value = 2 });
queue.Writer.Post(new EcsPingEvent { Value = 5 });
var played = queue.Playback(bus);
Assert.AreEqual(2, played);
Assert.AreEqual(7, subscriber.Sum);
}
[Test]
public void BurstJobWritesThenPlaybackUsesManagedBus()
{
using var host = new ShrinkEventBusHost();
var bus = host.CreateBus(ShrinkBusKey.World("burst-tests"), ShrinkBusOptions.Inline());
var subscriber = new EcsPingSubscriber();
using var binding = host.Attach(subscriber, ShrinkBusKey.World("burst-tests"));
using var queue = new ShrinkEcsEventQueue<EcsPingEvent>(Allocator.TempJob);
var job = new PostPingJob { Writer = queue.Writer };
job.Schedule().Complete();
var played = queue.Playback(bus);
Assert.AreEqual(1, played);
Assert.AreEqual(11, subscriber.Sum);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3be15e44ff9405e947ecaaac7905527
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
{
"name": "ShrinkEventBus.Entities.Tests",
"rootNamespace": "ShrinkEventBus.Entities.Tests",
"references": [
"ShrinkEventBus.Entities.Runtime",
"ShrinkEventBus.Runtime",
"Unity.Burst",
"Unity.Collections",
"Unity.Jobs",
"UniTask",
"UnityEngine.TestRunner",
"UnityEditor.TestRunner"
],
"includePlatforms": ["Editor"],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"autoReferenced": false,
"defineConstraints": ["UNITY_INCLUDE_TESTS"]
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9ef47a51870047fda3659747535d685a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+22
View File
@@ -0,0 +1,22 @@
{
"name": "com.cneicy.shrink-eventbus-entities",
"version": "0.1.0",
"displayName": "ShrinkEventBus Entities",
"description": "Burst-safe NativeQueue writer and playback adapter for ShrinkEventBus.",
"unity": "2022.3",
"dependencies": {
"com.cneicy.shrink-eventbus": "2.0.0",
"com.unity.entities": "1.0.11"
},
"keywords": [
"eventbus",
"entities",
"burst",
"ecs"
],
"author": {
"name": "cneicy",
"url": "https://git.crash.work/ShrinkSDK"
},
"documentationUrl": "https://git.crash.work/ShrinkSDK/ShrinkEventBus.Entities"
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 908d154d9ac34f55817ba92f073b3aa8
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: