Skip to content

Commit

Permalink
Merge pull request #24 from TD-Sky/completions
Browse files Browse the repository at this point in the history
Generate completions and CI/CD
  • Loading branch information
gabm authored Dec 4, 2023
2 parents b649271 + 43aef11 commit 891b4e9
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 28 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: lint

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --check
env:
RUSTFLAGS: "-Dwarnings"

lint:
runs-on: ubuntu-latest
container:
image: ghcr.io/gtk-rs/gtk4-rs/gtk4:latest
steps:
- name: Install dependencies
run: yum install -y gtk4-devel libadwaita-devel
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
components: clippy
- uses: Swatinem/rust-cache@v2
- run: |
cargo clippy --all-features --all-targets \
-- -D warnings
doc:
runs-on: ubuntu-latest
container:
image: ghcr.io/gtk-rs/gtk4-rs/gtk4:latest
steps:
- name: Install dependencies
run: yum install -y gtk4-devel libadwaita-devel
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-deadlinks
- run: cargo deadlinks
- run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: -Dwarnings
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

env:
CARGO_TERM_COLOR: always

jobs:
release:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz

runs-on: ${{ matrix.os }}
container:
image: ghcr.io/gtk-rs/gtk4-rs/gtk4:latest

steps:
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: yum install -y gtk4-devel libadwaita-devel

- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2

- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}

- name: Pack Artifacts
if: matrix.os == 'ubuntu-latest'
env:
RELEASE_NAME: satty-${{ matrix.target }}
ARTIFACTS_DIR: target/${{ matrix.target }}/release
run: |
mkdir $RELEASE_NAME
cp target/${{ matrix.target }}/release/satty -t $RELEASE_NAME
cp -r completions -t $RELEASE_NAME
cp -r README.md assets LICENSE satty.desktop -t $RELEASE_NAME
tar -zcvf $RELEASE_NAME.${{ matrix.archive }} -C $RELEASE_NAME .
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: satty-${{ matrix.target }}.${{ matrix.archive }}
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Completion scripts
completions/
40 changes: 36 additions & 4 deletions Cargo.lock

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

54 changes: 34 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,55 @@ version = "0.8.0"
edition = "2021"
authors = ["Matthias Gabriel <[email protected]>"]
description = "A screenshot annotation tool inspired by Swappy and Flameshot."
homepage ="https://github.com/gabm/satty"
repository ="https://github.com/gabm/satty"
homepage = "https://github.com/gabm/satty"
repository = "https://github.com/gabm/satty"
license = "MPL-2.0"
include = [
"src/**/*",
"Cargo.toml",
"Cargo.lock",
"LICENSE*",
"README.md",
"assets/",
]


[dependencies]
relm4 = { version = "0.6.2", features = ["macros", "libadwaita", "gnome_44"] }
pangocairo = "0.17.10"
tokio = { version = "1.32.0", features = ["full"]}
tokio = { version = "1.32.0", features = ["full"] }
gdk-pixbuf = "0.17.2"

# error handling
anyhow = "1.0"

# command line
clap = { version = "4.4.4", features = ["derive"] }
clap = { version = "4.4.10", features = ["derive"] }


[dependencies.relm4-icons]
version = "0.6.0"
features = [
"pen-regular",
"color-regular",
"cursor-regular",
"number-circle-1-regular",
"drop-regular",
"arrow-redo-filled",
"arrow-undo-filled",
"save-regular",
"copy-regular",
"text-case-title-regular",
"text-font-regular",
"minus-large",
"checkbox-unchecked-regular",
"crop-filled",
"arrow-up-right-filled",
"rectangle-landscape-regular"
"pen-regular",
"color-regular",
"cursor-regular",
"number-circle-1-regular",
"drop-regular",
"arrow-redo-filled",
"arrow-undo-filled",
"save-regular",
"copy-regular",
"text-case-title-regular",
"text-font-regular",
"minus-large",
"checkbox-unchecked-regular",
"crop-filled",
"arrow-up-right-filled",
"rectangle-landscape-regular",
]

[build-dependencies]
clap = { version = "4.4.10", features = ["derive"] }
clap_complete = "4.4.4"
clap_complete_nushell = "4.4.2"
clap_complete_fig = "4.4.2"
27 changes: 27 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#[allow(dead_code)]
#[path = "src/command_line.rs"]
mod command_line;

use std::fs;
use std::io;

use clap::CommandFactory;
use clap_complete::{generate_to, Shell};
use clap_complete_fig::Fig;
use clap_complete_nushell::Nushell;

fn main() -> Result<(), io::Error> {
let cmd = &mut command_line::CommandLine::command();
let bin = "satty";
let out = "completions";

fs::create_dir_all(out)?;
generate_to(Shell::Bash, cmd, bin, out)?;
generate_to(Shell::Fish, cmd, bin, out)?;
generate_to(Shell::Zsh, cmd, bin, out)?;
generate_to(Shell::Elvish, cmd, bin, out)?;
generate_to(Nushell, cmd, bin, out)?;
generate_to(Fig, cmd, bin, out)?;

Ok(())
}

0 comments on commit 891b4e9

Please sign in to comment.