feat: Add ci and wasm pages
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
contents: "read"
|
||||||
|
id-token: "write"
|
||||||
|
pages: "write"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: DeterminateSystems/nix-installer-action@main
|
||||||
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
- uses: DeterminateSystems/flake-checker-action@main
|
||||||
|
|
||||||
|
- name: Run `nix build wasm`
|
||||||
|
run: nix build .#tadventure-wasm
|
||||||
|
|
||||||
|
- name: Setup Pages
|
||||||
|
uses: actions/configure-pages@v5
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
with:
|
||||||
|
path: result/dist
|
||||||
|
|
||||||
|
- name: Deploy to gh-pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Tadventure</title>
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
canvas {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
background: black;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas id="glcanvas" tabindex='1'></canvas>
|
||||||
|
<script src="https://not-fl3.github.io/miniquad-samples/gl.js"></script>
|
||||||
|
<script>load("tadventure.wasm");</script> <!-- Your compiled wasm file -->
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
# Extra targets if required
|
# Extra targets if required
|
||||||
};
|
};
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain stableToolchain;
|
craneLib = (crane.mkLib pkgs).overrideToolchain stableToolchain;
|
||||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
src = craneLib.path ./.;
|
||||||
commonArgs = {
|
commonArgs = {
|
||||||
inherit src;
|
inherit src;
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||||
in {
|
in rec {
|
||||||
checks = {
|
checks = {
|
||||||
tadventure-clippy = craneLib.cargoClippy (commonArgs
|
tadventure-clippy = craneLib.cargoClippy (commonArgs
|
||||||
// {
|
// {
|
||||||
@@ -111,10 +111,35 @@
|
|||||||
inherit src;
|
inherit src;
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
cargoExtraArgs = "--target wasm32-unknown-unknown";
|
cargoExtraArgs = "--target wasm32-unknown-unknown";
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/dist
|
||||||
|
cp target/wasm32-unknown-unknown/release/tadventure.wasm $out/dist/tadventure.wasm
|
||||||
|
cp $src/assets/index.html $out/dist/index.html
|
||||||
|
'';
|
||||||
|
meta.mainProgram = null;
|
||||||
};
|
};
|
||||||
default = tadventure;
|
default = tadventure;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
apps = {
|
||||||
|
default = let
|
||||||
|
wasm = pkgs.writeShellApplication {
|
||||||
|
# Our shell script name is serve
|
||||||
|
# so it is available at $out/bin/serve
|
||||||
|
name = "tadventure";
|
||||||
|
# Caddy is a web server with a convenient CLI interface
|
||||||
|
runtimeInputs = [pkgs.caddy];
|
||||||
|
text = ''
|
||||||
|
# Serve the current directory on port 8090
|
||||||
|
caddy file-server --listen :8000 --root ${packages.tadventure-wasm}/dist
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
type = "app";
|
||||||
|
program = "${wasm}/bin/tadventure";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
devShells.default = (craneLib.overrideToolchain stableToolchainWithRustAnalyzer).devShell (commonArgs
|
devShells.default = (craneLib.overrideToolchain stableToolchainWithRustAnalyzer).devShell (commonArgs
|
||||||
// {
|
// {
|
||||||
buildInputs = [];
|
buildInputs = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user