Skip to content

Update Tool Versions #4

Update Tool Versions

Update Tool Versions #4

name: Update Tool Versions
on:
schedule:
# Run daily at 01:00 UTC
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
dry_run:
description: "Dry run - only check for updates without creating PR"
required: false
default: "false"
type: choice
options:
- "true"
- "false"
permissions:
contents: write
pull-requests: write
jobs:
check-and-update:
name: Check for tool version updates
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Install Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Check for Go tool updates
id: check-go-tools
run: |
# Store updates in a file for later processing
UPDATES_FILE="updates.txt"
> "$UPDATES_FILE"
# Run the check script
./hack/check-go-tool-versions.sh Makefile "$UPDATES_FILE"
- name: Check for GitHub binary tool updates
id: check-github-tools
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
UPDATES_FILE="updates.txt"
# Run the check script
./hack/check-github-tool-versions.sh Makefile "$UPDATES_FILE"
- name: Check if updates are available
id: check-updates
run: |
if [ -f updates.txt ] && [ -s updates.txt ]; then
echo "updates_available=true" >> $GITHUB_OUTPUT
echo "Updates found:"
cat updates.txt
else
echo "updates_available=false" >> $GITHUB_OUTPUT
echo "No updates available"
# Write to GitHub Step Summary
echo "## ✅ All Tools Up-to-Date" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All development tools are already at their latest versions. No updates needed." >> $GITHUB_STEP_SUMMARY
fi
- name: Update Makefile
if: steps.check-updates.outputs.updates_available == 'true' && github.event.inputs.dry_run != 'true'
run: |
echo "Updating Makefile with new versions..."
while IFS='|' read -r var_name current_version new_version repo_url; do
echo "Updating $var_name: $current_version → $new_version"
sed -i "s/^${var_name} ?= .*/${var_name} ?= ${new_version}/" Makefile
done < updates.txt
echo "Makefile updated successfully"
- name: Generate PR summary
if: steps.check-updates.outputs.updates_available == 'true'
id: pr-summary
run: |
echo "Generating PR summary..."
# Create PR body
cat > pr_body.md <<'EOF'
## Tool Version Updates
This PR updates the following development tools to their latest versions:
| Tool | Current Version | New Version | Repository |
|------|-----------------|-------------|------------|
EOF
while IFS='|' read -r var_name current_version new_version repo_url; do
tool_display_name=$(echo "$var_name" | sed 's/_VERSION$//' | tr '_' '-' | tr '[:upper:]' '[:lower:]')
echo "| $tool_display_name | \`$current_version\` | \`$new_version\` | [$repo_url]($repo_url) |" >> pr_body.md
done < updates.txt
cat >> pr_body.md <<'EOF'
### Changes
- Updated tool versions in `Makefile`
### Testing
Please verify that:
- [ ] Unit tests pass (`make unit-tests`)
- [ ] Integration tests pass (`make integration-tests`)
- [ ] All tools can be installed successfully (`make install-tools`)
---
🤖 This PR was automatically generated by the [update-tool-versions workflow](.github/workflows/update-tool-versions.yml).
EOF
echo "PR summary generated"
cat pr_body.md
# Write to GitHub Step Summary
echo "## Tool Version Updates Available" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The following updates were found:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Add the table to step summary
echo "| Tool | Current Version | New Version | Repository |" >> $GITHUB_STEP_SUMMARY
echo "|------|-----------------|-------------|------------|" >> $GITHUB_STEP_SUMMARY
while IFS='|' read -r var_name current_version new_version repo_url; do
tool_display_name=$(echo "$var_name" | sed 's/_VERSION$//' | tr '_' '-' | tr '[:upper:]' '[:lower:]')
echo "| $tool_display_name | \`$current_version\` | \`$new_version\` | [$repo_url]($repo_url) |" >> $GITHUB_STEP_SUMMARY
done < updates.txt
echo "" >> $GITHUB_STEP_SUMMARY
echo "A pull request will be created with these updates." >> $GITHUB_STEP_SUMMARY
- name: Create Pull Request
if: steps.check-updates.outputs.updates_available == 'true' && github.event.inputs.dry_run != 'true'
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update tool versions"
title: "chore: update tool versions"
body-path: pr_body.md
branch: automated-tool-updates
delete-branch: true
labels: |
dependencies
automation
add-paths: Makefile
- name: Dry run summary
if: github.event.inputs.dry_run == 'true' && steps.check-updates.outputs.updates_available == 'true'
run: |
echo "### Dry Run Mode - No PR Created ###"
echo ""
echo "The following updates are available:"
echo ""
cat pr_body.md
# Write to GitHub Step Summary
echo "## 🧪 Dry Run Mode" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**No PR was created.** The following updates are available:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Add the table to step summary
echo "| Tool | Current Version | New Version | Repository |" >> $GITHUB_STEP_SUMMARY
echo "|------|-----------------|-------------|------------|" >> $GITHUB_STEP_SUMMARY
while IFS='|' read -r var_name current_version new_version repo_url; do
tool_display_name=$(echo "$var_name" | sed 's/_VERSION$//' | tr '_' '-' | tr '[:upper:]' '[:lower:]')
echo "| $tool_display_name | \`$current_version\` | \`$new_version\` | [$repo_url]($repo_url) |" >> $GITHUB_STEP_SUMMARY
done < updates.txt