File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build :
10+ name : Build Connectors
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout repo
15+ uses : actions/checkout@v4
16+
17+ - name : Setup Node
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : 22
21+
22+ - name : Setup Rust
23+ uses : dtolnay/rust-toolchain@stable
24+
25+ - name : Install wasm-pack
26+ run : curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
27+
28+ - name : Build WASM binary
29+ run : |
30+ cd connecto.rs
31+ chmod +x build.sh
32+ ./build.sh
33+
34+ - name : Install dependencies
35+ uses : bahmutov/npm-install@v1.10.9
36+ with :
37+ working-directory : ./www
38+
39+ - name : Build project
40+ run : npm run build
41+ working-directory : ./www
42+
43+ - name : Upload build files
44+ uses : actions/upload-artifact@v4
45+ with :
46+ name : artifacts
47+ path : ./www/dist
48+
49+ deploy :
50+ name : Deploy Connectors
51+ runs-on : ubuntu-latest
52+ permissions :
53+ contents : write
54+ steps :
55+ - uses : actions/checkout@v4
56+
57+ - name : Download build artifacts
58+ uses : actions/download-artifact@v4
59+ with :
60+ name : artifacts
61+ path : ./www/dist
62+
63+ - name : Deploy
64+ uses : peaceiris/actions-gh-pages@v4
65+ if : github.ref == 'refs/heads/main'
66+ with :
67+ github_token : ${{ secrets.GITHUB_TOKEN }}
68+ publish_dir : ./www/dist
69+ needs : build
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ connectors/
6464 - [ 5.2 - Adding interactivity] ( https://github.com/tauseefk/connectors/tree/interactivity )
6565- Chapter 6
6666 - [ Chapter 6 - Computing the winner] ( https://github.com/tauseefk/connectors/tree/winning-move )
67+ - Chapter 7
68+ - [ Chapter 7 - Build and deploy] ( )
6769
6870## Other Resources
6971
Original file line number Diff line number Diff line change 22
33set -euo pipefail
44
5- TARGET=web
5+ TARGET=bundler
66OUTDIR=../../www/connectors
77
88wasm-pack build connectors --target $TARGET --release --out-dir $OUTDIR
Original file line number Diff line number Diff line change 1+ /connectors
2+ .DS_Store
3+ node_modules
4+ /dist
Original file line number Diff line number Diff line change 1+ import esbuild from "esbuild" ;
2+ import { copy } from "esbuild-plugin-copy" ;
3+ import { wasmLoader } from "esbuild-plugin-wasm" ;
4+
5+ const isDevelopment = process . env . NODE_ENV === "development" ;
6+
7+ const buildOptions = {
8+ logLevel : "info" ,
9+ entryPoints : [ "src/index.js" ] ,
10+ bundle : true ,
11+ minify : ! isDevelopment ,
12+ format : "esm" ,
13+ platform : "browser" ,
14+ target : "es2022" ,
15+ outdir : "./dist" ,
16+ plugins : [
17+ wasmLoader ( ) ,
18+ // copy the index.html and styles.css as they are
19+ copy ( {
20+ resolveFrom : "cwd" ,
21+ assets : {
22+ from : [ "./public/*" ] ,
23+ to : [ "./dist" ] ,
24+ } ,
25+ } ) ,
26+ ] ,
27+ } ;
28+
29+ const run = async ( ) => {
30+ try {
31+ const ctx = await esbuild . context ( buildOptions ) ;
32+
33+ if ( ! isDevelopment ) {
34+ await esbuild . build ( buildOptions ) ;
35+ console . log ( "Build complete" ) ;
36+
37+ process . exit ( 0 ) ;
38+ return ;
39+ }
40+
41+ // DEV server
42+ await ctx . serve ( {
43+ port : 8000 ,
44+ servedir : "./dist" ,
45+ } ) ;
46+ await ctx . watch ( ) ;
47+ } catch ( e ) {
48+ console . error ( e ) ;
49+ process . exit ( 1 ) ;
50+ }
51+ } ;
52+
53+ run ( ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments