From 744b5dd5a1cefeedebe153e60837d83b399181bf Mon Sep 17 00:00:00 2001 From: Hunter Wittenborn Date: Mon, 3 Jul 2023 06:28:57 -0500 Subject: [PATCH] Add CI for releases (#138) * Add CI for releases * Release '2.0.1' * Add missing environment variable to GitHub CLI call * Don't install parse-changelog if no release is being made --- .github/workflows/publish.yml | 38 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 3 +++ Cargo.toml | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8f4be35 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Publish +on: + push: { branches: [master] } + +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 }}" -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/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 170c690..94d3f78 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"