Skip to content

Commit

Permalink
Try to build github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
0rphee committed Jan 17, 2025
1 parent 7b51858 commit f360995
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on:
pull_request:
push:
branches: ["main"]

paths:
- "app/**"
- "Setup.hs"
- "src/**"
- "test/**"
jobs:
fourmolu:
runs-on: ubuntu-latest
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Web

# Trigger the workflow on push or pull request, but only for the main branch
on:
pull_request:
paths:
- "app/**"
- "asmh.cabal"
- "cabal.project"
- "Setup.hs"
- "src/**"
- "test/**"
- "web/**"
push:
paths:
- "app/**"
- "asmh.cabal"
- "cabal.project"
- "Setup.hs"
- "src/**"
- "test/**"
- "web/**"
workflow_dispatch:

jobs:
build:
name: "Build website"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build site
run: |
nix develop -command bash -c "cd web && echo hello world ls -la"
# nix develop -command bash -c "cd web && ./build.sh && ls dist/"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './web/dist/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'';
mkShell = pkgs.callPackage inputs.clean-devshell.lib.mkDevShell { };
packages = [
pkgs.bash
pkgs.gnumake
pkgs.dartpkgs."2.19.6"
jlox-test
Expand Down
30 changes: 27 additions & 3 deletions web/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,33 @@ if [[ $PWD != */web ]]; then
exit 1
fi

outdir=""
case $1 in
dev)
echo "dev run"
outdir="./static/"
;;
prod)
echo "prod run"
npm install
outdir="./dist/"
cp -R static/ $outdir/
;;
*)
echo "This script should be invoked with 'dev' or 'prod' as arguments."
exit 1
;;
esac

wasm32-wasi-cabal build xolsh-exe && wasmpath=$(wasm32-wasi-cabal list-bin xolsh-exe)
cp -f $wasmpath dist/xolsh-exe.wasm

cp -R static/ dist/
cp -f $wasmpath $outdir/xolsh-exe.wasm

esbuild ./src/index.js --bundle --serve=127.0.0.1:9000 --servedir=./dist --outfile=./dist/index.js --global-name=Main --format=esm --platform=browser "--external:node:timers"
case $1 in
dev)
esbuild ./src/index.js --bundle --serve=127.0.0.1:9000 --servedir=./static --outfile=./static/index.js --format=esm --platform=browser "--external:node:timers"
;;
prod)
esbuild ./src/index.js --bundle --outfile=./dist/index.js --format=esm --platform=browser "--external:node:timers"
;;
esac
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "./build.sh"
"start": "./build.sh dev"
},
"repository": {
"type": "git",
Expand All @@ -24,4 +24,4 @@
"codemirror": "^6.0.1",
"thememirror": "^2.0.1"
}
}
}

0 comments on commit f360995

Please sign in to comment.