-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasm: Separate dev and release builds.
* Pass explicit output directory to wasm-pack (which are in the target directory, for tidiness). * Pass profile to wasm-pack. * Select client files to read/embed in the server based on profile. * Create a CI job for building the web version as release. There is a gap in coverage here, in that xtask has no way to say "build the release client to run the release server", but it has no way to run the release server anyway, so that's okay, and eventually I want to trigger it automatically from the build script. Part of <#379>.
- Loading branch information
Showing
6 changed files
with
167 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,18 +191,50 @@ jobs: | |
path: | | ||
target/cargo-timings/cargo-timing-*.html | ||
- run: df -h . | ||
|
||
# Build web version with release profile. | ||
build-web: | ||
# Only do this if the tests passed | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
# Same condition as "deploy-web" job, because the result will only be used then. | ||
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pages-alt') }} | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- uses: Swatinem/[email protected] | ||
with: | ||
# Reuse the cache from the normal `build` job instead of creating an independent one, | ||
# to reduce redundant work and save disk space — but don't *write* to that cache, so | ||
# we don't bloat it or conflict. | ||
# | ||
# Since this is a release build, it won’t be able to reuse most of the build artifacts, | ||
# but it will be able to reuse xtask and possibly some build dependencies, so it will | ||
# still be faster than a clean build. | ||
prefix-key: "v1-rust-ubuntu-stable-locked" | ||
shared-key: "build" | ||
save-if: false | ||
workspaces: | | ||
./ | ||
all-is-cubes-wasm/ | ||
- run: cargo build --package xtask | ||
|
||
- run: cargo xtask build-web-release | ||
|
||
# Save wasm build so that we can optionally deploy it without rebuilding | ||
# (but only for the stablest matrix version) | ||
- name: Save wasm dist artifact | ||
if: ${{ matrix.primary }} | ||
uses: actions/upload-pages-artifact@v3 | ||
- uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: all-is-cubes-wasm/dist | ||
|
||
- run: df -h . | ||
|
||
deploy: | ||
needs: build | ||
# Deploy web build to GitHub Pages. | ||
deploy-web: | ||
needs: build-web | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pages: write | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![allow(missing_docs)] | ||
|
||
fn main() { | ||
// Make the build profile visible so that we can | ||
// embed/read a client built with the same profile. | ||
// We use cfg rather than env because `include_dir!()` forces us to do that anyway. | ||
// TODO: Replace `include_dir!()` with a build script. | ||
// Also, replace requiring the build to already exist with having this build script do it. | ||
println!( | ||
"cargo::rustc-env=AIC_CLIENT_BUILD_DIR={manifest}/../all-is-cubes-wasm/target/web-app-{profile_dir_name}", | ||
manifest = std::env::var("CARGO_MANIFEST_DIR").unwrap(), | ||
profile_dir_name = match &*std::env::var("PROFILE").unwrap() { | ||
"debug" => "dev", | ||
"release" => "release", | ||
other => panic!("unexpected PROFILE={other}") | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters