-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,560 additions
and
613 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,64 @@ | ||
#!/bin/bash | ||
|
||
if [ $# != 1 ] | ||
then | ||
echo "Please provide version as the first argument" | ||
exit 1 | ||
fi | ||
|
||
version="$1" | ||
CI_DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
pushd "$CI_DIR/../" | ||
|
||
echo "Searching for crates..." | ||
|
||
crates=($(find . -type d -exec bash -c '[ -f "$0"/Cargo.toml ]' '{}' \; -print)) | ||
|
||
if [[ "${#crates[@]}" == "0" ]]; then | ||
echo "No crates found." | ||
exit 1 | ||
else | ||
echo "Found ${#crates[@]} crate(s): ${crates[*]}" | ||
fi | ||
|
||
file=Cargo.toml | ||
final_exit_code=0 | ||
declare -a grep_failures | ||
declare -a lockfile_failures | ||
|
||
bump_version() { | ||
# Catches every `version` that begins a line and doesn't end with a comma. | ||
find_pattern='^version\s*=.*[^,]\s*$' | ||
replace_pattern='s/'$find_pattern'/version = "'"$version"'"/' | ||
|
||
grep -q "$find_pattern" "$file" && sed -i "$replace_pattern" "$file" | ||
exit_code="$?" | ||
if [[ "$exit_code" != "0" ]]; then | ||
final_exit_code=1 | ||
grep_failures+=($1) | ||
return | ||
fi | ||
|
||
cargo generate-lockfile | ||
exit_code="$?" | ||
if [[ "$exit_code" != "0" ]]; then | ||
final_exit_code=1 | ||
lockfile_failures+=($1) | ||
fi | ||
} | ||
|
||
for crate in "${crates[@]}" | ||
do | ||
pushd "$crate" | ||
bump_version "$crate" | ||
popd | ||
done | ||
|
||
if [[ $final_exit_code != 0 ]]; then | ||
[[ "${#grep_failures[@]}" != "0" ]] && echo "Failed to find 'version' for ${#grep_failures[@]} crate(s): ${grep_failures[*]}" | ||
[[ "${#lockfile_failures[@]}" != "0" ]] && echo "Failed to generate lockfile for ${#lockfile_failures[@]} crate(s): ${lockfile_failures[*]}" | ||
else | ||
echo "The version number has been changed to $version." | ||
fi | ||
|
||
exit $final_exit_code |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.