Skip to content

Commit

Permalink
Add crate_type workflow
Browse files Browse the repository at this point in the history
- Check if the create is lib and bin
  • Loading branch information
ameknite committed Jun 19, 2024
1 parent da34e5b commit 788b4ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
27 changes: 1 addition & 26 deletions .github/workflows/build_and_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,32 +174,7 @@ jobs:
ref: refs/tags/${{ needs.get-version.outputs.tag_version }}

check-if-bin:
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Install jql
uses: taiki-e/install-action@v2
with:
tool: jql

- name: Searching for bin
id: searching
run: |
result=$(cargo metadata --format-version=1 --no-deps | jql '"packages"|>"targets"<|[0]|>"kind"' | jql '..' -i);
echo "targets=$result" >> "$GITHUB_OUTPUT";
echo kind of targets $result;
- name: print if skip upploading binaries to github release
if: ${{ !contains(steps.searching.outputs.targets, 'bin') }}
run: echo "This job avoid publishing binaries to github releases for libraries crates"

outputs:
is_bin: ${{ contains(steps.searching.outputs.targets, 'bin') }}
uses: ./.github/workflows/crate_type.yaml

build-and-release:
needs: [get-version, create-release, check-if-bin]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: cargo doc --workspace --all-features

check-if-lib:
uses: ./.github/workflows/check-if-lib.yaml
uses: ./.github/workflows/crate_type.yaml

cargo-test-doc:
needs: check-if-lib
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check if Lib
name: Crate Type

on:
workflow_call:
Expand Down Expand Up @@ -28,9 +28,6 @@ jobs:
echo "targets=$result" >> "$GITHUB_OUTPUT";
echo kind of targets $result;
- name: print if skip cargo-semver-checks
if: ${{ !contains(steps.searching.outputs.targets, 'lib') }}
run: echo "cargo semver-check only works in libraries"

outputs:
is_lib: ${{ contains(steps.searching.outputs.targets, 'lib') }}
is_bin: ${{ contains(steps.searching.outputs.targets, 'bin') }}

0 comments on commit 788b4ea

Please sign in to comment.