diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c90a845 --- /dev/null +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..227a223 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 6985cf1..841ac03 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/Cargo.lock b/Cargo.lock index cd39af0..a21db29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -179,9 +179,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.7" +version = "4.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" dependencies = [ "clap_builder", "clap_derive", @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" dependencies = [ "anstream", "anstyle", @@ -199,6 +199,35 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_complete" +version = "4.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" +dependencies = [ + "clap", +] + +[[package]] +name = "clap_complete_fig" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e571d70e22ec91d34e1c5317c8308035a2280d925167646bf094fc5de1737c" +dependencies = [ + "clap", + "clap_complete", +] + +[[package]] +name = "clap_complete_nushell" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "948bf70d7e1f179635d3ef819ce8baa2d3074d0d57816ac37387cd6f9eed0c31" +dependencies = [ + "clap", + "clap_complete", +] + [[package]] name = "clap_derive" version = "4.4.7" @@ -1114,6 +1143,9 @@ version = "0.8.0" dependencies = [ "anyhow", "clap", + "clap_complete", + "clap_complete_fig", + "clap_complete_nushell", "gdk-pixbuf", "pangocairo", "relm4", diff --git a/Cargo.toml b/Cargo.toml index ac0db87..9e0bc25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,41 +4,55 @@ version = "0.8.0" edition = "2021" authors = ["Matthias Gabriel "] 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" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..3be231c --- /dev/null +++ b/build.rs @@ -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(()) +}