Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4eebd0393 | ||
|
|
2ef9ad827b | ||
|
|
ece3f072dd | ||
|
|
afc58da579 | ||
|
|
6fa2ad2623 | ||
|
|
7de7bbbcdc | ||
|
|
182bacbb09 |
@@ -15,32 +15,39 @@ jobs:
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.SHRINKSDK_PACKAGE_TOKEN }}
|
||||
steps:
|
||||
- name: Install Git
|
||||
- name: Fetch exact tagged release archive
|
||||
env:
|
||||
GITEA_REF: ${{ gitea.ref }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git ca-certificates
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
fi
|
||||
tag="${GITEA_REF#refs/tags/}"
|
||||
case "$tag" in
|
||||
v[0-9]*) ;;
|
||||
*) echo "Expected a version tag ref, got: $GITEA_REF" >&2; exit 1 ;;
|
||||
esac
|
||||
export SHRINKSDK_ARCHIVE_URL="https://git.crash.work/ShrinkSDK/Installer/archive/${tag}.tar.gz"
|
||||
node --input-type=module <<'NODE'
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
|
||||
- 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/Installer.git"
|
||||
git fetch --depth=1 --tags origin "$ref"
|
||||
git checkout --detach FETCH_HEAD
|
||||
const response = await fetch(process.env.SHRINKSDK_ARCHIVE_URL);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Release archive download failed: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
await writeFile('release.tar.gz', new Uint8Array(await response.arrayBuffer()));
|
||||
NODE
|
||||
mkdir release
|
||||
tar -xzf release.tar.gz --strip-components=1 -C release
|
||||
rm -f release.tar.gz
|
||||
printf '%s' "$tag" > release/.shrink-sdk-release-tag
|
||||
|
||||
- name: Validate immutable release version
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
tag="$(git describe --exact-match --tags HEAD)"
|
||||
cd release
|
||||
tag="$(cat .shrink-sdk-release-tag)"
|
||||
version="$(node -p "require('./package.json').version")"
|
||||
test "$tag" = "v$version"
|
||||
npm pack --dry-run
|
||||
@@ -50,10 +57,11 @@ jobs:
|
||||
run: |
|
||||
set -eu
|
||||
: "${NODE_AUTH_TOKEN:?SHRINKSDK_PACKAGE_TOKEN is required}"
|
||||
cd release
|
||||
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/
|
||||
npm publish --registry=https://git.crash.work/api/packages/ShrinkSDK/npm/
|
||||
|
||||
@@ -26,12 +26,17 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
machine_id_file="/root/.local/share/unity3d/Unity/.machine-id"
|
||||
if test -s "$machine_id_file"; then
|
||||
cat "$machine_id_file" > /etc/machine-id
|
||||
echo "Unity machine identity restored"
|
||||
fi
|
||||
git config --global url."https://ghfast.top/https://github.com/".insteadOf "https://github.com/"
|
||||
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 \
|
||||
|
||||
@@ -11,5 +11,8 @@
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.cneicy.shrink-installer": "file:../../.."
|
||||
}
|
||||
},
|
||||
"testables": [
|
||||
"com.cneicy.shrink-installer"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,9 +12,7 @@ namespace ShrinkSDK.Installer
|
||||
{
|
||||
internal sealed class ShrinkSdkInstallerWindow : EditorWindow
|
||||
{
|
||||
private AddRequest? _addRequest;
|
||||
private ListRequest? _listRequest;
|
||||
private ShrinkSdkPackageEntry? _pendingInstall;
|
||||
private int _selectedPackageIndex;
|
||||
private string _status = "Ready";
|
||||
private MessageType _statusType = MessageType.Info;
|
||||
@@ -69,26 +67,10 @@ namespace ShrinkSDK.Installer
|
||||
EditorGUILayout.HelpBox(_status, _statusType);
|
||||
}
|
||||
|
||||
private bool IsBusy => _addRequest != null || _listRequest != null;
|
||||
private bool IsBusy => _listRequest != null;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_addRequest != null && _addRequest.IsCompleted)
|
||||
{
|
||||
var request = _addRequest;
|
||||
_addRequest = null;
|
||||
if (request.Status == StatusCode.Success)
|
||||
{
|
||||
SetStatus("Installed " + request.Result.name + " " + request.Result.version, MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatus("Package install failed: " + request.Error.message, MessageType.Error);
|
||||
}
|
||||
|
||||
_pendingInstall = null;
|
||||
}
|
||||
|
||||
if (_listRequest != null && _listRequest.IsCompleted)
|
||||
{
|
||||
var request = _listRequest;
|
||||
@@ -110,7 +92,6 @@ namespace ShrinkSDK.Installer
|
||||
try
|
||||
{
|
||||
ShrinkSdkManifestStore.EnsureShrinkSdkRegistry();
|
||||
_pendingInstall = null;
|
||||
Client.Resolve();
|
||||
SetStatus("Registry configuration written. Unity is resolving packages.", MessageType.Info);
|
||||
}
|
||||
@@ -124,11 +105,11 @@ namespace ShrinkSDK.Installer
|
||||
{
|
||||
try
|
||||
{
|
||||
ShrinkSdkManifestStore.EnsureShrinkSdkRegistry();
|
||||
ShrinkSdkManifestStore.EnsurePackageInstallation(entry);
|
||||
Client.Resolve();
|
||||
_pendingInstall = entry;
|
||||
_addRequest = Client.Add(entry.PackageSpecifier);
|
||||
SetStatus("Installing " + entry.PackageSpecifier, MessageType.Info);
|
||||
SetStatus(
|
||||
"Pinned " + entry.PackageName + " " + entry.Version + " in Packages/manifest.json. Unity is resolving packages.",
|
||||
MessageType.Info);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,28 @@ namespace ShrinkSDK.Installer
|
||||
internal static void EnsureShrinkSdkRegistry()
|
||||
{
|
||||
var manifest = ReadManifest();
|
||||
EnsureShrinkSdkRegistry(manifest);
|
||||
AtomicWrite(manifest.ToString(Formatting.Indented) + Environment.NewLine);
|
||||
}
|
||||
|
||||
internal static void EnsurePackageInstallation(ShrinkSdkPackageEntry package)
|
||||
{
|
||||
var manifest = ReadManifest();
|
||||
EnsureShrinkSdkRegistry(manifest);
|
||||
EnsurePinnedDependency(manifest, package.PackageName, package.Version);
|
||||
if (package.RequiresUniTask)
|
||||
{
|
||||
EnsurePinnedDependency(
|
||||
manifest,
|
||||
ShrinkSdkPackageCatalog.UniTaskPackageName,
|
||||
ShrinkSdkPackageCatalog.UniTaskGitUrl);
|
||||
}
|
||||
|
||||
AtomicWrite(manifest.ToString(Formatting.Indented) + Environment.NewLine);
|
||||
}
|
||||
|
||||
private static void EnsureShrinkSdkRegistry(JObject manifest)
|
||||
{
|
||||
var registries = manifest["scopedRegistries"] as JArray;
|
||||
if (registries == null)
|
||||
{
|
||||
@@ -71,8 +93,26 @@ namespace ShrinkSDK.Installer
|
||||
|
||||
registry["scopes"] = scopes;
|
||||
}
|
||||
}
|
||||
|
||||
AtomicWrite(manifest.ToString(Formatting.Indented) + Environment.NewLine);
|
||||
private static void EnsurePinnedDependency(JObject manifest, string packageName, string version)
|
||||
{
|
||||
var dependencies = manifest["dependencies"] as JObject;
|
||||
if (dependencies == null)
|
||||
{
|
||||
dependencies = new JObject();
|
||||
manifest["dependencies"] = dependencies;
|
||||
}
|
||||
|
||||
var existing = dependencies[packageName];
|
||||
if (existing != null && !string.Equals(existing.Value<string>(), version, StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Packages/manifest.json already pins " + packageName + " to " + existing.Value<string>() +
|
||||
". ShrinkSDK requires the fixed version " + version + ".");
|
||||
}
|
||||
|
||||
dependencies[packageName] = version;
|
||||
}
|
||||
|
||||
private static JObject ReadManifest()
|
||||
|
||||
@@ -7,17 +7,18 @@ namespace ShrinkSDK.Installer
|
||||
{
|
||||
internal sealed class ShrinkSdkPackageEntry
|
||||
{
|
||||
public ShrinkSdkPackageEntry(string displayName, string packageName, string version)
|
||||
public ShrinkSdkPackageEntry(string displayName, string packageName, string version, bool requiresUniTask = false)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
PackageName = packageName;
|
||||
Version = version;
|
||||
RequiresUniTask = requiresUniTask;
|
||||
}
|
||||
|
||||
public string DisplayName { get; }
|
||||
public string PackageName { get; }
|
||||
public string Version { get; }
|
||||
public string PackageSpecifier => PackageName + "@" + Version;
|
||||
public bool RequiresUniTask { get; }
|
||||
}
|
||||
|
||||
internal static class ShrinkSdkPackageCatalog
|
||||
@@ -25,34 +26,37 @@ namespace ShrinkSDK.Installer
|
||||
internal const string RegistryName = "ShrinkSDK";
|
||||
internal const string RegistryUrl = "https://git.crash.work/api/packages/ShrinkSDK/npm/";
|
||||
internal const string RegistryScope = "com.cneicy";
|
||||
internal const string UniTaskPackageName = "com.cysharp.unitask";
|
||||
internal const string UniTaskGitUrl = "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask#7c0f199fe0d3fc528024488ccd671e6c7b27745b";
|
||||
|
||||
internal static readonly ShrinkSdkPackageEntry StarterBasic = new(
|
||||
"ShrinkApp Starter Basic",
|
||||
"com.cneicy.shrink-app-starter-basic",
|
||||
"0.1.0");
|
||||
"0.1.2",
|
||||
requiresUniTask: true);
|
||||
|
||||
internal static readonly IReadOnlyList<ShrinkSdkPackageEntry> Packages = new[]
|
||||
{
|
||||
new ShrinkSdkPackageEntry("ShrinkApp Core", "com.cneicy.shrink-app-core", "0.1.1"),
|
||||
new ShrinkSdkPackageEntry("ShrinkApp Core", "com.cneicy.shrink-app-core", "0.1.1", requiresUniTask: true),
|
||||
StarterBasic,
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand", "com.cneicy.shrink-command", "0.2.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand Integration App", "com.cneicy.shrink-command-integration-app", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand Integration EventBus", "com.cneicy.shrink-command-integration-eventbus", "0.1.1"),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand Integration Network", "com.cneicy.shrink-command-integration-network", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkContext App Adapter", "com.cneicy.shrink-context-app-adapter", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkContext Core", "com.cneicy.shrink-context-core", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkContext EventBus Adapter", "com.cneicy.shrink-context-eventbus-adapter", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkDataSaver", "com.cneicy.shrink-datasaver", "2.2.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkDataSaver Integration App", "com.cneicy.shrink-datasaver-integration-app", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkDataSaver Integration EventBus", "com.cneicy.shrink-datasaver-integration-eventbus", "2.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkEventBus", "com.cneicy.shrink-eventbus", "2.0.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkEventBus Entities", "com.cneicy.shrink-eventbus-entities", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkModFramework", "com.cneicy.shrink-mod-framework", "0.2.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkNetwork", "com.cneicy.shrink-network", "0.2.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkNetwork Integration App", "com.cneicy.shrink-network-integration-app", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkNetwork Integration EventBus", "com.cneicy.shrink-network-integration-eventbus", "0.1.1"),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand", "com.cneicy.shrink-command", "0.2.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand Integration App", "com.cneicy.shrink-command-integration-app", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand Integration EventBus", "com.cneicy.shrink-command-integration-eventbus", "0.1.1", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkCommand Integration Network", "com.cneicy.shrink-command-integration-network", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkContext App Adapter", "com.cneicy.shrink-context-app-adapter", "0.1.2", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkContext Core", "com.cneicy.shrink-context-core", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkContext EventBus Adapter", "com.cneicy.shrink-context-eventbus-adapter", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkDataSaver", "com.cneicy.shrink-datasaver", "2.2.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkDataSaver Integration App", "com.cneicy.shrink-datasaver-integration-app", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkDataSaver Integration EventBus", "com.cneicy.shrink-datasaver-integration-eventbus", "2.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkEventBus", "com.cneicy.shrink-eventbus", "2.0.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkEventBus Entities", "com.cneicy.shrink-eventbus-entities", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkModFramework", "com.cneicy.shrink-mod-framework", "0.2.1", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkNetwork", "com.cneicy.shrink-network", "0.2.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkNetwork Integration App", "com.cneicy.shrink-network-integration-app", "0.1.0", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkNetwork Integration EventBus", "com.cneicy.shrink-network-integration-eventbus", "0.1.1", requiresUniTask: true),
|
||||
new ShrinkSdkPackageEntry("ShrinkShared CodeGen", "com.cneicy.shrink-shared-codegen", "0.1.0"),
|
||||
new ShrinkSdkPackageEntry("ShrinkTutorial", "com.cneicy.shrink-tutorial", "0.1.0")
|
||||
new ShrinkSdkPackageEntry("ShrinkTutorial", "com.cneicy.shrink-tutorial", "0.1.1")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
`com.cneicy.shrink-installer` is the Git URL bootstrap package for ShrinkSDK.
|
||||
|
||||
Install the package from an immutable tag, then open `ShrinkSDK/Packages` in the Unity editor. The window merges the public ShrinkSDK scoped registry without replacing other registries and installs only catalogued package versions.
|
||||
Install the package from an immutable tag, then open `ShrinkSDK/Packages` in the Unity editor. The window merges the public ShrinkSDK scoped registry without replacing other registries and writes only catalogue-pinned dependencies to `Packages/manifest.json`. Packages which require UniTask also receive its fixed Git revision.
|
||||
|
||||
The installer does not copy templates into `Assets`, does not store credentials, and does not add an unpinned package version.
|
||||
|
||||
## Bootstrap URL
|
||||
|
||||
```text
|
||||
https://git.crash.work/ShrinkSDK/Installer.git#v0.1.1
|
||||
https://git.crash.work/ShrinkSDK/Installer.git#v0.1.5
|
||||
```
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.cneicy.shrink-installer",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.5",
|
||||
"displayName": "ShrinkSDK Installer",
|
||||
"description": "ShrinkSDK registry bootstrapper and fixed-version package installer.",
|
||||
"unity": "2022.3",
|
||||
|
||||
Reference in New Issue
Block a user