Skip to content

Commit

Permalink
Update scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kendryte747 committed Nov 28, 2024
1 parent f263ec9 commit 3404ce4
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions .github/tag_subproject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,52 @@ TAG_NAME="$1"

if [ -z "$TAG_NAME" ]; then
echo "Error: No tag name provided."
echo "Usage: ./$0 <tag-name>"
echo "Usage: $0 <tag-name>"
exit 1
fi

echo "Applying tag: $TAG_NAME to all subprojects..."

# Iterate over all subprojects and apply the tag
~/.bin/repo forall --group sdk,canmv -c '
echo "Tagging project $(pwd)"
echo "Processing project $(pwd)"
set -x
# Get the name of the default remote (typically 'origin')
# Get the name of the default remote (typically "origin")
REMOTE_NAME=$(git remote | head -n 1)
if [ -z "$REMOTE_NAME" ]; then
echo "Error: No remotes found."
exit 1
fi
# Apply the tag to the current project
git tag -a '"$TAG_NAME"' -m "Tagging for release version '"$TAG_NAME"'"
# Get the last tag from the repository
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
if [ $? -ne 0 ] || [ -z "$LAST_TAG" ]; then
echo "No previous tags found. Creating tag without commit history in $(pwd)..."
LAST_TAG=""
TAG_MESSAGE="Release: '"$TAG_NAME"'\n\nNo previous tags found. Initial release for the project."
else
echo "Last tag found: $LAST_TAG"
# Collect commits between the last tag and the current HEAD
COMMIT_LOG=$(git log "$LAST_TAG..HEAD" --oneline --pretty=format:"* %h %s")
if [ -z "$COMMIT_LOG" ]; then
TAG_MESSAGE="Release: '"$TAG_NAME"'\n\nNo new commits since the previous tag: $LAST_TAG."
else
TAG_MESSAGE="Release: '"$TAG_NAME"'\n\n**Changes since $LAST_TAG:**\n\n$COMMIT_LOG"
fi
fi
# Apply the new tag to the current project
git tag -a '"$TAG_NAME"' -m "$(echo "$TAG_MESSAGE")"
if [ $? -ne 0 ]; then
echo "Error creating tag in $(pwd)"
exit 1
fi
# Push the tag to the remote repository
echo "Push tag to $REMOTE_NAME"
# Push the new tag to the remote repository
echo "Pushing tag to $REMOTE_NAME"
git push -v $REMOTE_NAME '"$TAG_NAME"'
if [ $? -ne 0 ]; then
echo "Error pushing tag in $(pwd)"
Expand Down

0 comments on commit 3404ce4

Please sign in to comment.