Skip to content

Commit ebaaf57

Browse files
committed
chore: add workflow to release crates
1 parent cedf57e commit ebaaf57

6 files changed

Lines changed: 71 additions & 27 deletions

File tree

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish to crates.io
2+
on:
3+
push:
4+
tags: ['v*'] # Triggers when pushing tags starting with 'v'
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
id-token: write # Required for OIDC token exchange
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: rust-lang/crates-io-auth-action@v1
13+
id: auth
14+
15+
- name: Publish typesense_derive
16+
run: cargo publish
17+
working-directory: typesense_derive
18+
19+
- name: Publish typesense_codegen
20+
run: cargo publish
21+
working-directory: typesense_codegen
22+
23+
- name: Publish typesense
24+
run: cargo publish
25+
working-directory: typesense

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,17 @@ members = [
44
"typesense_derive",
55
"typesense_codegen"
66
]
7+
8+
resolver = "3"
9+
10+
[workspace.package]
11+
version = "0.3.0"
12+
edition = "2024"
13+
license = "Apache-2.0"
14+
repository = "https://github.com/typesense/typesense-rust"
15+
authors = ["Typesense <contact@typesense.org>"]
16+
17+
[workspace.dependencies]
18+
19+
typesense_derive = { path = "./typesense_derive", version = "0.3.0" }
20+
typesense_codegen = { path = "./typesense_codegen", version = "0.25.0" }

typesense/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "typesense"
3-
version = "0.2.0"
4-
authors = ["Typesense <contact@typesense.org>"]
5-
edition = "2018"
6-
license = "Apache-2.0"
7-
description = "WIP client for typesense"
8-
repository = "https://github.com/typesense/typesense-rust"
3+
version.workspace = true
4+
authors.workspace = true
5+
repository.workspace = true
6+
edition.workspace = true
7+
license.workspace = true
8+
description = "Client for typesense"
99

1010
[features]
1111
default = ["derive"]
@@ -24,8 +24,8 @@ hmac = "0.12"
2424
serde = { version = "1", features = ["derive"] }
2525
serde_json = "1.0"
2626
sha2 = "0.10"
27-
typesense_derive = { version = "0.2.0", path = "../typesense_derive", optional = true }
28-
typesense_codegen = { version = "0.25.0", path = "../typesense_codegen" }
27+
typesense_derive = { workspace = true, optional = true }
28+
typesense_codegen = { workspace = true }
2929

3030
[dev-dependencies]
3131
dotenvy = "0.15"

typesense_codegen/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[package]
22
name = "typesense_codegen"
3-
version = "0.25.0"
4-
authors = ["OpenAPI Generator team and contributors"]
5-
description = "client for typesense generated with openapi spec"
6-
edition = "2018"
7-
license = "Apache-2.0"
3+
version = "0.25.1"
4+
description = "Types for typesense generated with openapi spec"
5+
authors.workspace = true
6+
repository.workspace = true
7+
edition.workspace = true
8+
license.workspace = true
89

910
[dependencies]
1011
serde = "^1.0"

typesense_derive/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[package]
22
name = "typesense_derive"
3-
version = "0.2.0"
4-
authors = ["Typesense <contact@typesense.org>"]
5-
edition = "2018"
3+
version.workspace = true
64
description = "macros for typesense client"
7-
license = "Apache-2.0"
5+
authors.workspace = true
6+
repository.workspace = true
7+
edition.workspace = true
8+
license.workspace = true
89

910
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1011

typesense_derive/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use proc_macro::TokenStream;
22
use proc_macro2::{Ident, TokenTree};
3-
use quote::{quote, ToTokens};
4-
use syn::{spanned::Spanned, Attribute, Field, ItemStruct};
3+
use quote::{ToTokens, quote};
4+
use syn::{Attribute, Field, ItemStruct, spanned::Spanned};
55

66
#[proc_macro_derive(Typesense, attributes(typesense))]
77
pub fn typesense_collection_derive(input: TokenStream) -> TokenStream {
@@ -79,7 +79,7 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
7979
proc_macro2::TokenStream::new()
8080
};
8181

82-
let gen = quote! {
82+
let g = quote! {
8383
impl #impl_generics typesense::document::Document for #ident #ty_generics #where_clause {
8484
fn collection_schema() -> typesense::collection_schema::CollectionSchema {
8585
let name = #collection_name.to_owned();
@@ -94,18 +94,18 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
9494
}
9595
}
9696
};
97-
Ok(gen.into())
97+
Ok(g.into())
9898
}
9999

100-
// Get the inner type for a given wrappper
100+
// Get the inner type for a given wrapper
101101
fn ty_inner_type<'a>(ty: &'a syn::Type, wrapper: &'static str) -> Option<&'a syn::Type> {
102-
if let syn::Type::Path(ref p) = ty {
102+
if let syn::Type::Path(p) = ty {
103103
if p.path.segments.len() == 1 && p.path.segments[0].ident == wrapper {
104104
if let syn::PathArguments::AngleBracketed(ref inner_ty) = p.path.segments[0].arguments {
105105
if inner_ty.args.len() == 1 {
106106
// len is 1 so this should not fail
107107
let inner_ty = inner_ty.args.first().unwrap();
108-
if let syn::GenericArgument::Type(ref t) = inner_ty {
108+
if let syn::GenericArgument::Type(t) = inner_ty {
109109
return Some(t);
110110
}
111111
}
@@ -198,7 +198,7 @@ fn extract_attrs(attrs: Vec<Attribute>) -> syn::Result<Attrs> {
198198
return Err(syn::Error::new(
199199
tt.span(),
200200
"Expected boolean, without quotation marks (\"\")",
201-
))
201+
));
202202
}
203203
};
204204
res.enable_nested_fields = Some(val);
@@ -250,10 +250,13 @@ fn to_typesense_field_type(field: &Field) -> syn::Result<proc_macro2::TokenStrea
250250
return Some(Err(syn::Error::new_spanned(
251251
tt,
252252
format!("Unexpected token {}. Did you mean `facet`?", tt),
253-
)))
253+
)));
254254
}
255255
None => {
256-
return Some(Err(syn::Error::new_spanned(attr, "expected `facet`")))
256+
return Some(Err(syn::Error::new_spanned(
257+
attr,
258+
"expected `facet`",
259+
)));
257260
}
258261
}
259262

0 commit comments

Comments
 (0)