Skip to content

Commit

Permalink
Merge pull request #28 from eseiker/gh-action-deno-compile
Browse files Browse the repository at this point in the history
Build cross-compiled executables with GitHub Actions
  • Loading branch information
eseiker authored Nov 1, 2023
2 parents 6530a2d + dd44896 commit da57e05
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/deno-compile.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 9 additions & 4 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const getAddressFromPrivateKey = async (key: string | Uint8Array) => {

const confirmOptions: Partial<ConfirmOptions> = { 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",
Expand Down Expand Up @@ -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 });

Expand All @@ -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";
}
Expand All @@ -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({
Expand All @@ -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.");
Expand Down

0 comments on commit da57e05

Please sign in to comment.