-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update actions #39
Update actions #39
Conversation
WalkthroughThe pull request introduces a new GitHub Action named Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (2)
.github/actions/version-tag/action.yml (2)
1-8
: Consider making documentation publicly accessibleThe referenced documentation URL points to a private repository (
allthings/github-action-tools
). Consider either making the documentation public or including essential documentation directly in this file to ensure users can understand and use the action effectively.
22-41
: Consider concurrent execution safetyThe current implementation might face race conditions if multiple workflows attempt to create version tags simultaneously.
Consider these approaches to handle concurrent execution:
- Use GitHub Actions concurrency controls to ensure only one instance runs at a time:
concurrency: group: version-tag cancel-in-progress: false
- Implement a locking mechanism using GitHub API
- Use GitHub's branch protection rules to prevent concurrent tag creation
🧰 Tools
🪛 yamllint (1.35.1)
[error] 31-31: trailing spaces
(trailing-spaces)
[error] 39-39: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/actions/version-tag/action.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/actions/version-tag/action.yml
[error] 31-31: trailing spaces
(trailing-spaces)
[error] 39-39: trailing spaces
(trailing-spaces)
- name: Set PATH | ||
shell: bash | ||
run: | | ||
echo "/bin" >> $GITHUB_PATH | ||
echo "/sbin" >> $GITHUB_PATH | ||
echo "/usr/bin" >> $GITHUB_PATH | ||
echo "/usr/sbin" >> $GITHUB_PATH | ||
echo "/usr/local/bin" >> $GITHUB_PATH | ||
echo "/usr/local/sbin" >> $GITHUB_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Reconsider PATH modification approach
Adding standard system directories to GITHUB_PATH
is unnecessary as these paths are typically already included in the default PATH of GitHub Actions runners. This approach might mask underlying PATH-related issues rather than addressing them properly.
Consider removing this step unless there's a specific documented reason for including it. If you're experiencing PATH-related issues, it would be better to:
- Debug the specific command that's failing
- Use absolute paths for critical commands
- Document why this PATH modification is necessary if it must be kept
set +e | ||
git config user.name "Bot" | ||
git config user.email "admin@allthings.me" | ||
currentVersion="$(git describe --tags `git rev-list --tags --max-count=1`)" | ||
if [ "$currentVersion" = "" ]; then | ||
currentVersion="v0.0.0" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error handling and version initialization
While set +e
is used, the script doesn't check for errors after critical git commands. Also, the version initialization could be more robust.
Consider this improved implementation:
- set +e
- git config user.name "Bot"
- git config user.email "admin@allthings.me"
- currentVersion="$(git describe --tags `git rev-list --tags --max-count=1`)"
- if [ "$currentVersion" = "" ]; then
- currentVersion="v0.0.0"
- fi
+ set -e # Fail fast on errors
+ git config user.name "Allthings Bot"
+ git config user.email "admin@allthings.me"
+
+ # Get latest version tag with error handling
+ if ! currentVersion=$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null); then
+ echo "No existing tags found, initializing with v0.0.0"
+ currentVersion="v0.0.0"
+ fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
set +e | |
git config user.name "Bot" | |
git config user.email "admin@allthings.me" | |
currentVersion="$(git describe --tags `git rev-list --tags --max-count=1`)" | |
if [ "$currentVersion" = "" ]; then | |
currentVersion="v0.0.0" | |
fi | |
set -e # Fail fast on errors | |
git config user.name "Allthings Bot" | |
git config user.email "admin@allthings.me" | |
# Get latest version tag with error handling | |
if ! currentVersion=$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null); then | |
echo "No existing tags found, initializing with v0.0.0" | |
currentVersion="v0.0.0" | |
fi |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 31-31: trailing spaces
(trailing-spaces)
latestVersion="${currentVersion//v[0-9]*.[0-9]*./}" | ||
((++latestVersion)) | ||
newVersion="${currentVersion%.*}.$latestVersion" | ||
git tag -a $newVersion -m "Release new version: $newVersion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strengthen version parsing and increment logic
The current version parsing is fragile and could break with unexpected version formats. It also doesn't validate the version structure.
Consider using a more robust version parsing approach:
- latestVersion="${currentVersion//v[0-9]*.[0-9]*./}"
- ((++latestVersion))
- newVersion="${currentVersion%.*}.$latestVersion"
+ # Validate and parse semantic version
+ if [[ ! $currentVersion =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Error: Current version $currentVersion doesn't match expected format (vX.Y.Z)"
+ exit 1
+ fi
+
+ # Parse version components
+ major=$(echo $currentVersion | cut -d. -f1 | tr -d 'v')
+ minor=$(echo $currentVersion | cut -d. -f2)
+ patch=$(echo $currentVersion | cut -d. -f3)
+
+ # Increment patch version
+ newVersion="v$major.$minor.$((patch + 1))"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
latestVersion="${currentVersion//v[0-9]*.[0-9]*./}" | |
((++latestVersion)) | |
newVersion="${currentVersion%.*}.$latestVersion" | |
git tag -a $newVersion -m "Release new version: $newVersion" | |
# Validate and parse semantic version | |
if [[ ! $currentVersion =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Error: Current version $currentVersion doesn't match expected format (vX.Y.Z)" | |
exit 1 | |
fi | |
# Parse version components | |
major=$(echo $currentVersion | cut -d. -f1 | tr -d 'v') | |
minor=$(echo $currentVersion | cut -d. -f2) | |
patch=$(echo $currentVersion | cut -d. -f3) | |
# Increment patch version | |
newVersion="v$major.$minor.$((patch + 1))" | |
git tag -a $newVersion -m "Release new version: $newVersion" |
git push origin $newVersion | ||
if [ ! -z "${{ env.WORKFLOW_NAME }}" ]; then | ||
gh workflow run ${{ env.WORKFLOW_NAME }} --ref $newVersion | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add safeguards for tag creation and workflow triggering
The current implementation doesn't handle tag conflicts or verify workflow existence before triggering.
Consider adding these safety checks:
- git tag -a $newVersion -m "Release new version: $newVersion"
- git push origin $newVersion
- if [ ! -z "${{ env.WORKFLOW_NAME }}" ]; then
- gh workflow run ${{ env.WORKFLOW_NAME }} --ref $newVersion
- fi
+ # Check if tag already exists
+ if git rev-parse "$newVersion" >/dev/null 2>&1; then
+ echo "Error: Tag $newVersion already exists"
+ exit 1
+ fi
+
+ # Create and push tag with error handling
+ if ! git tag -a "$newVersion" -m "Release new version: $newVersion"; then
+ echo "Error: Failed to create tag $newVersion"
+ exit 1
+ fi
+
+ if ! git push origin "$newVersion"; then
+ echo "Error: Failed to push tag $newVersion"
+ git tag -d "$newVersion" # Clean up local tag
+ exit 1
+ fi
+
+ # Trigger workflow if specified
+ if [ -n "$WORKFLOW_NAME" ]; then
+ if ! gh workflow list | grep -q "^$WORKFLOW_NAME"; then
+ echo "Error: Workflow $WORKFLOW_NAME not found"
+ exit 1
+ fi
+ if ! gh workflow run "$WORKFLOW_NAME" --ref "$newVersion"; then
+ echo "Error: Failed to trigger workflow $WORKFLOW_NAME"
+ exit 1
+ fi
+ fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
git push origin $newVersion | |
if [ ! -z "${{ env.WORKFLOW_NAME }}" ]; then | |
gh workflow run ${{ env.WORKFLOW_NAME }} --ref $newVersion | |
fi | |
# Check if tag already exists | |
if git rev-parse "$newVersion" >/dev/null 2>&1; then | |
echo "Error: Tag $newVersion already exists" | |
exit 1 | |
fi | |
# Create and push tag with error handling | |
if ! git tag -a "$newVersion" -m "Release new version: $newVersion"; then | |
echo "Error: Failed to create tag $newVersion" | |
exit 1 | |
fi | |
if ! git push origin "$newVersion"; then | |
echo "Error: Failed to push tag $newVersion" | |
git tag -d "$newVersion" # Clean up local tag | |
exit 1 | |
fi | |
# Trigger workflow if specified | |
if [ -n "$WORKFLOW_NAME" ]; then | |
if ! gh workflow list | grep -q "^$WORKFLOW_NAME"; then | |
echo "Error: Workflow $WORKFLOW_NAME not found" | |
exit 1 | |
fi | |
if ! gh workflow run "$WORKFLOW_NAME" --ref "$newVersion"; then | |
echo "Error: Failed to trigger workflow $WORKFLOW_NAME" | |
exit 1 | |
fi | |
fi |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 39-39: trailing spaces
(trailing-spaces)
Update actions from workflow
Summary by CodeRabbit
version-tag
for automating Git version tagging.trigger-workflow-name
to trigger additional workflows after tagging.