-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
1 parent
92e965b
commit 22cc68e
Showing
2 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Source this file. | ||
# | ||
# Detects any changed Cargo manifests. | ||
|
||
detect_changed_manifests() { | ||
local changed_manifests=() | ||
local cargo_toml_files=$(find . -name "Cargo.toml") | ||
|
||
for file in $cargo_toml_files; do | ||
# Get the current version from the Cargo.toml. | ||
local current_version=$(grep -E '^version\s*=' "$file" | sed -E 's/version\s*=\s*"(.*)"/\1/') | ||
|
||
# Get the previous version from the last committed Cargo.toml. | ||
local previous_version=$(git show HEAD~1:"$file" | grep -E '^version\s*=' | sed -E 's/version\s*=\s*"(.*)"/\1/' 2>/dev/null) | ||
|
||
# Compare the versions and add the path to the list if they are different. | ||
if [ "$current_version" != "$previous_version" ]; then | ||
changed_manifests+=("$file") | ||
fi | ||
done | ||
|
||
echo "${changed_manifests[@]}" | ||
} |
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,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
source ci/detect-changed-manifests.sh | ||
|
||
changed_manifests=$(detect_changed_manifests) | ||
|
||
if [ -n "$changed_manifests" ]; then | ||
for manifest_path in $changed_manifests; do | ||
# Read the package name and version from its Cargo.toml. | ||
package_name=$(grep '^name\s*=' "$manifest_path" | awk -F'\"' '{print $2}') | ||
new_version=$(grep '^version\s*=' "$manifest_path" | awk -F'\"' '{print $2}') | ||
|
||
# Create a new git tag. | ||
tag_name="${package_name}-v${new_version}" | ||
git tag "$tag_name" | ||
echo "Created tag: $tag_name" | ||
done | ||
else | ||
echo "No versions changed." | ||
fi |