Skip to content

Commit

Permalink
publish on crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBoot committed Apr 2, 2024
1 parent 2d28672 commit 579c13b
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 29 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/rust-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
name: autokuma-${{ matrix.os }}
path: dist/*

release:
github-release:
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -83,6 +83,11 @@ jobs:
with:
fetch-depth: 0

- name: Install cargo-release
uses: taiki-e/install-action@v2
with:
tool: cargo-release

- name: Parse Changelog
id: changelog
uses: coditory/changelog-parser@v1
Expand All @@ -94,11 +99,35 @@ jobs:
pattern: autokuma-*
merge-multiple: true

- name: Publish to crates.io
shell: bash
run: cargo release --workspace --execute --no-confirm

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ github.ref }}
name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.description }}
files: dist/*

crates-io:
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install cargo-release
uses: taiki-e/install-action@v2
with:
tool: cargo-release

- name: Publish to crates.io
shell: bash
run: cargo release --workspace --execute --no-confirm "${GITHUB_REF_NAME#v}"
16 changes: 8 additions & 8 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ members = ["autokuma", "kuma-cli", "kuma-client"]
resolver = "2"

[workspace.package]
version = "0.0.0"
version = "0.0.3"
edition = "2021"
authors = ["Marco Kirchner <[email protected]>"]
license = "MIT"
repository = "https://github.com/BigBoot/AutoKuma"

[workspace.dependencies]
bollard = { version = "0.16.0" }
Expand All @@ -29,10 +32,10 @@ serde_repr = { version = "0.1.18" }
serde_with = { version = "3.4.0", features = ["time_0_3"] }
serde-inline-default = { version = "0.2.0" }
serde_yaml = { version = "0.9.30" }
shadow-rs = { version = "*" }
shadow-rs = { version = "0.27.1" }
strum = { version = "0.26.1", features = ["derive"] }
thiserror = { version = "1.0.56" }
time = { version = "0.3.31", features = ["serde"] }
tokio = { version = "1.35.1", features = ["full"] }
toml = { version = "0.8.8" }
url = { version = "*", features = ["serde"] }
url = { version = "2.5.0", features = ["serde"] }
7 changes: 6 additions & 1 deletion autokuma/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[package]
name = "autokuma"
description = "Automates the creation of Uptime Kuma monitors based on Docker container labels"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
readme = "../README.md"

[dependencies]
kuma_client = { path = "../kuma-client" }
kuma-client = { path = "../kuma-client", version = "0.0.3" }

bollard = { workspace = true }
config = { workspace = true }
Expand Down
11 changes: 0 additions & 11 deletions example/Cargo.toml

This file was deleted.

7 changes: 6 additions & 1 deletion kuma-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
[package]
name = "kuma-cli"
description = "CLI tool for managing and interacting with Uptime Kuma"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
readme = "../README.md"

[[bin]]
name = "kuma"
path = "src/main.rs"

[dependencies]
kuma_client = { path = "../kuma-client" }
kuma-client = { path = "../kuma-client", version = "0.0.3" }

clap = { workspace = true }
config = { workspace = true }
Expand Down
7 changes: 6 additions & 1 deletion kuma-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[package]
name = "kuma_client"
name = "kuma-client"
description = "Rust wrapper for the Uptime Kuma Socket.IO API"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
readme = "../README.md"

[dependencies]
config = { workspace = true }
Expand Down
80 changes: 78 additions & 2 deletions kuma-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,12 +1058,88 @@ impl Worker {
}

/// A client for interacting with Uptime Kuma.
///
/// Example:
/// ```
/// // Connect to the server
/// let client = Client::connect(Config {
/// url: Url::parse("http://localhost:3001").expect("Invalid URL"),
/// username: Some("Username".to_owned()),
/// password: Some("Password".to_owned()),
/// ..Default::default()
/// })
/// .await
/// .expect("Failed to connect to server");
///
/// // Create a tag
/// let tag_definition = client
/// .add_tag(TagDefinition {
/// name: Some("example_tag".to_owned()),
/// color: Some("red".to_owned()),
/// ..Default::default()
/// })
/// .await
/// .expect("Failed to add tag");
///
/// // Create a group
/// let group = client
/// .add_monitor(MonitorGroup {
/// name: Some("Example Group".to_owned()),
/// tags: vec![Tag {
/// tag_id: tag_definition.tag_id,
/// value: Some("example_group".to_owned()),
/// ..Default::default()
/// }],
/// ..Default::default()
/// })
/// .await
/// .expect("Failed to add group");
///
/// // Createa a notification
/// let notification = client
/// .add_notification(Notification {
/// name: Some("Example Notification".to_owned()),
/// config: Some(serde_json::json!({
/// "webhookURL": "https://webhook.site/304eeaf2-0248-49be-8985-2c86175520ca",
/// "webhookContentType": "json"
/// })),
/// ..Default::default()
/// })
/// .await
/// .expect("Failed to add notification");
///
/// // Create a monitor
/// client
/// .add_monitor(MonitorHttp {
/// name: Some("Monitor Name".to_owned()),
/// url: Some("https://example.com".to_owned()),
/// parent: group.common().id().clone(),
/// tags: vec![Tag {
/// tag_id: tag_definition.tag_id,
/// value: Some("example_monitor".to_owned()),
/// ..Default::default()
/// }],
/// notification_id_list: Some(
/// vec![(
/// notification.id.expect("No notification ID").to_string(),
/// true,
/// )]
/// .into_iter()
/// .collect(),
/// ),
/// ..Default::default()
/// })
/// .await
/// .expect("Failed to add monitor");
///
/// let monitors = client.get_monitors().await.expect("Failed to get monitors");
/// println!("{:?}", monitors);
/// ```
///
pub struct Client {
worker: Arc<Worker>,
}

impl Client {
/// Establishes a connection to Uptime Kuma with the provided configuration.
pub async fn connect(config: Config) -> Result<Client> {
let worker = Worker::new(config);
worker.connect().await?;
Expand Down
Empty file removed kuma.db
Empty file.
2 changes: 2 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
push = false
tag = false

0 comments on commit 579c13b

Please sign in to comment.