flake: emit Unity bundle zip; add Gitea Actions CI/release; publish VPM index
ci / build (push) Canceled after 0s
ci / build (push) Canceled after 0s
- flake.nix: install the libaac cdylib alongside aac-dump and zip it with the C# Unity packages as the default package - .gitea/workflows: build+package on push/PR, publish release on v* tags - vpm: commit the repository index and packaging script, with VPM_INDEX and VPM_INDEX_URL overrides for generating a local listing
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@v27
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
|
||||||
|
# Builds the cdylib and runs the cargo tests (doCheck).
|
||||||
|
- name: Build Rust core
|
||||||
|
run: nix build .#aac --print-build-logs
|
||||||
|
|
||||||
|
# Rehearses the VPM release: stages the C# package, bundles libaac, updates vpm/index.json.
|
||||||
|
- name: Package VPM zip
|
||||||
|
run: nix develop -c ./vpm/package.sh
|
||||||
|
|
||||||
|
# The Unity bundle produced by the flake itself.
|
||||||
|
- name: Build Unity bundle
|
||||||
|
run: nix build .#default --print-build-logs
|
||||||
|
|
||||||
|
- name: Collect artifacts
|
||||||
|
run: |
|
||||||
|
mkdir -p dist
|
||||||
|
cp -L result dist/animator-as-crab-bundle.zip
|
||||||
|
cp vpm/dist/*.zip dist/
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: animator-as-crab
|
||||||
|
path: dist/*.zip
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ['v*']
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@v27
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
|
||||||
|
# package.sh globs $root/result/lib/*, so the aac package must be linked as ./result.
|
||||||
|
- name: Build native library
|
||||||
|
run: nix build .#aac --print-build-logs
|
||||||
|
|
||||||
|
- name: Package VPM zip
|
||||||
|
run: nix develop -c ./vpm/package.sh
|
||||||
|
|
||||||
|
- name: Publish release and upload zip
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.VPM_TOKEN || secrets.GITHUB_TOKEN }}
|
||||||
|
SERVER: ${{ github.server_url }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
manifest=csharp/dev.doloro.animator-as-crab/package.json
|
||||||
|
id=$(jq -r .name "$manifest")
|
||||||
|
version=$(jq -r .version "$manifest")
|
||||||
|
zip="vpm/dist/$id-$version.zip"
|
||||||
|
|
||||||
|
release=$(curl -fsS -X POST \
|
||||||
|
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||||
|
"$SERVER/api/v1/repos/$REPO/releases" \
|
||||||
|
-d "$(jq -n --arg tag "$TAG" --arg name "$id $version" \
|
||||||
|
'{tag_name: $tag, name: $name, draft: false}')")
|
||||||
|
|
||||||
|
curl -fsS -X POST \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
"$SERVER/api/v1/repos/$REPO/releases/$(jq -r .id <<<"$release")/assets?name=$(basename "$zip")" \
|
||||||
|
-F "attachment=@$zip"
|
||||||
|
|
||||||
|
# The index ships the zip's sha256, which only exists after packaging, so it is committed here.
|
||||||
|
- name: Commit updated VPM index
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.VPM_TOKEN || secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
git config user.name gitea-actions
|
||||||
|
git config user.email actions@git.scug.io
|
||||||
|
git add vpm/index.json
|
||||||
|
git diff --cached --quiet && exit 0
|
||||||
|
version=$(jq -r .version csharp/dev.doloro.animator-as-crab/package.json)
|
||||||
|
git commit -m "vpm: index for $version"
|
||||||
|
git push "https://x-access-token:$TOKEN@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" \
|
||||||
|
HEAD:main
|
||||||
@@ -1 +1,3 @@
|
|||||||
/result
|
/result
|
||||||
|
vpm/dist/
|
||||||
|
vpm/index.local.json
|
||||||
|
|||||||
@@ -43,26 +43,58 @@
|
|||||||
};
|
};
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
||||||
|
|
||||||
|
# Name Unity expects on the current platform; AacCrabNative.cs imports "libaac".
|
||||||
|
nativeLib =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"libaac.dylib"
|
||||||
|
else if pkgs.stdenv.hostPlatform.isWindows then
|
||||||
|
"aac.dll"
|
||||||
|
else
|
||||||
|
"libaac.so";
|
||||||
|
|
||||||
# The Rust core: evaluates the Rhai DSL and emits the graph as JSON for Unity.
|
# The Rust core: evaluates the Rhai DSL and emits the graph as JSON for Unity.
|
||||||
aac = craneLib.buildPackage {
|
aac = craneLib.buildPackage {
|
||||||
src = ./rust;
|
src = ./rust;
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
# crane's default install only copies binaries; install the cdylib explicitly.
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
mkdir -p $out/lib $out/bin
|
||||||
|
cp target/release/${nativeLib} $out/lib/
|
||||||
|
cp target/release/aac-dump $out/bin/
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Unity-importable bundle: native library plus the C# packages, as a single zip.
|
||||||
|
bundle =
|
||||||
|
pkgs.runCommand "animator-as-crab-${system}.zip"
|
||||||
|
{
|
||||||
|
nativeBuildInputs = [ pkgs.zip ];
|
||||||
|
meta.description = "Unity plugin bundle for animator-as-crab";
|
||||||
|
}
|
||||||
|
''
|
||||||
|
mkdir -p root/Plugins root/bin
|
||||||
|
cp ${aac}/lib/${nativeLib} root/Plugins/
|
||||||
|
cp ${aac}/bin/aac-dump root/bin/
|
||||||
|
cp -r ${./csharp}/dev.doloro.animator-as-crab root/
|
||||||
|
cp -r ${./csharp}/dev.hai-vr.animator-as-code.v1.base.test root/
|
||||||
|
(cd root && zip -q -r $out .)
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
inherit aac;
|
inherit aac bundle;
|
||||||
default = aac;
|
default = bundle;
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = craneLib.devShell {
|
devShells.default = craneLib.devShell {
|
||||||
inputsFrom = [ aac ];
|
inputsFrom = [ aac ];
|
||||||
packages = [
|
packages = [
|
||||||
rustToolchain
|
rustToolchain
|
||||||
pkgs.dotnet-sdk
|
|
||||||
pkgs.mono
|
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
|
pkgs.zip
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "Doloro VPM Packages",
|
||||||
|
"id": "dev.doloro.vpm",
|
||||||
|
"url": "https://git.scug.io/doloro/av3-animation-as-crab/-/raw/main/vpm/index.json",
|
||||||
|
"author": {
|
||||||
|
"name": "doloro"
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"dev.doloro.animator-as-crab": {
|
||||||
|
"versions": {
|
||||||
|
"0.1.0": {
|
||||||
|
"name": "dev.doloro.animator-as-crab",
|
||||||
|
"displayName": "Animator As Crab",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"unity": "2019.4",
|
||||||
|
"description": "Writes Animator Controllers from a Rhai script, evaluated by the libaac native library.",
|
||||||
|
"url": "https://git.scug.io/doloro/av3-animation-as-crab/-/releases/download/v0.1.0/dev.doloro.animator-as-crab-0.1.0.zip",
|
||||||
|
"zipSHA256": "e0ad8c5717059115567e5c7907425d4a6a1ce1613023197061796d0b5128a515",
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.nuget.newtonsoft-json": "3.2.1"
|
||||||
|
},
|
||||||
|
"vpmDependencies": {},
|
||||||
|
"author": {
|
||||||
|
"name": "doloro"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+81
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Builds the VPM release zip for dev.doloro.animator-as-crab and (re)generates vpm/index.json,
|
||||||
|
# the repository listing that VCC and ALCOM read.
|
||||||
|
#
|
||||||
|
# Needs `zip` and `jq`: run it inside `nix develop`.
|
||||||
|
#
|
||||||
|
# Environment overrides (all optional):
|
||||||
|
# VPM_HOST default https://git.scug.io
|
||||||
|
# VPM_PROJECT default doloro/av3-animation-as-crab
|
||||||
|
# VPM_RELEASE_BASE default <host>/<project>/-/releases/download/v<version>
|
||||||
|
# VPM_INDEX default <root>/vpm/index.json
|
||||||
|
# VPM_INDEX_URL default <host>/<project>/-/raw/main/vpm/index.json
|
||||||
|
# VPM_REPO_NAME default "Doloro VPM Packages"
|
||||||
|
# VPM_REPO_ID default dev.doloro.vpm
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||||
|
pkg="$root/csharp/dev.doloro.animator-as-crab"
|
||||||
|
vpm="$root/vpm"
|
||||||
|
|
||||||
|
host=${VPM_HOST:-https://git.scug.io}
|
||||||
|
project=${VPM_PROJECT:-doloro/av3-animation-as-crab}
|
||||||
|
repo_name=${VPM_REPO_NAME:-Doloro VPM Packages}
|
||||||
|
repo_id=${VPM_REPO_ID:-dev.doloro.vpm}
|
||||||
|
index_url=${VPM_INDEX_URL:-$host/$project/-/raw/main/vpm/index.json}
|
||||||
|
release_base=${VPM_RELEASE_BASE:-}
|
||||||
|
|
||||||
|
id=$(jq -r .name "$pkg/package.json")
|
||||||
|
version=$(jq -r .version "$pkg/package.json")
|
||||||
|
zip_name="$id-$version.zip"
|
||||||
|
: "${release_base:=$host/$project/-/releases/download/v$version}"
|
||||||
|
zip_url="$release_base/$zip_name"
|
||||||
|
|
||||||
|
stage=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$stage"' EXIT
|
||||||
|
cp -r "$pkg/." "$stage/"
|
||||||
|
rm -f "$stage/.gitignore"
|
||||||
|
|
||||||
|
# The native library is not optional: DllImport("libaac") fails without it, and a VPM package is
|
||||||
|
# unpacked into Packages/, so it cannot rely on the user's Assets/Plugins. Ship it in the package.
|
||||||
|
# Only Linux is built here; drop a libaac.dll / libaac.dylib into vpm/native/ for other hosts.
|
||||||
|
shopt -s nullglob
|
||||||
|
native=("$vpm"/native/* "$root"/result/lib/*)
|
||||||
|
shopt -u nullglob
|
||||||
|
if [ ${#native[@]} -eq 0 ]; then
|
||||||
|
echo "warning: no native library found; the package will not load libaac" >&2
|
||||||
|
fi
|
||||||
|
for lib in "${native[@]}"; do
|
||||||
|
cp "$lib" "$stage/V1/Editor/"
|
||||||
|
echo "bundled $(basename "$lib")"
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p "$vpm/dist"
|
||||||
|
rm -f "$vpm/dist/$zip_name"
|
||||||
|
(cd "$stage" && zip -r -X -q "$vpm/dist/$zip_name" .)
|
||||||
|
sha=$(sha256sum "$vpm/dist/$zip_name" | cut -d' ' -f1)
|
||||||
|
|
||||||
|
entry=$(jq -n \
|
||||||
|
--arg id "$id" --arg version "$version" --arg zip_url "$zip_url" --arg sha "$sha" \
|
||||||
|
--slurpfile manifest "$pkg/package.json" \
|
||||||
|
'{name: $id, displayName: $manifest[0].displayName, version: $version, unity: $manifest[0].unity,
|
||||||
|
description: $manifest[0].description, url: $zip_url, zipSHA256: $sha,
|
||||||
|
dependencies: ($manifest[0].dependencies // {}), vpmDependencies: {}, author: $manifest[0].author}')
|
||||||
|
|
||||||
|
index=${VPM_INDEX:-$vpm/index.json}
|
||||||
|
|
||||||
|
old='{}'
|
||||||
|
[ -f "$index" ] && old=$(cat "$index")
|
||||||
|
echo "$old" | jq \
|
||||||
|
--arg repo_name "$repo_name" --arg repo_id "$repo_id" --arg index_url "$index_url" \
|
||||||
|
--arg id "$id" --arg version "$version" --argjson entry "$entry" \
|
||||||
|
'.name = $repo_name | .id = $repo_id | .url = $index_url | .author = $entry.author
|
||||||
|
| .packages = (.packages // {})
|
||||||
|
| .packages[$id] = (.packages[$id] // {versions: {}})
|
||||||
|
| .packages[$id].versions[$version] = $entry' > "$index"
|
||||||
|
|
||||||
|
jq -e . "$index" > /dev/null
|
||||||
|
|
||||||
|
echo "wrote $vpm/dist/$zip_name"
|
||||||
|
echo "sha256 $sha"
|
||||||
|
echo "updated $index -> $zip_url"
|
||||||
Reference in New Issue
Block a user