-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #12085 - weihanglo:ci-check-version-bump, r=<try>
ci: check if a crate needs a version bump when source files change
- Loading branch information
Showing
7 changed files
with
217 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
# This script checks if a crate needs a version bump. | ||
# | ||
# At the time of writing, it doesn't check what kind of bump is required. | ||
# In the future, we could take SemVer compatibliity into account, like | ||
# integrating `cargo-semver-checks` of else | ||
# | ||
# Inputs: | ||
# BASE_SHA The commit SHA of the branch where the PR wants to merge into. | ||
# COMMIT_SHA The commit SHA that triggered the workflow. | ||
|
||
set -euo pipefail | ||
|
||
# When `BASE_SHA` is missing, we assume it is from bors merge commit, | ||
# so `HEAD~` should find the previous commit on master branch. | ||
base_sha=$(git rev-parse "${BASE_SHA:-HEAD~}") | ||
commit_sha=$(git rev-parse "${COMMIT_SHA:-HEAD}") | ||
|
||
echo "Base branch is $base_sha" | ||
echo "The current is $commit_sha" | ||
|
||
changed_crates=$( | ||
git diff --name-only "$base_sha" "$commit_sha" -- crates/ credential/ benches/ \ | ||
| cut -d'/' -f2 \ | ||
| sort -u | ||
) | ||
|
||
if [ -z "$changed_crates" ] | ||
then | ||
echo "No file changed in sub crates." | ||
exit 0 | ||
fi | ||
|
||
output=$( | ||
echo "$changed_crates" \ | ||
| xargs printf -- '--package %s\n' \ | ||
| xargs cargo unpublished --check-version-bump | ||
) | ||
|
||
if [ -z "$output" ] | ||
then | ||
echo "No version bump needed for sub crates." | ||
exit 0 | ||
fi | ||
|
||
echo "$output" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters