Work towards a single-binary silverbullet
This commit is contained in:
parent
cb7f00f296
commit
fcda68dbfe
39
.github/workflows/server.yml
vendored
Normal file
39
.github/workflows/server.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: Server
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Deno
|
||||||
|
uses: denoland/setup-deno@v1
|
||||||
|
with:
|
||||||
|
deno-version: v1.34
|
||||||
|
|
||||||
|
- name: Build bundles
|
||||||
|
run: |
|
||||||
|
deno task build
|
||||||
|
|
||||||
|
- name: Compile for all platforms
|
||||||
|
run: |
|
||||||
|
deno task server:dist:linux-x86_64
|
||||||
|
deno task server:dist:darwin-x86_64
|
||||||
|
deno task server:dist:darwin-aarch64
|
||||||
|
deno task server:dist:windows-x86_64
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
files: |
|
||||||
|
silverbullet-*.zip
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ env.sh
|
|||||||
node_modules
|
node_modules
|
||||||
*.db
|
*.db
|
||||||
test_space
|
test_space
|
||||||
|
silverbullet
|
@ -35,3 +35,78 @@ export async function upgradeCommand() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WIP: This is not yet working, but it's a start
|
||||||
|
import { dirname } from "https://deno.land/std@0.186.0/path/mod.ts";
|
||||||
|
|
||||||
|
const silverBulletReleases =
|
||||||
|
"https://github.com/silverbulletmd/silverbullet/releases";
|
||||||
|
|
||||||
|
export async function compiledUpgradeCommand() {
|
||||||
|
console.log("Now going to attempt an upgrade...");
|
||||||
|
|
||||||
|
const resp = await fetch(`${silverBulletReleases}/latest`, {
|
||||||
|
redirect: "manual",
|
||||||
|
});
|
||||||
|
const versionedUrl = resp.headers.get("location")!;
|
||||||
|
const latestVersion = /([^\/]+)$/.exec(versionedUrl);
|
||||||
|
if (!latestVersion) {
|
||||||
|
console.error("Could not fetch latest version");
|
||||||
|
}
|
||||||
|
if (version === latestVersion![0]) {
|
||||||
|
console.log("No version available, we're done here!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
"New version available:",
|
||||||
|
latestVersion![0],
|
||||||
|
"which I will now personally download. Hang on...",
|
||||||
|
);
|
||||||
|
const installDir = dirname(new URL(Deno.mainModule).pathname);
|
||||||
|
|
||||||
|
const tmpDir = Deno.makeTempDirSync();
|
||||||
|
// const zipUrl = "https://github.com/silverbulletmd/silverbullet/releases/download/test-release/silverbullet-server-apple-aarch64.zip";
|
||||||
|
const zipUrl =
|
||||||
|
`${versionedUrl}/download/silverbullet-server-${Deno.build.os}-${Deno.build.arch}.zip`;
|
||||||
|
const zipPath = `${tmpDir}/silverbullet.zip`;
|
||||||
|
const command = new Deno.Command("curl", {
|
||||||
|
args: [
|
||||||
|
"-L",
|
||||||
|
"-o",
|
||||||
|
zipPath,
|
||||||
|
zipUrl,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const curlOutput = await command.output();
|
||||||
|
console.log(
|
||||||
|
"Now going to replace the existing silverbullet binary in",
|
||||||
|
installDir,
|
||||||
|
);
|
||||||
|
if (curlOutput.code !== 0) {
|
||||||
|
console.error(
|
||||||
|
"Download failed",
|
||||||
|
new TextDecoder().decode(curlOutput.stderr),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const unzipCommand = new Deno.Command("unzip", {
|
||||||
|
args: [
|
||||||
|
"-o",
|
||||||
|
"-d",
|
||||||
|
installDir,
|
||||||
|
`${tmpDir}/silverbullet.zip`,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const zipOutput = await unzipCommand.output();
|
||||||
|
if (zipOutput.code !== 0) {
|
||||||
|
console.error(
|
||||||
|
"Download failed",
|
||||||
|
new TextDecoder().decode(curlOutput.stderr),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await Deno.chmod(`${installDir}/silverbullet`, 0o755);
|
||||||
|
await Deno.remove(zipPath);
|
||||||
|
console.log("And done! Restart your server to get the latest and greatest!");
|
||||||
|
}
|
||||||
|
@ -14,7 +14,14 @@
|
|||||||
"bundle": "deno run -A build_bundle.ts",
|
"bundle": "deno run -A build_bundle.ts",
|
||||||
// Regenerates some bundle files (checked into the repo)
|
// Regenerates some bundle files (checked into the repo)
|
||||||
// Install lezer-generator with "npm install -g @lezer/generator"
|
// Install lezer-generator with "npm install -g @lezer/generator"
|
||||||
"generate": "lezer-generator common/markdown_parser/query.grammar -o common/markdown_parser/parse-query.js"
|
"generate": "lezer-generator common/markdown_parser/query.grammar -o common/markdown_parser/parse-query.js",
|
||||||
|
|
||||||
|
// Compile
|
||||||
|
"compile": "deno task bundle && deno compile -A -o silverbullet dist/silverbullet.js",
|
||||||
|
"server:dist:linux-x86_64": "deno task bundle && deno compile -A --target x86_64-unknown-linux-gnu dist/silverbullet.js -o silverbullet && zip silverbullet-server-linux-x86_64.zip silverbullet",
|
||||||
|
"server:dist:darwin-x86_64": "deno task bundle && deno compile -A --target x86_64-apple-darwin dist/silverbullet.js -o silverbullet && zip silverbullet-server-darwin-x86_64.zip silverbullet",
|
||||||
|
"server:dist:darwin-aarch64": "deno task bundle && deno task bundle && deno compile -A --target aarch64-apple-darwin dist/silverbullet.js -o silverbullet && zip silverbullet-server-darwin-aarch64.zip silverbullet",
|
||||||
|
"server:dist:windows-x86_64": "deno compile -A --target x86_64-pc-windows-msvc dist/silverbullet.js -o silverbullet.exe && zip silverbullet-server-windows-x86_64.zip silverbullet.exe"
|
||||||
},
|
},
|
||||||
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
35
install.sh
Normal file
35
install.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if ! command -v unzip >/dev/null; then
|
||||||
|
echo "Error: unzip is required to install SilverBullet." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $(uname -sm) in
|
||||||
|
"Darwin x86_64") target="darwin-x86_64" ;;
|
||||||
|
"Darwin arm64") target="darwin-aarch64" ;;
|
||||||
|
"Linux aarch64")
|
||||||
|
echo "Error: Official SilverBullet builds for Linux aarch64 are not available." 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*) target="linux-x86_64" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "Installing for $target"
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
sb_uri="https://github.com/silverbulletmd/silverbullet/releases/latest/download/silverbullet-server-${target}.zip"
|
||||||
|
else
|
||||||
|
sb_uri="https://github.com/silverbulletmd/silverbullet/releases/download/${1}/silverbullet-server-${target}.zip"
|
||||||
|
fi
|
||||||
|
exe=silverbullet
|
||||||
|
bin_dir=.
|
||||||
|
|
||||||
|
curl --fail --location --progress-bar --output "$exe.zip" "$sb_uri"
|
||||||
|
unzip -d "$bin_dir" -o "$exe.zip"
|
||||||
|
chmod +x "$exe"
|
||||||
|
rm "$exe.zip"
|
||||||
|
|
||||||
|
echo "SilverBullet server was installed successfully to $bin, run it directly via ./$exe or move it to a more convenient place."
|
@ -48,4 +48,5 @@ echo > website_build/empty.md
|
|||||||
#echo "Bundling..."
|
#echo "Bundling..."
|
||||||
deno task bundle
|
deno task bundle
|
||||||
cp dist/silverbullet.js website_build/
|
cp dist/silverbullet.js website_build/
|
||||||
cp web/images/logo.ico website_build/
|
cp web/images/logo.ico website_build/
|
||||||
|
cp install.sh website_build/
|
Loading…
Reference in New Issue
Block a user