🔄 Update VS Code Version Window #7
This file contains hidden or 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
| 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 3 major versions with their latest patches | |
| MAJOR_VERSIONS=$(echo $RELEASES | jq -r '.[]' | sed -E 's/([0-9]+\.[0-9]+)\..*/\1/' | uniq | head -3) | |
| # Validate we have at least 3 major versions | |
| COUNT=$(echo "$MAJOR_VERSIONS" | wc -l | tr -d ' ') | |
| if [[ "$COUNT" -lt 3 ]]; then | |
| echo "❌ Not enough major versions available (found $COUNT, need 3)" | |
| exit 1 | |
| fi | |
| # Get the latest patch version for each of the 3 major versions | |
| MAJOR_1=$(echo "$MAJOR_VERSIONS" | sed -n '1p') | |
| MAJOR_2=$(echo "$MAJOR_VERSIONS" | sed -n '2p') | |
| MAJOR_3=$(echo "$MAJOR_VERSIONS" | sed -n '3p') | |
| LATEST=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_1\"))" | head -1) | |
| MIDDLE=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_2\"))" | head -1) | |
| OLDEST=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_3\"))" | head -1) | |
| # Validate version format (x.y.z) | |
| for VERSION in $LATEST $MIDDLE $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: $LATEST" | |
| echo " Middle: $MIDDLE" | |
| echo " Oldest: $OLDEST" | |
| echo "latest=$LATEST" >> $GITHUB_OUTPUT | |
| echo "middle=$MIDDLE" >> $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) | |
| CURRENT_MIDDLE=$(grep 'version: \[min,' .github/workflows/main.yml | sed -E 's/.*version: \[min, ([^,]+),.*/\1/' | tr -d ' ') | |
| echo "current_max=$CURRENT_MAX" >> $GITHUB_OUTPUT | |
| echo "current_min=$CURRENT_MIN" >> $GITHUB_OUTPUT | |
| echo "current_middle=$CURRENT_MIDDLE" >> $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}- 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}- Min: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}\n" | |
| fi | |
| if [[ "${{ steps.versions.outputs.middle }}" != "${{ steps.versions.outputs.current_middle }}" ]]; then | |
| echo "📌 Middle version changed: ${{ steps.versions.outputs.current_middle }} → ${{ steps.versions.outputs.middle }}" | |
| NEEDS_UPDATE=true | |
| CHANGES="${CHANGES}- Middle: ${{ steps.versions.outputs.current_middle }} → ${{ steps.versions.outputs.middle }}\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: 📝 Update CI workflow matrix | |
| if: steps.check.outputs.needs_update == 'true' | |
| run: | | |
| echo "Updating .github/workflows/main.yml..." | |
| # Update the version matrix in main.yml | |
| sed -i "s/version: \[min, [0-9.]\+, max\]/version: [min, ${{ steps.versions.outputs.middle }}, max]/" \ | |
| .github/workflows/main.yml | |
| # Verify the update | |
| UPDATED_MIDDLE=$(grep 'version: \[min,' .github/workflows/main.yml | sed -E 's/.*version: \[min, ([^,]+),.*/\1/' | tr -d ' ') | |
| if [[ "$UPDATED_MIDDLE" != "${{ steps.versions.outputs.middle }}" ]]; then | |
| echo "❌ Failed to update main.yml correctly" | |
| echo "Expected: ${{ steps.versions.outputs.middle }}" | |
| echo "Got: $UPDATED_MIDDLE" | |
| exit 1 | |
| fi | |
| echo "✅ main.yml 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 3 releases | |
| - vscode-min: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }} | |
| - vscode-middle: ${{ steps.versions.outputs.current_middle }} → ${{ steps.versions.outputs.middle }} | |
| - vscode-max: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }} | |
| branch: auto-update-vscode-versions | |
| delete-branch: true | |
| 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 3 stable releases. | |
| ### 📊 Version Changes | |
| | Position | Before | After | Status | | |
| |----------|--------|-------|--------| | |
| | **Min (Oldest)** | `${{ steps.versions.outputs.current_min }}` | `${{ steps.versions.outputs.oldest }}` | ${{ steps.versions.outputs.current_min != steps.versions.outputs.oldest && '✅ Updated' || '➖ No change' }} | | |
| | **Middle** | `${{ steps.versions.outputs.current_middle }}` | `${{ steps.versions.outputs.middle }}` | ${{ steps.versions.outputs.current_middle != steps.versions.outputs.middle && '✅ Updated' || '➖ No change' }} | | |
| | **Max (Latest)** | `${{ 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` | |
| - ✅ [`.github/workflows/main.yml`](https://github.com/${{ github.repository }}/blob/${{ github.head_ref || github.ref_name }}/.github/workflows/main.yml) - Updated CI test matrix middle version | |
| ### 🧪 Testing | |
| CI will automatically test against all 3 versions: | |
| - ✅ Min: `${{ steps.versions.outputs.oldest }}` | |
| - ✅ Middle: `${{ steps.versions.outputs.middle }}` | |
| - ✅ Max: `${{ steps.versions.outputs.latest }}` | |
| ### ✅ Review Checklist | |
| - [ ] All CI tests pass for all 3 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: 💬 Comment on PR with test instructions | |
| if: steps.check.outputs.needs_update == 'true' && steps.create_pr.outputs.pull-request-number | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| 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 all 3 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 middle version | |
| CODE_VERSION=${{ steps.versions.outputs.middle }} 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 3 VS Code stable versions at https://code.visualstudio.com/updates | |
| 2. Update \`packages/extester/package.json\`: | |
| - \`vscode-min\`: oldest of the 3 versions | |
| - \`vscode-max\`: newest of the 3 versions | |
| 3. Update \`.github/workflows/main.yml\`: | |
| - Update the middle version in the test matrix | |
| 4. Run tests and create a release | |
| --- | |
| 🤖 *This issue was automatically created by the version update workflow*`, | |
| labels: ['automation', 'bug', 'maintenance'] | |
| }) | |
| # Made with Bob |