Skip to content

Commit 1921f20

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 1921f20

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

.github/workflows/publish.yml

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

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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 <[email protected]>"]
77
license = "MPL-2.0"

0 commit comments

Comments
 (0)