Skip to content

Commit

Permalink
ci: upload to npm upon tag
Browse files Browse the repository at this point in the history
rename to venbind
  • Loading branch information
tuxinal committed Aug 15, 2024
1 parent c9bb8c8 commit c728e8c
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 28 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/target
/dist
# Devenv
.devenv*
devenv*
devenv.local.nix

# direnv
.direnv
.envrc

# pre-commit
.pre-commit-config.yaml

.gitignore
.github
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "venkeybind"
version = "0.1.0"
name = "venbind"
version = "0.0.1"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Venkeybind
# Venbind

An all-in-one library made to handle shortcuts globally across multiple operating systems and desktops

Expand Down
2 changes: 1 addition & 1 deletion lib/venkeybind.d.ts → lib/venbind.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class Venkeybind {
export class Venbind {
startKeybinds(window_id: BigInt | null, callback: (x: number) => void): Promise<void>;
registerKeybind(keybind: string, keybindId: number): void;
unregisterKeybind(keybindId: number): void;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use thiserror::Error;

pub type Result<T> = std::result::Result<T, VenkeybindError>;
pub type Result<T> = std::result::Result<T, VenbindError>;

#[derive(Debug, Error)]
pub enum VenkeybindError {
pub enum VenbindError {
#[error("Something went wrong with libuiohook")] // TODO: better log
LibUIOHookError,
#[error("{0}")]
Message(String)
}
}
10 changes: 5 additions & 5 deletions src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit c728e8c

Please sign in to comment.