mirror of https://github.com/rust-lang/cargo
ci: integrate `xtask-bump-check`
This commit is contained in:
parent
9cca5721e4
commit
aefa6e96d7
|
@ -2,3 +2,4 @@
|
||||||
build-man = "run --package xtask-build-man --"
|
build-man = "run --package xtask-build-man --"
|
||||||
stale-label = "run --package xtask-stale-label --"
|
stale-label = "run --package xtask-stale-label --"
|
||||||
unpublished = "run --package xtask-unpublished --"
|
unpublished = "run --package xtask-unpublished --"
|
||||||
|
bump-check = "run --package xtask-bump-check --"
|
||||||
|
|
|
@ -91,8 +91,14 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # make `git diff` work
|
fetch-depth: 0
|
||||||
- run: rustup update stable && rustup default stable
|
- run: rustup update stable && rustup default stable
|
||||||
|
- name: Install cargo-semver-checks
|
||||||
|
run: |
|
||||||
|
mkdir installed-bins
|
||||||
|
curl -Lf https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.22.1/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz \
|
||||||
|
| tar -xz --directory=./installed-bins
|
||||||
|
echo `pwd`/installed-bins >> $GITHUB_PATH
|
||||||
- run: ci/validate-version-bump.sh
|
- run: ci/validate-version-bump.sh
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|
|
@ -16,46 +16,7 @@ set -euo pipefail
|
||||||
base_sha=$(git rev-parse "${BASE_SHA:-HEAD~1}")
|
base_sha=$(git rev-parse "${BASE_SHA:-HEAD~1}")
|
||||||
head_sha=$(git rev-parse "${HEAD_SHA:-HEAD}")
|
head_sha=$(git rev-parse "${HEAD_SHA:-HEAD}")
|
||||||
|
|
||||||
echo "Base branch is $base_sha"
|
echo "Base revision is $base_sha"
|
||||||
echo "Current head is $head_sha"
|
echo "Head revision is $head_sha"
|
||||||
|
|
||||||
# Gets crate names of members that has been changed from $bash_sha to $head_sha.
|
cargo bump-check --base-rev "$base_sha" --head-rev "$head_sha"
|
||||||
changed_crates=$(
|
|
||||||
git diff --name-only "$base_sha" "$head_sha" -- crates/ credential/ benches/ \
|
|
||||||
| cut -d'/' -f2 \
|
|
||||||
| sort -u
|
|
||||||
)
|
|
||||||
|
|
||||||
if [ -z "$changed_crates" ]
|
|
||||||
then
|
|
||||||
echo "No file changed in member crates."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checks publish status for only crates with code changes.
|
|
||||||
publish_status_table=$(
|
|
||||||
echo "$changed_crates" \
|
|
||||||
| xargs printf -- '--package %s\n' \
|
|
||||||
| xargs cargo unpublished
|
|
||||||
)
|
|
||||||
|
|
||||||
# "yes" -> code changed but no version difference -> need a bump
|
|
||||||
# Prints 2nd column (sep by space), which is the name of the crate.
|
|
||||||
crates_need_bump=$(
|
|
||||||
echo "$publish_status_table" \
|
|
||||||
| { grep '| yes ' || true; } \
|
|
||||||
| awk '{print $2}'
|
|
||||||
)
|
|
||||||
|
|
||||||
if [ -z "$crates_need_bump" ]
|
|
||||||
then
|
|
||||||
echo "No version bump needed for member crates."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Detected changes in these crates but no version bump found:"
|
|
||||||
echo "$crates_need_bump"
|
|
||||||
echo
|
|
||||||
echo "Please bump at least one patch version for each corresponding Cargo.toml:"
|
|
||||||
echo 'Run "cargo unpublished" to read the publish status table for details.'
|
|
||||||
exit 1
|
|
||||||
|
|
Loading…
Reference in New Issue