From 385c50a1d7998e4bff8bd9684b25ff6937699edb Mon Sep 17 00:00:00 2001
From: marked <iczerwony98@gmail.com>
Date: Wed, 12 Mar 2025 21:01:38 +0100
Subject: [PATCH] Fully automate CI/CD, evil multitargetting

---
 .forgejo/workflows/release.yml                |  25 ----
 .../{sync.yml => syncandrelease.yml}          |  34 +++++
 .lune/pull.luau                               | 121 +++++-------------
 .lune/read_version.luau                       |  73 +----------
 .lune/types.luau                              |  88 +++++++++++++
 pesde.lock                                    |   3 -
 rokit.toml                                    |   3 +-
 7 files changed, 159 insertions(+), 188 deletions(-)
 delete mode 100644 .forgejo/workflows/release.yml
 rename .forgejo/workflows/{sync.yml => syncandrelease.yml} (54%)
 create mode 100644 .lune/types.luau
 delete mode 100644 pesde.lock

diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml
deleted file mode 100644
index 11376a3..0000000
--- a/.forgejo/workflows/release.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-name: Release
-
-on:
-  workflow_dispatch:
-
-jobs:
-  release:
-    name: Release
-    runs-on: docker
-    container:
-      image: ghcr.io/catthehacker/ubuntu:act-22.04
-    steps:
-      - name: Checkout Repository
-        uses: actions/checkout@v4
-
-      - name: Install Rokit
-        uses: https://github.com/CompeyDev/setup-rokit@v0.1.2
-        with:
-          token: ${{ secrets.githubtoken }}
-
-      - name: Authorize
-        run: pesde auth login --token "${{ secrets.pesde_auth_token }}"
-
-      - name: Publish
-        run: pesde publish -y
diff --git a/.forgejo/workflows/sync.yml b/.forgejo/workflows/syncandrelease.yml
similarity index 54%
rename from .forgejo/workflows/sync.yml
rename to .forgejo/workflows/syncandrelease.yml
index e5a95d1..5915aad 100644
--- a/.forgejo/workflows/sync.yml
+++ b/.forgejo/workflows/syncandrelease.yml
@@ -20,9 +20,35 @@ jobs:
         with:
           token: ${{ secrets.githubtoken }}
 
+      - name: Install forgejo-cli
+        run: |
+          wget https://codeberg.org/Cyborus/forgejo-cli/releases/download/v0.2.0/forgejo-cli-linux.gz -O fj.gz
+          gunzip fj.gz
+          mv fj /usr/local/bin/fj
+          chmod +x /usr/local/bin/fj
+
       - name: Pull Newest Jecs
         run: lune run pull.luau ${{ secrets.githubtoken }}
 
+      - name: Authorize
+        run: pesde auth login --token "${{ secrets.pesde_auth_token }}"
+
+      - name: Publish Luau Target
+        run: pesde publish -y
+
+      - name: Manifest Switcharoo
+        run: |
+          mv pesde.toml pesde-luau.toml
+          mv pesde-rbx.toml pesde.toml
+
+      - name: Publish Roblox Target
+        run: pesde publish -y
+
+      - name: Manifest Switcharoo
+        run: |
+          mv pesde.toml pesde-rbx.toml
+          mv pesde-luau.toml pesde.toml
+
       - name: Read Jecs Version
         id: read_jecs_version
         run: |
@@ -40,3 +66,11 @@ jobs:
           commit-message: Sync to upstream Jecs ${{ steps.read_jecs_version.outputs.JECS_VERSION }}
           base: main
           token: ${{ secrets.privileged_forgejo_token }}
+
+      - name: Merge Pull Request
+        shell: bash
+        run: |
+          if [ ! -z "${{ steps.create_pull_request.outputs.pull-request-number }}" ]; then
+            fj --host git.devmarked.win auth add-key marked ${{ secrets.privileged_forgejo_token }}
+            fj --host git.devmarked.win pr merge --method squash "${{ steps.create_pull_request.outputs.pull-request-number }}"
+          fi
diff --git a/.lune/pull.luau b/.lune/pull.luau
index 15cb1ce..08b9b55 100644
--- a/.lune/pull.luau
+++ b/.lune/pull.luau
@@ -4,94 +4,10 @@ local net = require("@lune/net")
 local process = require("@lune/process")
 local serde = require("@lune/serde")
 
+local types = require("./types")
+
 print("-- 🟧 Starting pull of latest release...")
 
