Skip to content

Commit

Permalink
Improve CI, bump deps (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jun 4, 2024
1 parent 65827a9 commit 8618df2
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 23 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ jobs:
- run: just test
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
- name: Get local and published versions
id: get-versions
run: |
echo "local_version=$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')" >> $GITHUB_OUTPUT
CRATE_NAME=$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/')
PUBLISHED_VERSION=$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')
echo "published_version=${PUBLISHED_VERSION}" >> $GITHUB_OUTPUT
- name: Test that we haven't published current version yet
run: |
LOCAL_VERSION=${{ steps.get-versions.outputs.local_version }}
PUBLISHED_VERSION=${{ steps.get-versions.outputs.published_version }}
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "The current crate version ($LOCAL_VERSION) has already been published."
exit 1
else
echo "The current crate version ($LOCAL_VERSION) has not been published yet."
fi
msrv:
name: Test MSRV
Expand Down Expand Up @@ -170,3 +187,15 @@ jobs:
files: 'target/files/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
name: Publish to crates.io
if: startsWith(github.ref, 'refs/tags/')
needs: [ test, msrv, build, cross-build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlite-hashes"
version = "0.7.1" # This value is also used in the README.md
version = "0.7.2" # This value is also used in the README.md
description = "Hashing functions for SQLite with aggregation support: MD5, SHA1, SHA256, SHA512, FNV-1a, xxHash"
authors = ["Yuri Astrakhan <YuriAstrakhan@gmail.com>"]
repository = "https://github.com/nyurik/sqlite-hashes"
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ fn main() {
}
```

#### Using with SQLx

To use with [SQLx](https://crates.io/crates/sqlx), you need to get the raw handle from the `SqliteConnection` and pass it to the registration function.

```rust,ignore
use sqlx::sqlite::SqliteConnection;
async fn register_functions(sqlx_conn: &SqliteConnection) {
// SAFETY: No query must be performed on `sqlx_conn` until `handle_lock` is dropped.
let mut handle_lock = sqlx_conn.lock_handle().await.unwrap();
let handle = handle_lock.as_raw_handle().as_ptr();
// SAFETY: this is safe as long as handle_lock is valid.
let rusqlite_conn = unsafe { Connection::from_handle(handle) }.unwrap();
// Registration is attached to the connection, not to rusqlite_conn,
// so it will be available for the entire lifetime of the `sqlx_conn`.
// Registration will be automatically dropped when SqliteConnection is dropped.
register_hash_functions(&rusqlite_conn).unwrap();
}
```

## Crate features

By default, this crate will compile with all features. You can enable just the ones you need to reduce compile time and
Expand Down

0 comments on commit 8618df2

Please sign in to comment.