From 0eedacb0d545f9fe67fddc98fa785111f4c63598 Mon Sep 17 00:00:00 2001 From: Max Mindlin Date: Tue, 9 Jul 2024 22:05:36 -0400 Subject: [PATCH] crates io --- .github/workflows/crates-io.yml | 20 ++++++++++++++++++++ Cargo.toml | 6 +++--- build.rs | 31 +++++++++++++++++++++++++++++++ scout-interpreter/Cargo.toml | 4 ++-- scout-parser/Cargo.toml | 2 +- 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/crates-io.yml create mode 100644 build.rs diff --git a/.github/workflows/crates-io.yml b/.github/workflows/crates-io.yml new file mode 100644 index 0000000..521d742 --- /dev/null +++ b/.github/workflows/crates-io.yml @@ -0,0 +1,20 @@ +name: crates.io + +on: + push: + tags: + - "**[0-9]+.[0-9]+.[0-9]+*" + pull_request: + +jobs: + push_to_crates_io: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index ca86267..b40b8fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,9 +31,9 @@ repository = "https://github.com/maxmindlin/scout-lang" [dependencies] futures = "0.3.30" -scout-interpreter = { path = "./scout-interpreter/" } -scout-lexer = { path = "./scout-lexer/" } -scout-parser = { path = "./scout-parser/" } +scout-interpreter = { version = "0.5.1", path = "./scout-interpreter/" } +scout-lexer = { version = "0.5.1", path = "./scout-lexer/" } +scout-parser = { version = "0.5.1", path = "./scout-parser/" } rustyline = "8.0.0" colored = "2" fantoccini = "0.19.3" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..753f046 --- /dev/null +++ b/build.rs @@ -0,0 +1,31 @@ +use core::panic; +use std::path::Path; +use std::{env, fs, io}; + +fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> io::Result<()> { + fs::create_dir_all(&dst)?; + for entry in fs::read_dir(src)? { + let entry = entry?; + let ty = entry.file_type()?; + if ty.is_dir() { + copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?; + } else { + let content = fs::read_to_string(entry.path())?; + fs::write(dst.as_ref().join(entry.file_name()), content)?; + } + } + Ok(()) +} + +fn main() { + println!("cargo::rerun-if-changed=scout-lib/"); + let scout_dir = match env::var("SCOUT_PATH") { + Ok(s) => Path::new(&s).to_path_buf(), + Err(_) => match env::var("HOME") { + Ok(s) => Path::new(&s).join("scout-lang"), + Err(_) => panic!("Unable to find $HOME or $SCOUT_PATH. Please set one."), + }, + }; + let path = scout_dir.join("scout-lib").to_owned(); + copy_dir_all("scout-lib", path).unwrap(); +} diff --git a/scout-interpreter/Cargo.toml b/scout-interpreter/Cargo.toml index e21c5c7..4fa564b 100644 --- a/scout-interpreter/Cargo.toml +++ b/scout-interpreter/Cargo.toml @@ -6,13 +6,13 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -scout-parser = { path = "../scout-parser/" } +scout-parser = { version = "0.5.1", path = "../scout-parser/" } fantoccini = "0.19.3" futures = "0.3.30" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" image = "0.25.1" -scout-lexer = { path = "../scout-lexer/" } +scout-lexer = { version = "0.5.1", path = "../scout-lexer/" } url = "2.5.2" [dev-dependencies] diff --git a/scout-parser/Cargo.toml b/scout-parser/Cargo.toml index b56963b..df3579c 100644 --- a/scout-parser/Cargo.toml +++ b/scout-parser/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -scout-lexer = { path = "../scout-lexer/" } +scout-lexer = { version = "0.5.1", path = "../scout-lexer/" } [dev-dependencies] test-case = "*"