-type wally_manifest = {
-    package: {
-        name: string,
-        version: string,
-        registry: string,
-        realm: string,
-        license: string?,
-        exclude: { string }?,
-        include: { string }?,
-    },
-    dependencies: {
-        [string]: string,
-    },
-}
-
-type environment = "luau" | "lune" | "roblox" | "roblox_server"
-type pesde_dependency = {
-    name: string,
-    version: string,
-    index: string?,
-    target: environment?,
-} | {
-    wally: string,
-    version: string,
-    index: string?,
-} | {
-    repo: string,
-    rev: string,
-    path: string?,
-}
-
-type pesde_manifest = {
-    name: string,
-    version: string,
-    description: string?,
-    license: string?,
-    authors: { string }?,
-    repository: string?,
-    private: boolean?,
-    includes: { string }?,
-    pesde_version: string?,
-    workspace_members: { string }?,
-
-    target: {
-        environment: environment,
-        lib: string,
-        bin: string?,
-        build_files: { string }?,
-    },
-
-    scripts: {
-        roblox_sync_config_generator: string?,
-        sourcemap_generator: string?,
-
-        [string]: string,
-    }?,
-
-    indices: {
-        default: string,
-
-        [string]: string,
-    },
-    wally_indices: {
-        default: string,
-
-        [string]: string,
-    }?,
-
-    overrides: {
-        [string]: pesde_dependency,
-    }?,
-    patches: {
-        [string]: { [string]: string },
-    }?,
-
-    dependencies: {
-        [string]: pesde_dependency,
-    }?,
-    peer_dependencies: {
-        [string]: pesde_dependency,
-    }?,
-    dev_dependencies: {
-        [string]: pesde_dependency,
-    }?,
-}
-
 print("🟧 Fetching github token...")
 local github_token: string = process.args[1]
 
@@ -114,7 +30,7 @@ if not pull_manifest_res.ok then
     error(`❌ Couldn't download jecs manifest: {pull_manifest_res.statusCode} {pull_manifest_res.statusMessage}`)
 end
 local manifest_contents = pull_manifest_res.body
-local manifest: wally_manifest = serde.decode("toml", manifest_contents) or error("Couldn't decode manifest.")
+local manifest: types.wally_manifest = serde.decode("toml", manifest_contents) or error("Couldn't decode manifest.")
 local jecs_version = manifest.package.version
 print(`✅ Got latest manifest. Version: {jecs_version}`)
 
@@ -189,7 +105,7 @@ Install with pesde @ `marked/jecs`
 fs.writeFile("README.md", new_readme_contents)
 print(`✅ Modified README.md.`)
 
