Skip to content

Create/Update release #126

Create/Update release

Create/Update release #126

name: Create/Update release
on:
workflow_dispatch:
inputs:
version:
type: string
description: Version number, e.g. 1.19 (not scary, will just open a PR)
required: true
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Validate input version number
run: |
VERSION="${{ github.event.inputs.version }}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Version is not a two digit semver version"
exit 1
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: 'microsoft/playwright'
path: playwright
ref: 'release-${{ github.event.inputs.version }}'
- uses: actions/setup-node@v3
with:
node-version: '18'
- 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: |
BRANCH_NAME="roll-release/$(date +"%d-%m-%y")"
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 github-actions
git config --global user.email 41898282+github-actions[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 ${{ github.event.inputs.version }} Playwright"
git push origin $BRANCH_NAME --force
- name: Create Pull Request
uses: actions/github-script@v6
if: ${{ steps.prepare-branch.outputs.HAS_CHANGES == '1' }}
with:
github-token: ${{ secrets.GH_SERVICE_ACCOUNT_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 ${{ github.event.inputs.version }} Playwright',
body: 'Upstream commit: https://github.com/microsoft/playwright/commit/${{ steps.prepare-branch.outputs.GIT_COMMIT }}',
});