From a5ae345498d6cb51c8f5c11d4edf0f732163617b Mon Sep 17 00:00:00 2001 From: Mizuki Date: Tue, 31 Oct 2023 11:32:30 +0900 Subject: [PATCH 1/2] fetch templates from remote location if provided --- cli.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cli.ts b/cli.ts index 10f9df3..8331df2 100755 --- a/cli.ts +++ b/cli.ts @@ -21,6 +21,11 @@ const getAddressFromPrivateKey = async (key: string | Uint8Array) => { const confirmOptions: Partial = { active: "y", inactive: "n" }; +const fetchTemplate = (path: string) => { + if (globalThis.location) return fetch(path).then((res) => res.text()); + return Deno.readTextFile(path); +} + const envKeys = [ "L1_RPC", "L2_CHAIN_ID", @@ -63,7 +68,7 @@ if (!(env.ADMIN_KEY && env.PROPOSER_KEY && env.BATCHER_KEY && env.SEQUENCER_KEY) } } -let dockerComposeYml = await Deno.readTextFile("templates/docker-compose.yml"); +let dockerComposeYml = await fetchTemplate("templates/docker-compose.yml"); await Deno.mkdir("out", { recursive: true }); @@ -73,7 +78,7 @@ if ( ...confirmOptions, }) ) { - dockerComposeYml += "\n" + await Deno.readTextFile("templates/docker-compose-blockscout.yml"); + dockerComposeYml += "\n" + await fetchTemplate("templates/docker-compose-blockscout.yml"); if (Deno.build.arch === "aarch64") { env.BLOCKSCOUT_IMAGE = "ghcr.io/planetarium/mothership-l2launcher-blockscout"; } @@ -82,7 +87,7 @@ if ( if ( await Confirm.prompt({ message: "Add Skandha bundler to docker-compose.yml?", ...confirmOptions }) ) { - dockerComposeYml += "\n" + await Deno.readTextFile("templates/docker-compose-bundler.yml"); + dockerComposeYml += "\n" + await fetchTemplate("templates/docker-compose-bundler.yml"); if (!env.ERC4337_BUNDLER_KEY) { if ( await Confirm.prompt({ @@ -99,7 +104,7 @@ if ( } console.log("Using predeploys from templates/predeploy.json."); -await Deno.copyFile("templates/predeploy.json", "out/predeploy.json"); +await Deno.writeTextFile("out/predeploy.json", await fetchTemplate("templates/predeploy.json")); await Deno.writeTextFile("out/docker-compose.yml", dockerComposeYml); console.log("out/docker-compose.yml copied."); From dd44896671cbb9ef28ea68d76ba3e81113a26f99 Mon Sep 17 00:00:00 2001 From: Mizuki Date: Wed, 1 Nov 2023 15:52:46 +0900 Subject: [PATCH 2/2] Add GitHub Action workflow to compile executable --- .github/workflows/deno-compile.yml | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/deno-compile.yml diff --git a/.github/workflows/deno-compile.yml b/.github/workflows/deno-compile.yml new file mode 100644 index 0000000..b58af40 --- /dev/null +++ b/.github/workflows/deno-compile.yml @@ -0,0 +1,65 @@ +name: Deno Compile + +on: + push: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - x86_64-unknown-linux-gnu + - x86_64-pc-windows-msvc + - x86_64-apple-darwin + - aarch64-apple-darwin + + steps: + - uses: actions/checkout@v4 + + - uses: denoland/setup-deno@v1 + + - name: deno compile ${{ matrix.target }} + run: > + deno compile + --allow-net + --allow-read + --allow-write=./ + --allow-run=docker + --location=https://raw.githubusercontent.com/planetarium/mothership-l2launcher/main + --target=${{ matrix.target }} + --output=build/l2launcher-${{ matrix.target }} + cli.ts + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: builds + path: build/* + if-no-files-found: error + retention-days: 1 + + release: + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: builds + path: build + + - name: Release + uses: softprops/action-gh-release@v1 + with: + prerelease: true + draft: true + token: ${{ secrets.GITHUB_TOKEN }} + files: | + build/l2launcher-x86_64-unknown-linux-gnu + build/l2launcher-aarch64-apple-darwin + build/l2launcher-x86_64-apple-darwin + build/l2launcher-x86_64-pc-windows-msvc.exe +