diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 8b398cf..6d4d10d 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -152,38 +152,40 @@ jobs: commit_user_email: github-actions[bot]@users.noreply.github.com commit_author: github-actions[bot] + # How to create a new GitHub release? + # 1. Create a release branch named "release/". + # 2. Open a PR from the branch, including the release note in the PR body. + # 3. Wait for the CI to create a draft release. + # 4. Publish the release when it's ready. release: name: Create GitHub release needs: [check, changelog] - if: startsWith(github.head_ref, 'release/') + if: startsWith(github.head_ref, 'release/') && github.repository == 'loichyan/dynify' permissions: - contents: write # Need to update release + contents: write # need to update release runs-on: ubuntu-latest steps: - name: Setup | Checkout uses: actions/checkout@v4 - # For a PR from "release/v1.0.0", the release tag is set to "v1.0.0" - name: Setup | Configure id: configure run: echo tag="${GITHUB_HEAD_REF#release/}" >$GITHUB_OUTPUT - # Release notes are taken from the PR's body - name: Release | Create Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} release_tag: ${{ steps.configure.outputs.tag }} release_body: ${{ github.event.pull_request.body }} run: | - if gh release view "$release_tag" &>/dev/null; then - echo "update existed release $release_tag" - command=edit + if gh release view "$release_tag" >/dev/null; then + echo "update existing release $release_tag" + gh release edit "$release_tag" --notes="$release_body" else echo "create new release $release_tag" - command=create + gh release create "$release_tag" \ + --target="$GITHUB_BASE_REF" \ + --draft=true \ + --title="${release_tag#v} ($(date -u +'%Y-%m-%d'))" \ + --notes="$release_body" fi - gh release "$command" "$release_tag" \ - --target="$GITHUB_BASE_REF" \ - --draft=true \ - --title="$release_tag ($(date -u +'%Y-%m-%d'))" \ - --notes="$release_body" diff --git a/CHANGELOG.md b/CHANGELOG.md index dd6c852..800d9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,7 +90,7 @@ changes. [README](https://github.com/loichyan/dynify/blob/v0.0.1/README.md) for more details. -[0.0.1]: https://github.com/loichyan/dynify/releases/tag/v0.0.1 -[0.1.0]: https://github.com/loichyan/dynify/releases/tag/v0.1.0 -[0.1.1]: https://github.com/loichyan/dynify/releases/tag/v0.1.1 +[0.0.1]: https://github.com/loichyan/dynify/tree/v0.0.1 +[0.1.0]: https://github.com/loichyan/dynify/compare/v0.0.1..v0.1.0 +[0.1.1]: https://github.com/loichyan/dynify/compare/v0.1.0..v0.1.1 [Unreleased]: https://github.com/loichyan/dynify/compare/v0.1.1..HEAD diff --git a/README.md b/README.md index 2cd7c52..553216b 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,14 @@ for limited environments. In contrast, async-trait requires heap allocation to store trait objects, as it essentially transforms `async fn` into `Box`. +### vs dynosaur + +[dynosaur](https://crates.io/crates/dynosaur) employs the same approach as +async-trait to generate dyn compatible traits but, by default, preserves the +original trait for more performant static dispatch. Similar to the async-trait +case, the main advantage of using dynify is the possibility to achieve heapless +dynamic dispatch. + ## ♥️ Special thanks - [Rust-for-Linux/pin-init](https://github.com/Rust-for-Linux/pin-init) for its diff --git a/src/dynify.md b/src/dynify.md index be2ed62..7521f16 100644 --- a/src/dynify.md +++ b/src/dynify.md @@ -111,7 +111,7 @@ trait DynTrait { In common cases, you can rely on the lifetimes generated by `#[dynify]`, adding extra bounds as needed. -## Making [`Send`]able generated traits +## Making generated traits [`Send`]able Unlike `async-trait`, this macro does not provide support for adding `Send` bounds to returned `Future`s (or any other `impl Trait`s). However, as @@ -136,3 +136,17 @@ fn run_client( } } ``` + +As an alternative, you can also [bitte](https://crates.io/crates/bitte) for this +purpose: + + + +```rust,ignore +# use dynify::PinDynify; +#[bitte::bitte(Send)] +#[dynify::dynify] // must be put within the scope of `#[bitte]` +trait Client { + async fn request(&self, uri: &str) -> String; +} +```