From ba2f9585e80de6155c3d6634e4512693005ecb48 Mon Sep 17 00:00:00 2001 From: pwnwriter Date: Wed, 18 Oct 2023 10:54:17 +0545 Subject: [PATCH 1/4] feat(ci,profiles): use github actions to release automated binaries // cargo profiles to test,bench,release binaries --- .github/workflows/release.yml | 93 +++++++++++++++++++++++++++++++++++ Cargo.toml | 20 ++++++++ 2 files changed, 113 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e44e97fa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,93 @@ +name: Continuous Deployment + +on: + push: + tags: + - "v*.*.*" + +jobs: + publish-github: + name: Publish on GitHub + runs-on: ${{ matrix.config.OS }} + strategy: + fail-fast: false + matrix: + config: + - { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-gnu" } + - { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-musl" } + - { OS: ubuntu-latest, TARGET: "i686-unknown-linux-gnu" } + - { OS: ubuntu-latest, TARGET: "i686-unknown-linux-musl" } + - { OS: ubuntu-latest, TARGET: "armv5te-unknown-linux-gnueabi" } + - { OS: ubuntu-latest, TARGET: "armv7-unknown-linux-gnueabihf" } + - { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-gnu" } + - { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-musl" } + - { OS: macos-latest, TARGET: "x86_64-apple-darwin" } + - { OS: macos-latest, TARGET: "aarch64-apple-darwin" } + - { OS: windows-latest, TARGET: "x86_64-pc-windows-msvc" } + - { OS: windows-latest, TARGET: "i686-pc-windows-msvc" } + + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Set the release version + shell: bash + run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.config.TARGET }} + override: true + + - name: Build + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --release --locked --target ${{ matrix.config.TARGET }} + + - name: Prepare release assets + shell: bash + run: | + mkdir release/ + cp {LICENSE,README.md} release/ + cp target/${{ matrix.config.TARGET }}/release/presenterm release/ + mv release/ presenterm-${{ env.RELEASE_VERSION }}/ + + - name: Create release artifacts + shell: bash + run: | + if [ "${{ matrix.config.OS }}" = "windows-latest" ]; then + 7z a -tzip "presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.zip" \ + presenterm-${{ env.RELEASE_VERSION }} + else + tar -czvf presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \ + presenterm-${{ env.RELEASE_VERSION }}/ + shasum -a 512 presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \ + > presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz.sha512 + fi + + - name: Upload the release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.* + file_glob: true + overwrite: true + tag: ${{ github.ref }} + + publish-crates-io: + name: Publish on crates.io + needs: publish-github + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Publish + uses: actions-rs/cargo@v1 + with: + command: publish + args: --locked --token ${{ secrets.CARGO_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index e64cece4..38679540 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,23 @@ rstest = { version = "0.18", default-features = false } [features] default = [] sixel = ["viuer/sixel"] + +[profile.dev] +opt-level = 0 +debug = true +panic = "abort" + +[profile.test] +opt-level = 0 +debug = true + +[profile.release] +opt-level = 3 +debug = false +panic = "unwind" +lto = true +codegen-units = 1 + +[profile.bench] +opt-level = 3 +debug = false From 6a47b3e4b361d20c8ab461a4c7bc70b94b4bda9c Mon Sep 17 00:00:00 2001 From: pwnwriter Date: Wed, 18 Oct 2023 10:55:55 +0545 Subject: [PATCH 2/4] feat(releaser): script to ease releasing process --- .github/releaser.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 .github/releaser.sh diff --git a/.github/releaser.sh b/.github/releaser.sh new file mode 100755 index 00000000..5969db8e --- /dev/null +++ b/.github/releaser.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Trigger release action on new release + +if [ -z "$1" ]; then + echo "Please provide a version number." + echo "Usages: $0 v[X.Y.Z]" + exit 1 +fi + +version=$1 + +git tag "v$version" +git push origin "v$version" From f636302c543e9bacf01adb41df03c9e1ab4a80fe Mon Sep 17 00:00:00 2001 From: pwnwriter Date: Wed, 18 Oct 2023 14:20:24 +0545 Subject: [PATCH 3/4] feat(splash): show splashes if no args were provided --- Cargo.lock | 23 +++++++++++++++++++++++ Cargo.toml | 1 + src/lib.rs | 1 + src/main.rs | 3 +++ src/splash.rs | 19 +++++++++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 src/splash.rs diff --git a/Cargo.lock b/Cargo.lock index 896ff90a..6dede33d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,6 +230,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" +dependencies = [ + "is-terminal", + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "comrak" version = "0.19.0" @@ -719,6 +730,17 @@ dependencies = [ "serde", ] +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "itoa" version = "1.0.9" @@ -1009,6 +1031,7 @@ name = "presenterm" version = "0.2.0" dependencies = [ "clap", + "colored", "comrak", "crossterm", "hex", diff --git a/Cargo.toml b/Cargo.toml index 38679540..7a6e5d97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ strum = { version = "0.25", features = ["derive"] } thiserror = "1" unicode-width = "0.1" viuer = "0.7.1" +colored = "2.0.4" [dev-dependencies] rstest = { version = "0.18", default-features = false } diff --git a/src/lib.rs b/src/lib.rs index 729ce090..d7e10b47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,3 +12,4 @@ pub mod render; pub mod resource; pub mod style; pub mod theme; +pub mod splash; diff --git a/src/main.rs b/src/main.rs index 0af6e304..c60d748e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,12 +6,15 @@ use presenterm::{ presenter::{PresentMode, Presenter}, render::highlighting::CodeHighlighter, resource::Resources, + splash::show_splashes, theme::PresentationTheme, }; use std::path::{Path, PathBuf}; /// Run slideshows from your terminal. #[derive(Parser)] +#[command()] +#[command(author, version, about = show_splashes(), long_about = show_splashes(), arg_required_else_help = true)] struct Cli { /// The path to the markdown file that contains the presentation. path: PathBuf, diff --git a/src/splash.rs b/src/splash.rs new file mode 100644 index 00000000..ff27a387 --- /dev/null +++ b/src/splash.rs @@ -0,0 +1,19 @@ +use colored::Colorize; + +pub fn show_splashes() -> String { + let crate_version = env!("CARGO_PKG_VERSION"); + + let logo = format!( + r#" + ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐┬─┐┌┬┐ + ├─┘├┬┘├┤ └─┐├┤ │││ │ ├┤ ├┬┘│││ + ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘┴└─┴ ┴ v{} + A terminal slideshow tool + @mfontanini/presenterm +"#, + crate_version, + ) + .bold() + .purple(); + format!("{logo}") +} From 7dcfcc7924cb4619751a857cd2db3227d02b033e Mon Sep 17 00:00:00 2001 From: pwnwriter Date: Wed, 18 Oct 2023 14:32:52 +0545 Subject: [PATCH 4/4] chore(clap-deps):use string feature to display splashes --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7a6e5d97..b352899a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ version = "0.2.0" edition = "2021" [dependencies] -clap = { version = "4.4", features = ["derive"] } +clap = { version = "4.4", features = ["derive", "string"] } comrak = { version = "0.19", default-features = false } crossterm = { version = "0.27", features = ["serde"] } hex = "0.4"