Skip to content

🔄 Update VS Code Version Window #18

🔄 Update VS Code Version Window

🔄 Update VS Code Version Window #18

name: 🔄 Update VS Code Version Window
on:
schedule:
- cron: "0 9 * * 1" # Weekly on Monday at 9 AM UTC
workflow_dispatch: # Allow manual trigger
jobs:
update-versions:
runs-on: ubuntu-latest
steps:
- name: 👷🏻 Checkout Repository
uses: actions/checkout@v6
- name: ⚙️ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: 🔍 Fetch VS Code versions with retry
id: versions
uses: nick-fields/retry@v4
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: |
# Fetch all stable releases
RELEASES=$(curl -sf https://update.code.visualstudio.com/api/releases/stable)
if [[ -z "$RELEASES" ]]; then
echo "❌ Failed to fetch VS Code releases"
exit 1
fi
# Get unique major.minor versions and find latest patch for each
# This gives us the latest 2 major versions with their latest patches
MAJOR_VERSIONS=$(echo $RELEASES | jq -r '.[]' | sed -E 's/([0-9]+\.[0-9]+)\..*/\1/' | uniq | head -2)
# Validate we have at least 2 major versions
COUNT=$(echo "$MAJOR_VERSIONS" | wc -l | tr -d ' ')
if [[ "$COUNT" -lt 2 ]]; then
echo "❌ Not enough major versions available (found $COUNT, need 2)"
exit 1
fi
# Get the latest patch version for each of the 2 major versions
MAJOR_1=$(echo "$MAJOR_VERSIONS" | sed -n '1p')
MAJOR_2=$(echo "$MAJOR_VERSIONS" | sed -n '2p')
LATEST=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_1\"))" | head -1)
OLDEST=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_2\"))" | head -1)
# Validate version format (x.y.z)
for VERSION in $LATEST $OLDEST; do
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid version format: $VERSION"
exit 1
fi
done
echo "✅ Found valid versions:"
echo " Latest (max): $LATEST"
echo " Oldest (min): $OLDEST"
echo "latest=$LATEST" >> $GITHUB_OUTPUT
echo "oldest=$OLDEST" >> $GITHUB_OUTPUT
# Get current values
CURRENT_MAX=$(jq -r '.supportedVersions["vscode-max"]' packages/extester/package.json)
CURRENT_MIN=$(jq -r '.supportedVersions["vscode-min"]' packages/extester/package.json)
echo "current_max=$CURRENT_MAX" >> $GITHUB_OUTPUT
echo "current_min=$CURRENT_MIN" >> $GITHUB_OUTPUT
- name: 🔎 Check if update needed
id: check
run: |
NEEDS_UPDATE=false
CHANGES=""
if [[ "${{ steps.versions.outputs.latest }}" != "${{ steps.versions.outputs.current_max }}" ]]; then
echo "📌 Max version changed: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }}"
NEEDS_UPDATE=true
CHANGES="${CHANGES}- vscode-max: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }}\n"
fi
if [[ "${{ steps.versions.outputs.oldest }}" != "${{ steps.versions.outputs.current_min }}" ]]; then
echo "📌 Min version changed: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}"
NEEDS_UPDATE=true
CHANGES="${CHANGES}- vscode-min: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}\n"
fi
if [[ "$NEEDS_UPDATE" = "false" ]]; then
echo "✅ No updates needed - versions are current"
fi
echo "needs_update=$NEEDS_UPDATE" >> $GITHUB_OUTPUT
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo -e "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 📝 Update package.json
if: steps.check.outputs.needs_update == 'true'
run: |
echo "Updating package.json..."
jq --arg min "${{ steps.versions.outputs.oldest }}" \
--arg max "${{ steps.versions.outputs.latest }}" \
'.supportedVersions["vscode-min"] = $min | .supportedVersions["vscode-max"] = $max' \
packages/extester/package.json > tmp.json
mv tmp.json packages/extester/package.json
# Verify the update
NEW_MIN=$(jq -r '.supportedVersions["vscode-min"]' packages/extester/package.json)
NEW_MAX=$(jq -r '.supportedVersions["vscode-max"]' packages/extester/package.json)
if [[ "$NEW_MIN" != "${{ steps.versions.outputs.oldest }}" ]] || \
[[ "$NEW_MAX" != "${{ steps.versions.outputs.latest }}" ]]; then
echo "❌ Failed to update package.json correctly"
exit 1
fi
echo "✅ package.json updated successfully"
- name: 🔀 Create Pull Request
if: steps.check.outputs.needs_update == 'true'
id: create_pr
uses: peter-evans/create-pull-request@v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
chore: update VS Code version window to latest 2 releases
- vscode-min: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}
- vscode-max: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }}
branch: auto-update-vscode-versions
delete-branch: true
push-to-fork: djelinek/vscode-extension-tester
title: "Update VS Code version window (${{ steps.versions.outputs.oldest }} - ${{ steps.versions.outputs.latest }})"
body: |
## 🔄 VS Code Version Window Update
This PR updates the supported VS Code version window to the latest 2 stable major releases.
### 📊 Version Changes
| Position | Before | After | Status |
|----------|--------|-------|--------|
| **Min** | `${{ steps.versions.outputs.current_min }}` | `${{ steps.versions.outputs.oldest }}` | ${{ steps.versions.outputs.current_min != steps.versions.outputs.oldest && '✅ Updated' || '➖ No change' }} |
| **Max** | `${{ steps.versions.outputs.current_max }}` | `${{ steps.versions.outputs.latest }}` | ${{ steps.versions.outputs.current_max != steps.versions.outputs.latest && '✅ Updated' || '➖ No change' }} |
### 📝 Files Modified
- ✅ [`packages/extester/package.json`](https://github.com/${{ github.repository }}/blob/${{ github.head_ref || github.ref_name }}/packages/extester/package.json) - Updated `vscode-min` and `vscode-max`
### 🧪 Testing
CI will automatically test against both versions:
- ✅ Min: `${{ steps.versions.outputs.oldest }}`
- ✅ Max: `${{ steps.versions.outputs.latest }}`
### ✅ Review Checklist
- [ ] All CI tests pass for both versions
- [ ] No breaking changes detected in test results
- [ ] Page objects still work across all versions
- [ ] Ready to merge and release
### 📦 Next Steps After Merge
1. ✅ Verify all tests passed
2. 🚀 Trigger release workflow if needed
3. 📚 Update documentation if there are breaking changes
---
🤖 *This PR was automatically created by the [version update workflow](https://github.com/${{ github.repository }}/actions/workflows/update-vscode-versions.yml)*
labels: |
automation
maintenance
dependencies
- name: 💬 Create PR using GitHub CLI
if: steps.check.outputs.needs_update == 'true' && steps.create_pr.outputs.pull-request-operation == 'created'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the PR number from the create-pull-request action
PR_NUMBER="${{ steps.create_pr.outputs.pull-request-number }}"
if [ -z "$PR_NUMBER" ]; then
echo "No PR number found, attempting to create PR via GitHub CLI..."
# Create PR using gh CLI
gh pr create \
--repo redhat-developer/vscode-extension-tester \
--head djelinek:auto-update-vscode-versions \
--base main \
--title "Update VS Code version window (${{ steps.versions.outputs.oldest }} - ${{ steps.versions.outputs.latest }})" \
--body "## 🔄 VS Code Version Window Update
This PR updates the supported VS Code version window to the latest 2 stable major releases.
### 📊 Version Changes
| Position | Before | After | Status |
|----------|--------|-------|--------|
| **Min** | \`${{ steps.versions.outputs.current_min }}\` | \`${{ steps.versions.outputs.oldest }}\` | ✅ Updated |
| **Max** | \`${{ steps.versions.outputs.current_max }}\` | \`${{ steps.versions.outputs.latest }}\` | ✅ Updated |
### 📝 Files Modified
- ✅ [\`packages/extester/package.json\`](https://github.com/redhat-developer/vscode-extension-tester/blob/auto-update-vscode-versions/packages/extester/package.json) - Updated \`vscode-min\` and \`vscode-max\`
### 🧪 Testing
CI will automatically test against both versions:
- ✅ Min: \`${{ steps.versions.outputs.oldest }}\`
- ✅ Max: \`${{ steps.versions.outputs.latest }}\`
### ✅ Review Checklist
- [ ] All CI tests pass for both versions
- [ ] No breaking changes detected in test results
- [ ] Page objects still work across all versions
- [ ] Ready to merge and release
### 📦 Next Steps After Merge
1. ✅ Verify all tests passed
2. 🚀 Trigger release workflow if needed
3. 📚 Update documentation if there are breaking changes
---
🤖 *This PR was automatically created by the [version update workflow](https://github.com/redhat-developer/vscode-extension-tester/actions/workflows/update-vscode-versions.yml)*" \
--label automation,maintenance,dependencies || echo "PR creation failed or already exists"
fi
- name: 💬 Comment on PR with test instructions
if: steps.check.outputs.needs_update == 'true' && steps.create_pr.outputs.pull-request-number
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ steps.create_pr.outputs.pull-request-number }} \
--repo redhat-developer/vscode-extension-tester \
--body "## 🧪 Testing Instructions
The CI pipeline will automatically test both versions. Monitor the test results in the checks below.
### 🔍 What to Review
- ✅ Check that all CI tests pass
- ⚠️ Look for any failures or warnings in test output
- 📸 Review screenshots if any tests fail
- 🐛 Check for breaking changes in page objects
### 🛠️ Manual Testing (Optional)
If you want to test locally before merging:
\`\`\`bash
# Test with min version
CODE_VERSION=min npm test
# Test with max version
CODE_VERSION=max npm test
\`\`\`
### ✅ Ready to Merge?
If all tests pass and there are no breaking changes, this PR is ready to merge! 🎉
After merging, consider:
1. Creating a new release with the updated version support
2. Updating documentation if needed
3. Announcing the new supported versions"
- name: ⚠️ Notify on failure (legacy)
if: failure()
uses: actions/github-script@v8
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ steps.create_pr.outputs.pull-request-number }},
body: `## 🧪 Testing Instructions
The CI pipeline will automatically test both versions. Monitor the test results in the checks below.
### 🔍 What to Review
- ✅ Check that all CI tests pass
- ⚠️ Look for any failures or warnings in test output
- 📸 Review screenshots if any tests fail
- 🐛 Check for breaking changes in page objects
### 🛠️ Manual Testing (Optional)
If you want to test locally before merging:
\`\`\`bash
# Test with min version
CODE_VERSION=min npm test
# Test with max version
CODE_VERSION=max npm test
\`\`\`
### ✅ Ready to Merge?
If all tests pass and there are no breaking changes, this PR is ready to merge! 🎉
After merging, consider:
1. Creating a new release with the updated version support
2. Updating documentation if needed
3. Announcing the new supported versions`
})
- name: ⚠️ Notify on failure
if: failure()
uses: actions/github-script@v8
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '⚠️ VS Code version update workflow failed',
body: `## ⚠️ Automated Version Update Failed
The automated VS Code version update workflow encountered an error.
### 📋 Details
- **Workflow Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- **Triggered**: ${{ github.event_name }}
- **Branch**: ${{ github.ref_name }}
### 🔧 Action Required
Please investigate the workflow failure and update versions manually if needed.
### 📝 Manual Update Steps
1. Check the latest 2 VS Code stable versions at https://code.visualstudio.com/updates
2. Update \`packages/extester/package.json\`:
- \`vscode-min\`: oldest of the 2 versions
- \`vscode-max\`: newest of the 2 versions
3. Run tests and create a release
---
🤖 *This issue was automatically created by the version update workflow*`,
labels: ['automation', 'bug', 'maintenance']
})