Skip to content

Commit 744b5dd

Browse files
committed
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
1 parent f32b457 commit 744b5dd

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.github/workflows/publish.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish
2+
on:
3+
push: { branches: [master] }
4+
5+
jobs:
6+
publish:
7+
name: Publish
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
- name: Get local crate version
13+
id: local-version
14+
run: cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version' | echo "VERSION=$(cat)" >> "${GITHUB_OUTPUT}"
15+
- name: Get crates.io crate version
16+
id: remote-version
17+
run: curl 'https://index.crates.io/co/lo/colored' | jq -r '.vers' | tail -n 1 | echo "VERSION=$(cat)" >> "${GITHUB_OUTPUT}"
18+
- name: Check if crates.io version is older than local version
19+
id: needs-update
20+
run: |
21+
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
22+
echo "UPDATE=true" >> "${GITHUB_OUTPUT}"
23+
else
24+
echo "UPDATE=false" >> "${GITHUB_OUTPUT}"
25+
fi
26+
- name: Install parse-changelog
27+
if: steps.needs-update.outputs.UPDATE == 'true'
28+
uses: taiki-e/install-action@parse-changelog
29+
- name: Create GitHub release
30+
if: steps.needs-update.outputs.UPDATE == 'true'
31+
run: gh release create "v${{ steps.local-version.outputs.VERSION }}" -n "$(parse-changelog CHANGELOG.md "${{ steps.local-version.outputs.VERSION }}")"
32+
env:
33+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
34+
- name: Publish to crates.io
35+
if: steps.needs-update.outputs.UPDATE == 'true'
36+
run: cargo publish
37+
env:
38+
CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}"

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2.0.1 (July 3, 2023)
2+
- Add edition for future compatibility.
3+
- Implement custom colors that can be stored in a variable.
14

25
# 2.0.0 (July 14, 2020)
36
- Add support for true colours.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "colored"
33
description = "The most simple way to add colors in your terminal"
4-
version = "2.0.0"
4+
version = "2.0.1"
55
edition = "2021"
66
authors = ["Thomas Wickham <mackwic@gmail.com>"]
77
license = "MPL-2.0"

0 commit comments

Comments
 (0)