From 4a97b075dd807899ac0212e4929d2f0bcc19ec15 Mon Sep 17 00:00:00 2001 From: Sven Assmann Date: Thu, 3 Feb 2022 22:19:15 +0100 Subject: [PATCH] chore(deps): bump dependencies + clap3 migration (#101) * feat(deb): migrate to prebuild deb builder * chore(deps): bump dependencies + clap3 migration * feat(ci): decouple artifacts building from deployment --- .deb/Dockerfile | 3 - .deb/Makefile | 5 +- .github/workflows/build.yml | 3 +- .github/workflows/deploy.yml | 23 --- .github/workflows/release-binary-assets.yml | 102 +++++++++++ Cargo.lock | 193 ++++++++------------ Cargo.toml | 16 +- src/cli.rs | 44 ++--- src/common/utils.rs | 2 +- 9 files changed, 215 insertions(+), 176 deletions(-) delete mode 100644 .deb/Dockerfile create mode 100644 .github/workflows/release-binary-assets.yml diff --git a/.deb/Dockerfile b/.deb/Dockerfile deleted file mode 100644 index e6f975f..0000000 --- a/.deb/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM rust:latest - -RUN cargo install cargo-deb diff --git a/.deb/Makefile b/.deb/Makefile index 2f3f39d..4300099 100644 --- a/.deb/Makefile +++ b/.deb/Makefile @@ -1,4 +1,5 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) deb: - docker build -t rust-deb-build - < ${ROOT_DIR}/Dockerfile - docker run --rm -it -v ${ROOT_DIR}/..:/usr/src/app -w /usr/src/app rust-deb-build cargo deb \ No newline at end of file + docker run --rm -v ${ROOT_DIR}/..:/usr/src/app \ + -w /usr/src/app \ + 5422m4n/rust-deb-builder:1.57.0 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1f6d4d..3eeeb24 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,7 +66,6 @@ jobs: strategy: fail-fast: false matrix: -# version: [ 'macos-11.0', 'macos-10.15', 'macos-10.14', 'ubuntu-latest'] version: [ 'macos-latest', 'ubuntu-latest'] rust: [ nightly, stable ] runs-on: ${{ matrix.version }} @@ -84,7 +83,7 @@ jobs: run: cargo test --all --locked -- -Z unstable-options pkg-deb: - name: binaray package .deb + name: binary package .deb needs: check runs-on: ubuntu-latest steps: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cd24170..6f4627e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,26 +67,3 @@ jobs: body: ${{ steps.changelog_reader.outputs.changes }} prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }} draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }} - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - # https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: target/x86_64-unknown-linux-musl/debian/t-rec*.deb - asset_name: t-rec-${{ steps.tag_name.outputs.current_version }}-amd64-static.deb - asset_content_type: application/vnd.debian.binary-package - - # https://github.com/mislav/bump-homebrew-formula-action - publish-to-brew: - name: post / homebrew - needs: publish - runs-on: macos-latest - steps: - - uses: mislav/bump-homebrew-formula-action@v1 - with: - formula-name: t-rec - env: - COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-binary-assets.yml b/.github/workflows/release-binary-assets.yml new file mode 100644 index 0000000..a94df59 --- /dev/null +++ b/.github/workflows/release-binary-assets.yml @@ -0,0 +1,102 @@ +name: Release Binary Assets +on: + release: + types: + - published +jobs: + # https://github.com/mislav/bump-homebrew-formula-action + publish-to-brew: + name: post / homebrew + runs-on: macos-latest + steps: + - uses: mislav/bump-homebrew-formula-action@v1 + with: + formula-name: t-rec + env: + COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} + + release: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + cross: true + binName: t-rec + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + cross: true + binName: t-rec + - target: x86_64-apple-darwin + os: macos-latest + cross: false + binName: t-rec + steps: + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + - uses: Swatinem/rust-cache@v1 + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + use-cross: ${{ matrix.cross }} + args: --release --target=${{ matrix.target }} + - name: Smoke Test + uses: actions-rs/cargo@v1 + with: + command: run + use-cross: ${{ matrix.cross }} + args: --release --target=${{ matrix.target }} -- --help + - name: Create Archive + id: archive + shell: bash + env: + TARGET: ${{ matrix.target }} + TAG: ${{ github.event.release.tag_name }} + run: | + filename="t-rec-$TAG-$TARGET.tar.gz" + tar -czvf "$filename" README.md LICENSE -C "target/$TARGET/release" "${{ matrix.binName }}" + echo "::set-output name=filename::$filename" + - name: Upload Archive + uses: ncipollo/release-action@v1.8.7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + allowUpdates: true + artifactErrorsFailBuild: true + artifacts: ${{ steps.archive.outputs.filename }} + artifactContentType: application/octet-stream + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + omitPrereleaseDuringUpdate: true + + pkg-deb: + name: binary package .deb + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: build .deb file + uses: sassman/rust-deb-builder@v1.57.0 + - name: Archive deb artifact + uses: actions/upload-artifact@v2 + with: + name: t-rec-amd64-static.deb + path: target/x86_64-unknown-linux-musl/debian/t-rec*.deb + - name: upload deb file + uses: ncipollo/release-action@v1.8.7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + allowUpdates: true + artifactErrorsFailBuild: true + artifacts: target/x86_64-unknown-linux-musl/debian/t-rec*.deb + artifactContentType: application/octet-stream + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + omitPrereleaseDuringUpdate: true + diff --git a/Cargo.lock b/Cargo.lock index 49f84f8..188fec1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,20 +23,11 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" -version = "1.0.52" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" +checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" [[package]] name = "atty" @@ -57,9 +48,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block" @@ -93,17 +84,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.34.0" +version = "3.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "b63edc3f163b3c71ec8aa23f9bd6070f77edbf3d1d198b164afa90ff00e4ec62" dependencies = [ - "ansi_term", "atty", "bitflags", + "indexmap", + "lazy_static", + "os_str_bytes", "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", ] [[package]] @@ -155,18 +147,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ "cfg-if", "crossbeam-utils", @@ -185,9 +177,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762" dependencies = [ "cfg-if", "crossbeam-utils", @@ -198,9 +190,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ "cfg-if", "lazy_static", @@ -235,6 +227,15 @@ dependencies = [ "termcolor", ] +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -252,25 +253,14 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "gethostname" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028" +checksum = "4addc164932852d066774c405dbbdb7914742d2b39e39e1a7ca949c856d054d1" dependencies = [ "libc", "winapi", ] -[[package]] -name = "getrandom" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "gif" version = "0.11.3" @@ -281,6 +271,12 @@ dependencies = [ "weezl", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -315,6 +311,25 @@ dependencies = [ "tiff", ] +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "jpeg-decoder" version = "0.1.22" @@ -332,9 +347,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "log" @@ -390,9 +405,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" dependencies = [ "bitflags", "cc", @@ -481,6 +496,15 @@ dependencies = [ "objc", ] +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] + [[package]] name = "png" version = "0.16.8" @@ -493,52 +517,6 @@ dependencies = [ "miniz_oxide 0.3.7", ] -[[package]] -name = "ppv-lite86" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" - -[[package]] -name = "rand" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core", -] - [[package]] name = "rayon" version = "1.5.1" @@ -622,13 +600,13 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "t-rec" -version = "0.6.2" +version = "0.6.3" dependencies = [ "anyhow", "clap", @@ -649,13 +627,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", "winapi", @@ -672,12 +650,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.11.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" [[package]] name = "tiff" @@ -690,24 +665,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - [[package]] name = "weezl" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index 24b3b3c..07bc74e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "t-rec" -version = "0.6.2" +version = "0.6.3" authors = ["Sven Assmann "] edition = "2018" license = "GPL-3.0-only" @@ -19,16 +19,22 @@ github-actions = { repository = "sassman/t-rec-rs", branch = "main", workflow = maintenance = { status = "actively-developed" } [dependencies] -clap = "2.34.0" -image = { version = "0.23.14", features = ["tga"] } -anyhow = "1.0.52" -tempfile = "3.2.0" +anyhow = "1.0.53" +tempfile = "3.3.0" rayon = "1.5.1" log = "0.4.14" env_logger = "0.9.0" simplerand = "1.3.0" humantime = "2.1.0" +[dependencies.clap] +version = "3.0.14" +features = ["cargo"] + +[dependencies.image] +version = "0.23.14" +features = ["tga"] + [target.'cfg(target_os = "macos")'.dependencies] objc_id = "0.1.1" objc-foundation = "0.1.1" diff --git a/src/cli.rs b/src/cli.rs index a31c2b3..6622645 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,101 +1,101 @@ use clap::{crate_authors, crate_description, crate_version, App, AppSettings, Arg, ArgMatches}; -pub fn launch<'a>() -> ArgMatches<'a> { +pub fn launch() -> ArgMatches { App::new("t-rec") .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .setting(AppSettings::AllowMissingPositional) .arg( - Arg::with_name("verbose") + Arg::new("verbose") .takes_value(false) - .short("v") + .short('v') .long("verbose") .required(false) .help("Enable verbose insights for the curious") ) - .arg(Arg::with_name("quiet") + .arg(Arg::new("quiet") .takes_value(false) - .short("q") + .short('q') .long("quiet") .required(false) .help("Quiet mode, suppresses the banner: 'Press Ctrl+D to end recording'") ) .arg( - Arg::with_name("video") + Arg::new("video") .takes_value(false) - .short("m") + .short('m') .long("video") .required(false) .help("Generates additionally to the gif a mp4 video of the recording") ) .arg( - Arg::with_name("video-only") + Arg::new("video-only") .takes_value(false) - .short("M") + .short('M') .long("video-only") .required(false) .conflicts_with("video") .help("Generates only a mp4 video and not gif") ) .arg( - Arg::with_name("decor") + Arg::new("decor") .takes_value(true) .possible_values(&["shadow", "none"]) .default_value("shadow") .required(false) - .short("d") + .short('d') .long("decor") .help("Decorates the animation with certain, mostly border effects") ) .arg( - Arg::with_name("bg") + Arg::new("bg") .takes_value(true) .possible_values(&["white", "black", "transparent"]) .default_value("transparent") .required(false) - .short("b") + .short('b') .long("bg") .help("Background color when decors are used") ) .arg( - Arg::with_name("natural-mode") + Arg::new("natural-mode") .value_name("natural") .takes_value(false) .required(false) - .short("n") + .short('n') .long("natural") .help("If you want a very natural typing experience and disable the idle detection and sampling optimization") ) .arg( - Arg::with_name("list-windows") + Arg::new("list-windows") .value_name("list all visible windows with name and id") .takes_value(false) .required(false) - .short("l") + .short('l') .long("ls-win") .help("If you want to see a list of windows available for recording by their id, you can set env var 'WINDOWID' to record this specific window only"), ) .arg( - Arg::with_name("end-pause") + Arg::new("end-pause") .value_name("s | ms | m") .takes_value(true) .required(false) - .short("e") + .short('e') .long("end-pause") .help("to specify the pause time at the end of the animation, that time the gif will show the last frame"), ) .arg( - Arg::with_name("start-pause") + Arg::new("start-pause") .value_name("s | ms | m") .takes_value(true) .required(false) - .short("s") + .short('s') .long("start-pause") .help("to specify the pause time at the start of the animation, that time the gif will show the first frame"), ) .arg( - Arg::with_name("program") + Arg::new("program") .value_name("shell or program to launch") .takes_value(true) .required(false) diff --git a/src/common/utils.rs b/src/common/utils.rs index bb644df..4e30e5a 100644 --- a/src/common/utils.rs +++ b/src/common/utils.rs @@ -22,7 +22,7 @@ impl HumanReadable for Duration { prefix = "~"; less = less.add(Duration::from_millis(1)) } - format!("{}{}", prefix, format_duration(less).to_string()) + format!("{}{}", prefix, format_duration(less)) } } }