diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..07264e9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: release +on: + workflow_run: + workflows: ["test"] + branches: [main] + types: + - completed + +env: + CARGO_TERM_COLOR: always + +jobs: + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/test.yml similarity index 82% rename from .github/workflows/ci.yml rename to .github/workflows/test.yml index 5e32586..1cf3945 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,5 @@ -name: build and test +name: test on: - workflow_dispatch: push: branches: - main @@ -77,20 +76,3 @@ jobs: prefix-key: cargo shared-key: udeps - uses: tweedegolf/ci-standard/.github/actions/cargo-udeps@main - - publish: - needs: - - format - - outdated - - deny - - build - - clippy - - test - - test-release - - udeps - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 348d097..775b6d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.4.3" +version = "0.4.4" edition = "2021" license = "Apache-2.0 OR MIT" repository = "https://github.com/tweedegolf/memory-serve" diff --git a/README.md b/README.md index 4639722..8c39889 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ calling `Router::into_make_service()`. ## Example -```rust +```rust,no_run use axum::{response::Html, routing::get, Router}; use memory_serve::{load_assets, MemoryServe}; use std::net::SocketAddr; @@ -54,7 +54,7 @@ async fn main() { .index_file(Some("/index.html")) .into_router(); - // possible other routes an be added at this point, like API routes + // possible other routes can be added at this point, like API routes let app = Router::new() .merge(memory_router); diff --git a/memory-serve-macros/src/lib.rs b/memory-serve-macros/src/lib.rs index af3ad49..b8ce56a 100644 --- a/memory-serve-macros/src/lib.rs +++ b/memory-serve-macros/src/lib.rs @@ -20,9 +20,13 @@ pub fn load_assets(input: TokenStream) -> TokenStream { .try_init(); if asset_path.is_relative() { - let crate_dir = env::var("CARGO_MANIFEST_DIR") - .expect("CARGO_MANIFEST_DIR environment variable not set"); - asset_path = Path::new(&crate_dir).join(asset_path); + if let Ok(root_dir) = env::var("MEMORY_SERVE_ROOT") { + asset_path = Path::new(&root_dir).join(asset_path); + } else if let Ok(crate_dir) = env::var("CARGO_MANIFEST_DIR") { + asset_path = Path::new(&crate_dir).join(asset_path); + } else { + panic!("Relative path provided but CARGO_MANIFEST_DIR environment variable not set"); + } } asset_path = asset_path diff --git a/memory-serve/Cargo.toml b/memory-serve/Cargo.toml index a48a308..b8de64e 100644 --- a/memory-serve/Cargo.toml +++ b/memory-serve/Cargo.toml @@ -16,5 +16,6 @@ tracing = "0.1" sha256 = "1.4" [dev-dependencies] -tokio = { version = "1", features = ["rt", "macros"] } +tokio = { version = "1", features = ["full"] } tower = "0.4" +axum = { version = "0.7" } diff --git a/memory-serve/static b/memory-serve/static new file mode 120000 index 0000000..4dab164 --- /dev/null +++ b/memory-serve/static @@ -0,0 +1 @@ +../static \ No newline at end of file