Skip to content

Commit

Permalink
Add CI to publish to crates.io (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
curquiza committed Jul 28, 2020
1 parent 020311b commit d97fa0d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -11,3 +11,6 @@ indent_style = space
[*.rs]
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_size = 2
13 changes: 13 additions & 0 deletions .github/scripts/check-release.sh
@@ -0,0 +1,13 @@
#!/bin/sh

# Checking if current tag matches the package version
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
file_tag=$(grep '^version = ' Cargo.toml | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
if [ "$current_tag" != "$file_tag" ]; then
echo "Error: the current tag does not match the version in package file(s)."
echo "$current_tag vs $file_tag"
exit 1
fi

echo 'OK'
exit 0
24 changes: 24 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,24 @@
name: Publish to crates.io
on:
push:
tags:
- v*

jobs:
publish:
runs-on: ubuntu-latest
name: Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: hecrj/setup-rust-action@master
with:
rust-version: stable
- name: Check release validity
run: sh .github/scripts/check-release.sh
- name: Build
run: cargo build --release
- name: Login
run: cargo login ${{ secrets.CRATES_TOKEN }}
- name: Publish to crates.io
run: cargo publish
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -11,17 +11,17 @@ repository = "https://github.com/Mubelotix/meilisearch-sdk"
[dependencies]
serde_json = "1.0"
log = "0.4"
serde = {version="1.0", features=["derive"]}
serde = { version = "1.0", features = ["derive"] }
urlencoding = "1.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
reqwest = "0.10"

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = {version="0.3", features=["RequestInit", "Headers", "Window", "Response", "console"]}
web-sys = { version = "0.3", features = ["RequestInit", "Headers", "Window", "Response", "console"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"

[dev-dependencies]
env_logger = "0.7"
tokio = { version = "0.2", features=["macros"] }
tokio = { version = "0.2", features = ["macros"] }

0 comments on commit d97fa0d

Please sign in to comment.