Projects
How it is deployed
The current framework (macroquad) being used for the project had much better support for wasm compilation than the previous framework, Raylib , which is why the project was recenly refactored.cargo build --target wasm32-unknown-unknown
This will output a wasm file in 'target/wasm32-unknown-unknown/debug/football.wasm', the author of the library created a single '.js' file which contains the glue needed to embed this into the frontend pretty easily. I did not, however, want to embed the wasm file into the git history of this project website, so I instead have setup the deployment of this site (hosted for free on vercel) to pull the .wasm file during deployment using a github api key. Here, i have simply hard-coded the artifact's ID as changes are infrequent enough, though the same api-key could list workflow runs & pull the latest artifact that way.
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--output "football.wasm.zip" \
https://api.github.com/repos/ajhetherington/football/actions/artifacts/1236674243/zip
unzip football.wasm.zip -d static
rm -f football.wasm.zip