From c728e8cbef74682cec835ddc735525dcbcfe42a0 Mon Sep 17 00:00:00 2001 From: Tuxinal <24763016+tuxinal@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:30:32 +0330 Subject: [PATCH] ci: upload to npm upon tag rename to venbind --- .github/workflows/build.yml | 21 ++++++++++----------- .github/workflows/publish.yml | 27 +++++++++++++++++++++++++++ .npmignore | 16 ++++++++++++++++ Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- README.md | 2 +- lib/{venkeybind.d.ts => venbind.d.ts} | 2 +- package.json | 6 +++--- src/errors.rs | 6 +++--- src/linux.rs | 10 +++++----- 10 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .npmignore rename lib/{venkeybind.d.ts => venbind.d.ts} (88%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8bf5eee..d77bd3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,15 +8,13 @@ jobs: strategy: matrix: platform: - # Linux - - name: Linux x86_64 - target: x86_64-unknown-linux-gnu - arch: x64 - os: linux - - name: Linux aarch64 - target: aarch64-unknown-linux-gnu - arch: arm64 + - name: Linux ${{ matrix.arch.name }} + target: ${{ matrix.arch.name }}-unknown-linux-gnu os: linux + output: libvenbind.so + arch: + - name: x86_64 + - name: aarch64 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -33,9 +31,10 @@ jobs: run: | cargo build --release mkdir dist - cp ./target/release/libvenkeybind.so ./dist/venkeybind-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.node + cp ./target/release/${{ matrix.platform.output }} ./dist/venbind-${{ matrix.platform.os }}-${{ matrix.arch.name }}.node - name: Upload uses: actions/upload-artifact@v4 with: - name: ${{ matrix.platform.os }}-${{ matrix.platform.arch }} - path: ./dist/venkeybind-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.node + name: ${{ matrix.platform.os }}-${{ matrix.arch.name }} + path: ./dist/venbind-${{ matrix.platform.os }}-${{ matrix.arch.name }}.node + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..dbab7cc --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +on: + workflow_run: + workflows: [build and upload artifacts] + types: [completed] + push: + tags: + - "*" +name: publish +workflows: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # TODO: check tag and make sure it matches across tag, package.json, and Cargo.toml + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + - name: Download artifacts + uses: actions/download-artifacts@v4 + with: + path: prebuilds + - name: Publish to npm + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..52a0f7b --- /dev/null +++ b/.npmignore @@ -0,0 +1,16 @@ +/target +/dist +# Devenv +.devenv* +devenv* +devenv.local.nix + +# direnv +.direnv +.envrc + +# pre-commit +.pre-commit-config.yaml + +.gitignore +.github \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index a6ab47e..9dd7093 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1984,8 +1984,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] -name = "venkeybind" -version = "0.1.0" +name = "venbind" +version = "0.0.1" dependencies = [ "ashpd", "node-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 84d2124..c1398ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "venkeybind" -version = "0.1.0" +name = "venbind" +version = "0.0.1" edition = "2021" [lib] diff --git a/README.md b/README.md index 6dea054..176c5df 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Venkeybind +# Venbind An all-in-one library made to handle shortcuts globally across multiple operating systems and desktops diff --git a/lib/venkeybind.d.ts b/lib/venbind.d.ts similarity index 88% rename from lib/venkeybind.d.ts rename to lib/venbind.d.ts index 90de3d1..0628948 100644 --- a/lib/venkeybind.d.ts +++ b/lib/venbind.d.ts @@ -1,4 +1,4 @@ -export class Venkeybind { +export class Venbind { startKeybinds(window_id: BigInt | null, callback: (x: number) => void): Promise; registerKeybind(keybind: string, keybindId: number): void; unregisterKeybind(keybindId: number): void; diff --git a/package.json b/package.json index ce1c497..8f36fb0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "venkeybind", - "version": "1.0.0", + "name": "venbind", + "version": "0.0.1", "description": "", - "types": "./lib/venkeybind.d.ts", + "types": "./lib/venbind.d.ts", "scripts": {}, "keywords": [], "author": "Tuxinal" diff --git a/src/errors.rs b/src/errors.rs index f878a43..12bad99 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,11 +1,11 @@ use thiserror::Error; -pub type Result = std::result::Result; +pub type Result = std::result::Result; #[derive(Debug, Error)] -pub enum VenkeybindError { +pub enum VenbindError { #[error("Something went wrong with libuiohook")] // TODO: better log LibUIOHookError, #[error("{0}")] Message(String) -} \ No newline at end of file +} diff --git a/src/linux.rs b/src/linux.rs index cb9fe54..fe1418a 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -10,7 +10,7 @@ use uiohook_sys::{ use xcb::Extension; use xkbcommon::xkb::{self, State}; -use crate::errors::{Result, VenkeybindError}; +use crate::errors::{Result, VenbindError}; use crate::structs::{Keybind, KeybindId, KeybindTrigger, Keybinds}; use crate::utils; @@ -27,7 +27,7 @@ pub(crate) fn start_keybinds_internal( ) -> Result<()> { TX.set(tx).unwrap(); if utils::is_wayland() { - return Err(VenkeybindError::Message("todo".to_owned())); + return Err(VenbindError::Message("todo".to_owned())); } let (connection, _screen) = xcb::Connection::connect_with_extensions(None, &[Extension::Xkb], &[]).unwrap(); @@ -57,7 +57,7 @@ pub(crate) fn start_keybinds_internal( unsafe { hook_set_dispatch_proc(Some(dispatch_proc)); if hook_run() != UIOHOOK_SUCCESS as i32 { - return Err(VenkeybindError::LibUIOHookError); + return Err(VenbindError::LibUIOHookError); } }; Ok(()) @@ -94,7 +94,7 @@ pub unsafe extern "C" fn dispatch_proc(event_ref: *mut _uiohook_event) { pub(crate) fn register_keybind_internal(keybind: String, id: KeybindId) -> Result<()> { if utils::is_wayland() { - return Err(VenkeybindError::Message("todo".to_owned())); + return Err(VenbindError::Message("todo".to_owned())); } let keybind = Keybind::from_string(keybind); let mut keybinds = KEYBINDS.lock().unwrap(); @@ -103,7 +103,7 @@ pub(crate) fn register_keybind_internal(keybind: String, id: KeybindId) -> Resul } pub(crate) fn unregister_keybind_internal(id: KeybindId) -> Result<()> { if utils::is_wayland() { - return Err(VenkeybindError::Message("todo".to_owned())); + return Err(VenbindError::Message("todo".to_owned())); } let mut keybinds = KEYBINDS.lock().unwrap(); keybinds.unregister_keybind(id);