From 9143e8820c8d180c0de90c34fca2af491280a6ea Mon Sep 17 00:00:00 2001 From: LuisFerLCC Date: Sun, 21 Sep 2025 22:15:41 -0600 Subject: [PATCH 1/3] Add GitHub Actions: Tests and Publish on PR into stable --- .github/workflows/publish.yml | 59 +++++++++++++++++++++++++++ .github/workflows/test.yml | 1 + .github/workflows/testToStable.yml | 65 ++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/testToStable.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7538490 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,59 @@ +name: Publish to crates.io + +on: + push: + branches: + - stable + +permissions: + contents: write + discussions: write + + +jobs: + test: + name: Run tests and publish + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@2fcdc490d667999e01ddbbf0f2823181beef6b39 + with: + components: rustfmt, clippy + + - name: Run RustFMT + uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326 + + - name: Run Clippy + run: cargo clippy --all-targets --all-features + + - name: Run tests + run: cargo test --verbose --all-targets --all-features + + - name: Run documentation tests + run: cargo test --verbose --doc --all-features + + - name: Get crate version + id: get_crate_info + run: | + CRATE_VERSION=$(grep '^version = ' Cargo.toml | head -n 1 | cut -d '"' -f 2) + echo "Crate error-stack-macros2" + echo "Crate Version: $CRATE_VERSION" + echo "crate_version=$CRATE_VERSION" >> "$GITHUB_OUTPUT" + + - name: Publish crate + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_API_TOKEN }} + run: cargo publish + + - name: Create GitHub release + uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 + with: + body_path: RELEASE.md + prerelease: true + name: "`error-stack-macros2` ${{ steps.get_crate_info.outputs.crate_version }}" + tag_name: v${{ steps.get_crate_info.outputs.crate_version }} + target_commitish: stable diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a0f09c..b3c7260 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,7 @@ on: workflow_dispatch: + jobs: test: name: Run tests diff --git a/.github/workflows/testToStable.yml b/.github/workflows/testToStable.yml new file mode 100644 index 0000000..243c95b --- /dev/null +++ b/.github/workflows/testToStable.yml @@ -0,0 +1,65 @@ +name: Run tests and check version on crates.io + +on: + pull_request: + branches: + - stable + + +jobs: + test: + name: Run tests on PR into stable + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@2fcdc490d667999e01ddbbf0f2823181beef6b39 + with: + components: rustfmt, clippy + + - name: Run RustFMT + uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326 + + - name: Run Clippy + run: cargo clippy --all-targets --all-features + + - name: Run tests + run: cargo test --verbose --all-targets --all-features + + - name: Run documentation tests + run: cargo test --verbose --doc --all-features + + + check-version: + name: Check version on crates.io + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + + - name: Get crate version + id: get_crate_info + run: | + CRATE_VERSION=$(grep '^version = ' Cargo.toml | head -n 1 | cut -d '"' -f 2) + echo "Crate error-stack-macros2" + echo "Crate Version: $CRATE_VERSION" + echo "crate_version=$CRATE_VERSION" >> "$GITHUB_OUTPUT" + + - name: Check if version already exists on crates.io + run: | + CRATE_VERSION="${{ steps.get_crate_info.outputs.crate_version }}" + API_URL="https://crates.io/api/v1/crates/error-stack-macros2/$CRATE_VERSION" + + echo "Checking $API_URL" + + if curl --head -f "$API_URL"; then + echo "Error: Version $CRATE_VERSION already exists on crates.io!" + echo "Please increment the version in Cargo.toml." + exit 1 + else + echo "Version $CRATE_VERSION does not exist on crates.io. You're good to go!" + fi From 260e288b047dfc36c779df7f1bd31d5432a6f9af Mon Sep 17 00:00:00 2001 From: LuisFerLCC Date: Sun, 21 Sep 2025 22:35:51 -0600 Subject: [PATCH 2/3] Prepare release 0.1.0 --- Cargo.lock | 4 ++-- RELEASE.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ SECURITY.md | 2 +- impl/Cargo.toml | 2 +- tests/Cargo.toml | 2 +- 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 RELEASE.md diff --git a/Cargo.lock b/Cargo.lock index 06155d3..36dc187 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "error-stack-macros2" -version = "0.0.0-reserved" +version = "0.1.0" dependencies = [ "error-stack", "proc-macro2", @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "error-stack-macros2-tests" -version = "0.0.0-reserved" +version = "0.1.0" dependencies = [ "error-stack", "error-stack-macros2", diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..c4e0e49 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,56 @@ +# `error-stack-macros2` v0.1.0 + +The very first development version of `error-stack-macros2` is finally here! + +## Features + +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. + +Here's an example. This code: + +```rust +use std::{ + error::Error, + fmt::{self, Display, Formatter}, +}; + +#[derive(Debug)] +pub enum CreditCardError { + InvalidInput(String), + Other, +} + +impl Display for CreditCardError { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + let msg = match self { + Self::InvalidInput(_) => "credit card not found", + Self::Other => "failed to retrieve credit card", + }; + + f.write_str(msg) + } +} + +impl Error for CreditCardError {} +``` + +...can now be reduced to this code: + +```rust +use error_stack_macros2::Error; + +#[derive(Debug, Error)] +pub enum CreditCardError { + #[display("credit card not found")] + InvalidInput(String), + + #[display("failed to retrieve credit card")] + Other, +} +``` + +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. + +## Previous release notes + +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). diff --git a/SECURITY.md b/SECURITY.md index b3addf8..7033048 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,7 +4,7 @@ | Version | Supported | | ------- | --------- | -| - | - | +| 0.1.0 | โœ… | ## Report a vulnerability diff --git a/impl/Cargo.toml b/impl/Cargo.toml index 70c6320..563e35b 100644 --- a/impl/Cargo.toml +++ b/impl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "error-stack-macros2" -version = "0.0.0-reserved" +version = "0.1.0" authors = ["LuisFerLCC"] edition = "2024" rust-version = "1.90.0" diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 138780f..852700a 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "error-stack-macros2-tests" -version = "0.0.0-reserved" +version = "0.1.0" authors = ["LuisFerLCC"] edition = "2024" rust-version = "1.90.0" From a0cebda8f70545883457d6670556c4b35dbb37b0 Mon Sep 17 00:00:00 2001 From: LuisFerLCC Date: Sun, 21 Sep 2025 22:52:15 -0600 Subject: [PATCH 3/3] Add GitHub labels: Release preparation AND New release --- .github/labels.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/labels.yml b/.github/labels.yml index cf27b92..4f80b29 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -86,6 +86,14 @@ description: This PR is ready to be merged color: "0ff40b" +- name: ๐Ÿ”„ Release preparation + description: Preparing for a new release (version bump, release notes, etc.) + color: "f9c74f" + +- name: ๐Ÿ”„ New release + description: This PR into `stable` marks a new release + color: "f9c74f" + - name: ๐Ÿงช Tests description: Improvements or additions to unit tests color: "9f2d60"