Roll Stable #170
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: Roll Stable | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/github-script@v7 | |
| id: determine-version | |
| with: | |
| script: | | |
| const allBranches = await github.paginate("GET /repos/{owner}/{repo}/branches", { | |
| owner: 'microsoft', | |
| repo: 'playwright', | |
| }); | |
| const relevantBranches = allBranches.filter(branch => branch.name.startsWith('release-')); | |
| relevantBranches.sort((a, b) => { | |
| const aVersion = parseFloat(a.name.split('-')[1]); | |
| const bVersion = parseFloat(b.name.split('-')[1]); | |
| return aVersion - bVersion; | |
| }); | |
| return relevantBranches.pop().name.replace(/^release-/, ''); | |
| result-encoding: string | |
| - uses: actions/checkout@v4 | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: 'microsoft/playwright' | |
| path: playwright | |
| ref: 'release-${{ steps.determine-version.outputs.result }}' | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Delete previous Stable | |
| run: node src/versions.js --delete stable | |
| - name: Roll | |
| run: npm run roll | |
| env: | |
| SRC_DIR: ./playwright | |
| - name: Create new version | |
| run: npm run version-all | |
| - name: Prepare branch | |
| id: prepare-branch | |
| run: | | |
| VERSION=${{ steps.determine-version.outputs.result }} | |
| BRANCH_NAME="roll/stable-$VERSION" | |
| set +e | |
| git diff -s --exit-code | |
| HAS_CHANGES="$?" | |
| set -e | |
| GIT_COMMIT="$(cd playwright && git rev-parse HEAD && cd ..)" | |
| echo "HAS_CHANGES=$HAS_CHANGES" >> $GITHUB_OUTPUT | |
| echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| echo "GIT_COMMIT=$GIT_COMMIT" >> $GITHUB_OUTPUT | |
| if [[ $HAS_CHANGES == 0 ]]; then | |
| echo "No changes detected, skipping PR" | |
| exit 0 | |
| fi | |
| git config --global user.name microsoft-playwright-automation[bot] | |
| git config --global user.email 203992400+microsoft-playwright-automation[bot]@users.noreply.github.com | |
| git checkout -b "$BRANCH_NAME" | |
| # We only want to upgrade the version itself, not the next release | |
| git add "*versioned*" | |
| git add "**/versions.json" | |
| git commit -m "feat(roll): roll to $VERSION Playwright" | |
| git push origin $BRANCH_NAME --force | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.PLAYWRIGHT_APP_ID }} | |
| private-key: ${{ secrets.PLAYWRIGHT_PRIVATE_KEY }} | |
| - name: Check for existing Pull Request | |
| id: check-pr | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| const { data: pullRequests } = await github.rest.pulls.list({ | |
| owner: 'microsoft', | |
| repo: 'playwright.dev', | |
| head: `microsoft:${{ steps.prepare-branch.outputs.BRANCH_NAME }}`, | |
| state: 'open' | |
| }); | |
| return pullRequests.length > 0 ? 'true' : 'false'; | |
| result-encoding: string | |
| - name: Create Pull Request | |
| uses: actions/github-script@v7 | |
| if: ${{ steps.prepare-branch.outputs.HAS_CHANGES == '1' && steps.check-pr.outputs.result == 'false' }} | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| await github.rest.pulls.create({ | |
| owner: 'microsoft', | |
| repo: 'playwright.dev', | |
| head: 'microsoft:${{ steps.prepare-branch.outputs.BRANCH_NAME }}', | |
| base: 'main', | |
| title: 'feat(roll): roll to ${{ steps.determine-version.outputs.result }} Playwright', | |
| body: 'Upstream commit: https://github.com/microsoft/playwright/commit/${{ steps.prepare-branch.outputs.GIT_COMMIT }}', | |
| }); |