diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0555741 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: Publish +on: + push: + branches: [master] +permissions: + contents: write + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Get local crate version + id: local-version + run: cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version' | echo "VERSION=$(cat)" >> "${GITHUB_OUTPUT}" + - name: Get crates.io crate version + id: remote-version + run: curl 'https://index.crates.io/co/lo/colored' | jq -r '.vers' | tail -n 1 | echo "VERSION=$(cat)" >> "${GITHUB_OUTPUT}" + - name: Check if crates.io version is older than local version + id: needs-update + run: | + if ! printf '%s\n' "${{ steps.local-version.outputs.VERSION }}" "${{ steps.remote-version.outputs.VERSION }}" | sort -V | tail -n 1 | grep -Fw "${{ steps.remote-version.outputs.VERSION }}"; then + echo "UPDATE=true" >> "${GITHUB_OUTPUT}" + else + echo "UPDATE=false" >> "${GITHUB_OUTPUT}" + fi + - name: Install parse-changelog + if: steps.needs-update.outputs.UPDATE == 'true' + uses: taiki-e/install-action@parse-changelog + - name: Create GitHub release + if: steps.needs-update.outputs.UPDATE == 'true' + run: gh release create "v${{ steps.local-version.outputs.VERSION }}" -t "v${{ steps.local-version.outputs.VERSION }}" -n "$(parse-changelog CHANGELOG.md "${{ steps.local-version.outputs.VERSION }}")" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Publish to crates.io + if: steps.needs-update.outputs.UPDATE == 'true' + run: cargo publish + env: + CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f0c84d0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: Run tests +on: pull_request +env: { CLICOLOR_FORCE: 1 } + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Run formatting checks + run: cargo fmt --check + - name: Run clippy checks + run: cargo clippy --all-features -- -D warnings + - name: Run tests + run: cargo test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9062dfe..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: rust - -rust: - - nightly - - beta - - stable - -cache: cargo - -before_script: - - rustup component add clippy - -script: - - cargo test --verbose - - cargo clippy -- -Dwarnings - -matrix: - allow_failures: - - rust: nightly diff --git a/CHANGELOG.md b/CHANGELOG.md index f74427e..13c8690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.0.1 (July 3, 2023) +- Add edition for future compatibility. +- Implement custom colors that can be stored in a variable. # 2.0.0 (July 14, 2020) - Add support for true colours. diff --git a/Cargo.toml b/Cargo.toml index cdd3062..2475106 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "colored" description = "The most simple way to add colors in your terminal" -version = "2.0.0" +version = "2.0.1" edition = "2021" authors = ["Thomas Wickham "] license = "MPL-2.0" diff --git a/README.md b/README.md index 8c4a71c..55abc61 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Colored -[![Build -Status](https://travis-ci.org/mackwic/colored.svg?branch=master)](https://travis-ci.org/mackwic/colored) [![Crates.io](https://img.shields.io/crates/v/colored.svg?maxAge=2592000)](https://crates.io/crates/colored) [![Crates.io](https://img.shields.io/crates/l/colored.svg?maxAge=2592000)](https://github.com/mackwic/colored/blob/master/LICENSE) +[![Crates.io](https://img.shields.io/crates/v/colored.svg?maxAge=2592000)](https://crates.io/crates/colored) [![Crates.io](https://img.shields.io/crates/l/colored.svg?maxAge=2592000)](https://github.com/mackwic/colored/blob/master/LICENSE) Coloring terminal so simple, you already know how to do it! @@ -127,25 +126,6 @@ dumb_terminal = ["colored/no-color"] You can use have even finer control by using the `colored::control::set_override` method. -## Build with Docker - -### Install Docker - -Use the install instructions located [here](https://docs.docker.com/v17.12/install/) - -### Build the Docker image - -```docker build -t colored_image .``` - -### Build the library - -```docker run --rm -it -v "$PWD":/src -u `id -u`:`id -g` colored_image /bin/bash -c "cargo build"``` - -### Test the library - -```docker run --rm -it -v "$PWD":/src -u `id -u`:`id -g` colored_image /bin/bash -c "cargo test"``` - - ## Todo - **More tests ?**: We always welcome more tests! Please contribute! @@ -175,6 +155,7 @@ In non legal terms it means that: ## Contributors - Thomas Wickham: [@mackwic](https://github.com/mackwic) +- Hunter Wittenborn [@hwittenborn](https://github.com/hwittenborn) - Corey "See More" Richardson: [@cmr](https://github.com/cmr) - Iban Eguia: [@Razican](https://github.com/Razican) - Alexis "Horgix" Chotard: [@horgix](https://github.com/horgix) diff --git a/src/lib.rs b/src/lib.rs index 308992e..a29b328 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -325,10 +325,8 @@ pub trait Colorize { fn italic(self) -> ColoredString; fn underline(self) -> ColoredString; fn blink(self) -> ColoredString; - /// Historical name of `Colorize::reversed`. May be removed in a future version. Please use - /// `Colorize::reversed` instead + #[deprecated(since = "1.5.2", note = "Users should use reversed instead")] fn reverse(self) -> ColoredString; - /// This should be preferred to `Colorize::reverse`. fn reversed(self) -> ColoredString; fn hidden(self) -> ColoredString; fn strikethrough(self) -> ColoredString; diff --git a/src/style.rs b/src/style.rs index bf97acc..8588554 100644 --- a/src/style.rs +++ b/src/style.rs @@ -75,7 +75,7 @@ impl Styles { let res: Vec = STYLES .iter() - .filter(|&&(ref mask, _)| (0 != (u & mask))) + .filter(|&(mask, _)| (0 != (u & mask))) .map(|&(_, value)| value) .collect(); if res.is_empty() {