-local pesde_manifest: pesde_manifest = {
+local pesde_manifest: types.pesde_manifest = {
     name = "marked/jecs",
     description = "A minimal copy of jecs published on the official pesde registry",
     version = jecs_version,
@@ -215,9 +131,38 @@ local pesde_manifest: pesde_manifest = {
     },
 }
 
+local pesde_roblox_manifest: types.pesde_manifest = {
+    name = "marked/jecs",
+    description = "A minimal copy of jecs published on the official pesde registry",
+    version = jecs_version,
+    authors = { "jecs authors" },
+    repository = "https://git.devmarked.win/marked/jecs-pesde",
+    license = manifest.package.license,
+    includes = {
+        "init.luau",
+        "pesde.toml",
+        "README.md",
+        "CHANGELOG.md",
+        "LICENSE",
+        ".luaurc",
+    },
+
+    target = {
+        environment = "roblox",
+        lib = "init.luau",
+        build_files = { "init.luau" },
+    },
+
+    indices = {
+        default = "https://github.com/pesde-pkg/index",
+    },
+}
+
 print("🟧 Writing pesde manifest...")
 local serialized_manifest = serde.encode("toml", pesde_manifest, true)
 fs.writeFile("pesde.toml", serialized_manifest)
+local serialized_rbx_manifest = serde.encode("toml", pesde_roblox_manifest, true)
+fs.writeFile("pesde-rbx.toml", serialized_rbx_manifest)
 print("✅ Wrote pesde manifest.")
 
 print("-- ✅ Finished pulling latest release.")
diff --git a/.lune/read_version.luau b/.lune/read_version.luau
index ee4ef9a..a89345d 100644
--- a/.lune/read_version.luau
+++ b/.lune/read_version.luau
@@ -2,79 +2,10 @@
 local fs = require("@lune/fs")
 local serde = require("@lune/serde")
 
-type environment = "luau" | "lune" | "roblox" | "roblox_server"
-type pesde_dependency = {
-	name: string,
-	version: string,
-	index: string?,
-	target: environment?,
-} | {
-	wally: string,
-	version: string,
-	index: string?,
-} | {
-	repo: string,
-	rev: string,
-	path: string?,
-}
-
-type pesde_manifest = {
-	name: string,
-	version: string,
-	description: string?,
-	license: string?,
-	authors: { string }?,
-	repository: string?,
-	private: boolean?,
-	includes: { string }?,
-	pesde_version: string?,
-	workspace_members: { string }?,
-
-	target: {
-		environment: environment,
-		lib: string,
-		bin: string?,
-		build_files: { string }?,
-	},
-
-	scripts: {
-		roblox_sync_config_generator: string?,
-		sourcemap_generator: string?,
-
-		[string]: string,
-	}?,
-
-	indices: {
-		default: string,
-
-		[string]: string,
-	},
-	wally_indices: {
-		default: string,
-
-		[string]: string,
-	}?,
-
-	overrides: {
-		[string]: pesde_dependency,
-	}?,
-	patches: {
-		[string]: { [string]: string },
-	}?,
-
-	dependencies: {
-		[string]: pesde_dependency,
-	}?,
-	peer_dependencies: {
-		[string]: pesde_dependency,
-	}?,
-	dev_dependencies: {
-		[string]: pesde_dependency,
-	}?,
-}
+local types = require("./types")
 
 local manifest_contents = fs.readFile("pesde.toml")
-local manifest: pesde_manifest = serde.decode("toml", manifest_contents) or error("Couldn't decode manifest.")
+local manifest: types.pesde_manifest = serde.decode("toml", manifest_contents) or error("Couldn't decode manifest.")
 local jecs_version = manifest.version
 
 print(jecs_version)
diff --git a/.lune/types.luau b/.lune/types.luau
new file mode 100644
index 0000000..379d3f9
--- /dev/null
+++ b/.lune/types.luau
@@ -0,0 +1,88 @@
+--!strict
+export type wally_manifest = {
+    package: {
+        name: string,
+        version: string,
+        registry: string,
+        realm: string,
+        license: string?,
+        exclude: { string }?,
+        include: { string }?,
+    },
+    dependencies: {
+        [string]: string,
+    },
+}
+
+export type environment = "luau" | "lune" | "roblox" | "roblox_server"
+export type pesde_dependency = {
+    name: string,
+    version: string,
+    index: string?,
+    target: environment?,
+} | {
+    wally: string,
+    version: string,
+    index: string?,
+} | {
+    repo: string,
+    rev: string,
+    path: string?,
+}
+
+export type pesde_manifest = {
+    name: string,
+    version: string,
+    description: string?,
+    license: string?,
+    authors: { string }?,
+    repository: string?,
+    private: boolean?,
+    includes: { string }?,
+    pesde_version: string?,
+    workspace_members: { string }?,
+
+    target: {
+        environment: environment,
+        lib: string,
+        bin: string?,
+        build_files: { string }?,
+    },
+
+    scripts: {
+        roblox_sync_config_generator: string?,
+        sourcemap_generator: string?,
+
+        [string]: string,
+    }?,
+
+    indices: {
+        default: string,
+
+        [string]: string,
+    },
+    wally_indices: {
+        default: string,
+
+        [string]: string,
+    }?,
+
+    overrides: {
+        [string]: pesde_dependency,
+    }?,
+    patches: {
+        [string]: { [string]: string },
+    }?,
+
+    dependencies: {
+        [string]: pesde_dependency,
+    }?,
+    peer_dependencies: {
+        [string]: pesde_dependency,
+    }?,
+    dev_dependencies: {
+        [string]: pesde_dependency,
+    }?,
+}
+
+return {}
diff --git a/pesde.lock b/pesde.lock
deleted file mode 100644
index f84e716..0000000
--- a/pesde.lock
+++ /dev/null
@@ -1,3 +0,0 @@
-name = "marked/jecs"
-version = "0.5.3"
-target = "luau"
diff --git a/rokit.toml b/rokit.toml
index 91e0ac9..f864c9f 100644
--- a/rokit.toml
+++ b/rokit.toml
@@ -5,4 +5,5 @@
 
 [tools]
 lune = "lune-org/lune@0.8.9"
-pesde = "daimond113/pesde@0.6.0+registry.0.2.0"
+pesde = "daimond113/pesde@0.6.1+registry.0.2.2"
+luau-lsp = "johnnymorganz/luau-lsp@1.37.0"      # https://discord.com/channels/385151591524597761/1259775232533856327/1326154624335347732