-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b3de8da
Showing
44 changed files
with
2,532 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Deploy to Production | ||
on: | ||
release: | ||
# type: released | ||
# A release was published, or a pre-release was changed to a release. | ||
types: [released] | ||
# repository_dispatch: | ||
# types: [deploy] | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy to Fly.io and Netlify | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- uses: dsaltares/fetch-gh-release-asset@master | ||
with: | ||
file: "static-assets.tar.gz" | ||
- name: Un-tar static assets | ||
run: tar -xzvf static-assets.tar.gz | ||
- name: Publish to Netlify | ||
uses: netlify/actions/cli@master | ||
with: | ||
args: deploy --dir=target/site --prod | ||
env: | ||
NETLIFY_SITE_ID: 92571a12-b93f-4e77-bf4e-744c8ccec4e5 | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
- uses: dsaltares/fetch-gh-release-asset@master | ||
with: | ||
file: "fly.toml" | ||
- run: flyctl deploy --image $IMAGE_LABEL | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
IMAGE_LABEL: registry.fly.io/christopherbiscardi:${{github.event.release.name}} |
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,68 @@ | ||
name: Cut Release | ||
on: | ||
push: | ||
branches: | ||
- "wasm-main" | ||
paths: | ||
- "src/**" | ||
- "Dockerfile" | ||
- "style/**" | ||
- "tailwind.config.js" | ||
- "fly.toml" | ||
- "public/**" | ||
|
||
jobs: | ||
release: | ||
name: Test, Release [Docker, GH] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
toolchain: nightly-2024-08-10 | ||
targets: "wasm32-unknown-unknown" | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
# The prefix cache key, this can be changed to start a new cache manually. | ||
prefix-key: "v0-rust" | ||
|
||
# A cache key that is used instead of the automatic `job`-based key, | ||
# and is stable over multiple jobs. | ||
# default: empty | ||
# shared-key: "" | ||
- name: "Install cargo-leptos" | ||
run: curl --proto '=https' --tlsv1.2 -LsSf https://leptos-rs.artifacts.axodotdev.host/cargo-leptos/v0.2.12/cargo-leptos-installer.sh | sh | ||
- run: cargo leptos test | ||
- run: cargo leptos build --release | ||
env: | ||
CDN_PATH: https://cdn.christopherbiscardi.com | ||
CDN_PKG_PATH: https://cdn.christopherbiscardi.com/pkg | ||
LEPTOS_HASH_FILES: true | ||
- name: Get current date | ||
id: date | ||
run: | | ||
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
- name: Publish Docker Image to Fly.io | ||
run: flyctl deploy --build-only --push --image-label $IMAGE_LABEL | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
IMAGE_LABEL: gh-${{ env.date }}-${{ github.sha }} | ||
- name: Tar static files | ||
run: | | ||
tar -czvf static-assets.tar.gz target/site | ||
- name: Publish GitHub Release | ||
id: gh-release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: gh-${{ env.date }}-${{ github.sha }} | ||
fail_on_unmatched_files: true | ||
target_commitish: main | ||
tag_name: ${{env.date}}-${{ github.sha }} | ||
token: ${{ secrets.RELEASE_TOKEN }} | ||
files: | | ||
Cargo.toml | ||
target/release/this-week-in-bevy | ||
static-assets.tar.gz | ||
target/release/hash.txt | ||
fly.toml |
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,12 @@ | ||
name: test suite | ||
on: [pull_request] | ||
|
||
jobs: | ||
test: | ||
name: cargo leptos test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- run: cargo install cargo-leptos | ||
- run: cargo leptos test |
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,14 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
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,4 @@ | ||
max_width = 60 | ||
wrap_comments = true | ||
comment_width = 50 | ||
fn_call_width = 40 |
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,19 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["crates/*"] | ||
|
||
|
||
# Defines a size-optimized profile for the WASM bundle in release mode | ||
[profile.wasm-release] | ||
inherits = "release" | ||
opt-level = 'z' | ||
lto = true | ||
codegen-units = 1 | ||
panic = "abort" | ||
|
||
|
||
# [patch.crates-io] | ||
# # leptos = { version = "0.7.0-beta" | ||
# leptos = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" } | ||
# leptos_axum = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" } | ||
# leptos_router = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" } |
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,108 @@ | ||
[package] | ||
name = "www" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
leptos_meta = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" } | ||
axum = { version = "0.7", optional = true } | ||
console_error_panic_hook = "0.1" | ||
leptos = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7", features = [ | ||
"nightly", | ||
"experimental-islands", | ||
] } | ||
leptos_axum = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7", optional = true } | ||
leptos_router = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7", features = [ | ||
"nightly", | ||
] } | ||
leptos-use = { git = "https://github.com/Synphonyte/leptos-use.git", branch = "leptos-0.7" } | ||
tokio = { version = "1", features = ["rt-multi-thread"], optional = true } | ||
tower = { version = "0.4", optional = true } | ||
tower-http = { version = "0.5", features = ["fs"], optional = true } | ||
wasm-bindgen = "=0.2.92" | ||
thiserror = "1" | ||
tracing = { version = "0.1", optional = true } | ||
http = "1" | ||
|
||
|
||
[features] | ||
hydrate = ["leptos/hydrate"] | ||
ssr = [ | ||
"dep:axum", | ||
"dep:tokio", | ||
"dep:tower", | ||
"dep:tower-http", | ||
"dep:leptos_axum", | ||
"leptos/ssr", | ||
"leptos_meta/ssr", | ||
"leptos_router/ssr", | ||
"dep:tracing", | ||
] | ||
|
||
|
||
[package.metadata.leptos] | ||
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name | ||
output-name = "www" | ||
|
||
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup. | ||
site-root = "target/site" | ||
|
||
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written | ||
# Defaults to pkg | ||
site-pkg-dir = "pkg" | ||
|
||
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css | ||
# style-file = "style/main.scss" | ||
tailwind-input-file = "style/input.css" | ||
|
||
# Assets source dir. All files found here will be copied and synchronized to site-root. | ||
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir. | ||
# | ||
# Optional. Env: LEPTOS_ASSETS_DIR. | ||
assets-dir = "public" | ||
|
||
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup. | ||
site-addr = "127.0.0.1:3000" | ||
|
||
# The port to use for automatic reload monitoring | ||
reload-port = 3001 | ||
|
||
# [Optional] Command to use when running end2end tests. It will run in the end2end dir. | ||
# [Windows] for non-WSL use "npx.cmd playwright test" | ||
# This binary name can be checked in Powershell with Get-Command npx | ||
end2end-cmd = "npx playwright test" | ||
end2end-dir = "end2end" | ||
|
||
# The browserlist query used for optimizing the CSS. | ||
browserquery = "defaults" | ||
|
||
# The environment Leptos will run in, usually either "DEV" or "PROD" | ||
env = "DEV" | ||
|
||
# The features to use when compiling the bin target | ||
# | ||
# Optional. Can be over-ridden with the command line parameter --bin-features | ||
bin-features = ["ssr"] | ||
|
||
# If the --no-default-features flag should be used when compiling the bin target | ||
# | ||
# Optional. Defaults to false. | ||
bin-default-features = false | ||
|
||
# The features to use when compiling the lib target | ||
# | ||
# Optional. Can be over-ridden with the command line parameter --lib-features | ||
lib-features = ["hydrate"] | ||
|
||
# If the --no-default-features flag should be used when compiling the lib target | ||
# | ||
# Optional. Defaults to false. | ||
lib-default-features = false | ||
|
||
# The profile to use for the lib target when compiling for release | ||
# | ||
# Optional. Defaults to "release". | ||
lib-profile-release = "wasm-release" |
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,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <https://unlicense.org> |
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,90 @@ | ||
<picture> | ||
<source srcset="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_Solid_White.svg" media="(prefers-color-scheme: dark)"> | ||
<img src="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_RGB.svg" alt="Leptos Logo"> | ||
</picture> | ||
|
||
# Leptos Axum Starter Template | ||
|
||
This is a template for use with the [Leptos](https://github.com/leptos-rs/leptos) web framework and the [cargo-leptos](https://github.com/akesson/cargo-leptos) tool using [Axum](https://github.com/tokio-rs/axum). | ||
|
||
## Creating your template repo | ||
|
||
If you don't have `cargo-leptos` installed you can install it with | ||
|
||
```bash | ||
cargo install cargo-leptos --locked | ||
``` | ||
|
||
Then run | ||
```bash | ||
cargo leptos new --git https://github.com/leptos-rs/start-axum-0.7 | ||
``` | ||
|
||
to generate a new project template. | ||
|
||
```bash | ||
cd www | ||
``` | ||
|
||
to go to your newly created project. | ||
Feel free to explore the project structure, but the best place to start with your application code is in `src/app.rs`. | ||
Addtionally, Cargo.toml may need updating as new versions of the dependencies are released, especially if things are not working after a `cargo update`. | ||
|
||
## Running your project | ||
|
||
```bash | ||
cargo leptos watch | ||
``` | ||
|
||
## Installing Additional Tools | ||
|
||
By default, `cargo-leptos` uses `nightly` Rust, `cargo-generate`, and `sass`. If you run into any trouble, you may need to install one or more of these tools. | ||
|
||
1. `rustup toolchain install nightly --allow-downgrade` - make sure you have Rust nightly | ||
2. `rustup target add wasm32-unknown-unknown` - add the ability to compile Rust to WebAssembly | ||
3. `cargo install cargo-generate` - install `cargo-generate` binary (should be installed automatically in future) | ||
4. `npm install -g sass` - install `dart-sass` (should be optional in future | ||
|
||
## Compiling for Release | ||
```bash | ||
cargo leptos build --release | ||
``` | ||
|
||
Will generate your server binary in target/server/release and your site package in target/site | ||
|
||
## Testing Your Project | ||
```bash | ||
cargo leptos end-to-end | ||
``` | ||
|
||
```bash | ||
cargo leptos end-to-end --release | ||
``` | ||
|
||
Cargo-leptos uses Playwright as the end-to-end test tool. | ||
Tests are located in end2end/tests directory. | ||
|
||
## Executing a Server on a Remote Machine Without the Toolchain | ||
After running a `cargo leptos build --release` the minimum files needed are: | ||
|
||
1. The server binary located in `target/server/release` | ||
2. The `site` directory and all files within located in `target/site` | ||
|
||
Copy these files to your remote server. The directory structure should be: | ||
```text | ||
www | ||
site/ | ||
``` | ||
Set the following environment variables (updating for your project as needed): | ||
```text | ||
LEPTOS_OUTPUT_NAME="www" | ||
LEPTOS_SITE_ROOT="site" | ||
LEPTOS_SITE_PKG_DIR="pkg" | ||
LEPTOS_SITE_ADDR="127.0.0.1:3000" | ||
LEPTOS_RELOAD_PORT="3001" | ||
``` | ||
Finally, run the server binary. | ||
|
||
## Licensing | ||
|
||
This template itself is released under the Unlicense. You should replace the LICENSE for your own application with an appropriate license if you plan to release it publicly. |
Oops, something went wrong.