Skip to content

Commit 5a48733

Browse files
authored
ci: Invert crate-type test on semver check (#417)
Detect proc macro
1 parent c1e6ff9 commit 5a48733

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.github/workflows/publish-rust.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,26 @@ jobs:
171171
with:
172172
tool: toml-cli,cargo-semver-checks,cargo-release
173173

174-
- name: Check if crate has a lib target
175-
id: has_lib
174+
- name: Check if crate is a procedural macro
175+
id: is_proc_macro
176176
shell: bash
177177
run: |
178178
set +e # toml crashes the whole shell if it fails to find the key
179179
result=$(toml get "${{ inputs.package-path }}/Cargo.toml" lib.crate-type)
180-
if [[ "$result" == *"lib"* ]]; then
181-
echo "has_lib=true" >> "$GITHUB_OUTPUT"
180+
if [[ "$result" == *"proc-macro"* ]]; then
181+
echo "is_proc_macro=true" >> "$GITHUB_OUTPUT"
182182
else
183-
echo "has_lib=false" >> "$GITHUB_OUTPUT"
183+
echo "is_proc_macro=false" >> "$GITHUB_OUTPUT"
184184
fi
185185
186186
- name: Set Git Author (required for cargo-release)
187-
if: ${{ steps.has_lib.outputs.has_lib == 'true' }}
187+
if: ${{ steps.is_proc_macro.outputs.is_proc_macro == 'false' }}
188188
run: |
189189
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
190190
git config --global user.name "github-actions[bot]"
191191
192192
- name: Set Version
193-
if: ${{ steps.has_lib.outputs.has_lib == 'true' }}
193+
if: ${{ steps.is_proc_macro.outputs.is_proc_macro == 'false' }}
194194
run: |
195195
if [ "${{ inputs.level }}" == "version" ]; then
196196
LEVEL=${{ inputs.version }}
@@ -200,7 +200,7 @@ jobs:
200200
cargo release $LEVEL --manifest-path "${{ inputs.package_path }}/Cargo.toml" --no-tag --no-publish --no-push --no-confirm --execute
201201
202202
- name: Check semver
203-
if: ${{ steps.has_lib.outputs.has_lib == 'true' }}
203+
if: ${{ steps.is_proc_macro.outputs.is_proc_macro == 'false' }}
204204
run: cargo semver-checks --manifest-path "${{ inputs.package_path }}/Cargo.toml"
205205

206206
publish-crate:

0 commit comments

Comments
 (0)