Skip to content

Commit 2d864eb

Browse files
authored
Release v0.1.0
2 parents b0716c2 + 209660a commit 2d864eb

9 files changed

Lines changed: 194 additions & 5 deletions

File tree

.github/labels.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
description: This PR is ready to be merged
8787
color: "0ff40b"
8888

89+
- name: 🔄 Release preparation
90+
description: Preparing for a new release (version bump, release notes, etc.)
91+
color: "f9c74f"
92+
93+
- name: 🔄 New release
94+
description: This PR into `stable` marks a new release
95+
color: "f9c74f"
96+
8997
- name: 🧪 Tests
9098
description: Improvements or additions to unit tests
9199
color: "9f2d60"

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
push:
5+
branches:
6+
- stable
7+
8+
permissions:
9+
contents: write
10+
discussions: write
11+
12+
13+
jobs:
14+
test:
15+
name: Run tests and publish
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
21+
22+
- name: Setup Rust toolchain
23+
uses: actions-rust-lang/setup-rust-toolchain@2fcdc490d667999e01ddbbf0f2823181beef6b39
24+
with:
25+
components: rustfmt, clippy
26+
27+
- name: Run RustFMT
28+
uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326
29+
30+
- name: Run Clippy
31+
run: cargo clippy --all-targets --all-features
32+
33+
- name: Run tests
34+
run: cargo test --verbose --all-targets --all-features
35+
36+
- name: Run documentation tests
37+
run: cargo test --verbose --doc --all-features
38+
39+
- name: Get crate version
40+
id: get_crate_info
41+
run: |
42+
CRATE_VERSION=$(grep '^version = ' Cargo.toml | head -n 1 | cut -d '"' -f 2)
43+
echo "Crate error-stack-macros2"
44+
echo "Crate Version: $CRATE_VERSION"
45+
echo "crate_version=$CRATE_VERSION" >> "$GITHUB_OUTPUT"
46+
47+
- name: Publish crate
48+
env:
49+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_API_TOKEN }}
50+
run: cargo publish
51+
52+
- name: Create GitHub release
53+
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836
54+
with:
55+
body_path: RELEASE.md
56+
prerelease: true
57+
name: "`error-stack-macros2` ${{ steps.get_crate_info.outputs.crate_version }}"
58+
tag_name: v${{ steps.get_crate_info.outputs.crate_version }}
59+
target_commitish: stable

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
workflow_dispatch:
1313

14+
1415
jobs:
1516
test:
1617
name: Run tests

.github/workflows/testToStable.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Run tests and check version on crates.io
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- stable
7+
8+
9+
jobs:
10+
test:
11+
name: Run tests on PR into stable
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
17+
18+
- name: Setup Rust toolchain
19+
uses: actions-rust-lang/setup-rust-toolchain@2fcdc490d667999e01ddbbf0f2823181beef6b39
20+
with:
21+
components: rustfmt, clippy
22+
23+
- name: Run RustFMT
24+
uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326
25+
26+
- name: Run Clippy
27+
run: cargo clippy --all-targets --all-features
28+
29+
- name: Run tests
30+
run: cargo test --verbose --all-targets --all-features
31+
32+
- name: Run documentation tests
33+
run: cargo test --verbose --doc --all-features
34+
35+
36+
check-version:
37+
name: Check version on crates.io
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
43+
44+
- name: Get crate version
45+
id: get_crate_info
46+
run: |
47+
CRATE_VERSION=$(grep '^version = ' Cargo.toml | head -n 1 | cut -d '"' -f 2)
48+
echo "Crate error-stack-macros2"
49+
echo "Crate Version: $CRATE_VERSION"
50+
echo "crate_version=$CRATE_VERSION" >> "$GITHUB_OUTPUT"
51+
52+
- name: Check if version already exists on crates.io
53+
run: |
54+
CRATE_VERSION="${{ steps.get_crate_info.outputs.crate_version }}"
55+
API_URL="https://crates.io/api/v1/crates/error-stack-macros2/$CRATE_VERSION"
56+
57+
echo "Checking $API_URL"
58+
59+
if curl --head -f "$API_URL"; then
60+
echo "Error: Version $CRATE_VERSION already exists on crates.io!"
61+
echo "Please increment the version in Cargo.toml."
62+
exit 1
63+
else
64+
echo "Version $CRATE_VERSION does not exist on crates.io. You're good to go!"
65+
fi

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RELEASE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# `error-stack-macros2` v0.1.0
2+
3+
The very first development version of `error-stack-macros2` is finally here!
4+
5+
## Features
6+
7+
This version (0.1.0) offers a derive macro for the [`Error`](https://doc.rust-lang.org/stable/core/error/trait.Error.html) trait which encourages the best practices for defining [`error-stack`](https://crates.io/crates/error-stack) context types.
8+
9+
Here's an example. This code:
10+
11+
```rust
12+
use std::{
13+
error::Error,
14+
fmt::{self, Display, Formatter},
15+
};
16+
17+
#[derive(Debug)]
18+
pub enum CreditCardError {
19+
InvalidInput(String),
20+
Other,
21+
}
22+
23+
impl Display for CreditCardError {
24+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
25+
let msg = match self {
26+
Self::InvalidInput(_) => "credit card not found",
27+
Self::Other => "failed to retrieve credit card",
28+
};
29+
30+
f.write_str(msg)
31+
}
32+
}
33+
34+
impl Error for CreditCardError {}
35+
```
36+
37+
...can now be reduced to this code:
38+
39+
```rust
40+
use error_stack_macros2::Error;
41+
42+
#[derive(Debug, Error)]
43+
pub enum CreditCardError {
44+
#[display("credit card not found")]
45+
InvalidInput(String),
46+
47+
#[display("failed to retrieve credit card")]
48+
Other,
49+
}
50+
```
51+
52+
This new release also means that we will now be listening to feedback and accepting new features (macros, obviously). We are also now committed to maintaining this macro going forward and keeping our dependencies up to date.
53+
54+
## Previous release notes
55+
56+
If you want to take a look at the notes from previous releases, go to [GitHub Releases](https://github.com/LuisFerLCC/error-stack-macros2/releases).

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Version | Supported |
66
| ------- | --------- |
7-
| - | - |
7+
| 0.1.0 | |
88

99
## Report a vulnerability
1010

impl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "error-stack-macros2"
3-
version = "0.0.0-reserved"
3+
version = "0.1.0"
44
authors = ["LuisFerLCC"]
55
edition = "2024"
66
rust-version = "1.90.0"

tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "error-stack-macros2-tests"
3-
version = "0.0.0-reserved"
3+
version = "0.1.0"
44
authors = ["LuisFerLCC"]
55
edition = "2024"
66
rust-version = "1.90.0"

0 commit comments

Comments
 (0)