Skip to content

Commit 3ff8229

Browse files
committed
Release Workflow Improvements
1 parent 392e8a3 commit 3ff8229

2 files changed

Lines changed: 71 additions & 27 deletions

File tree

.github/workflows/patchright_release.yml

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,48 @@ on:
55
workflow_dispatch:
66
inputs:
77
version:
8-
description: 'Playwright Version (Base)'
8+
description: 'Playwright Version (e.g. v1.58.0 or 1.58.0)'
99
default: ''
1010
patchright_release:
11-
description: 'Patchright Release Version (e.g. `1.55.2`)'
11+
description: 'Patchright Release Version (e.g. v1.58.0 or 1.58.0) on pypi'
1212
default: ''
1313
# running every hour
1414
schedule:
1515
- cron: '0 * * * *'
1616

1717
env:
1818
REPO: ${{ github.repository }}
19+
patchright_release: ${{ github.event.inputs.patchright_release || '' }}
1920

2021
jobs:
21-
patchright-release-workflow:
22-
name: "Patchright-Python Workflow: Install, Patch, Build and Publish Patchright Python Package"
22+
check-release-version:
23+
name: Check Release Version
2324
runs-on: ubuntu-latest
24-
environment:
25-
name: pypi
26-
url: https://pypi.org/p/patchright
27-
permissions:
28-
contents: write
29-
id-token: write # For trusted Publishing
25+
outputs:
26+
proceed: ${{ steps.version_check.outputs.proceed }}
27+
playwright_version: ${{ steps.version_check.outputs.playwright_version }}
3028
steps:
3129
- name: Checkout Repository
3230
uses: actions/checkout@v6
3331

34-
- name: Install uv
35-
uses: astral-sh/setup-uv@v7
36-
37-
- name: Set up Python
38-
run: uv python install
39-
4032
- name: Check Release Version
4133
id: version_check
4234
run: |
43-
echo "patchright_release=${{ github.event.inputs.patchright_release }}" >> $GITHUB_ENV
4435
PLAYWRIGHT_VERSION=""
4536
if [ -n "${{ github.event.inputs.version }}" ]; then
46-
PLAYWRIGHT_VERSION="${{ github.event.inputs.version }}"
37+
raw_version="${{ github.event.inputs.version }}"
38+
PLAYWRIGHT_VERSION="v${raw_version#v}"
39+
echo "proceed=true" >>$GITHUB_OUTPUT
40+
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
41+
if [ -n "${{ github.event.inputs.patchright_release }}" ]; then
42+
raw_patchright_release="${{ github.event.inputs.patchright_release }}"
43+
echo "patchright_release=${raw_patchright_release#v}" >> $GITHUB_ENV
44+
fi
45+
elif [ -n "${{ github.event.inputs.patchright_release }}" ]; then
46+
raw_patchright_release="${{ github.event.inputs.patchright_release }}"
47+
echo "patchright_release=${raw_patchright_release#v}" >> $GITHUB_ENV
48+
response=$(curl --silent "https://api.github.com/repos/microsoft/playwright-python/releases/latest")
49+
PLAYWRIGHT_VERSION=$(echo "$response" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
4750
echo "proceed=true" >>$GITHUB_OUTPUT
4851
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
4952
else
@@ -55,12 +58,41 @@ jobs:
5558
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
5659
fi
5760
61+
run-patchright-tests:
62+
name: Run Patchright Tests
63+
needs: check-release-version
64+
if: needs.check-release-version.outputs.proceed == 'true'
65+
uses: ./.github/workflows/patchright_tests.yml
66+
with:
67+
playwright_version: ${{ needs.check-release-version.outputs.playwright_version }}
68+
69+
patchright-release-workflow:
70+
name: "Patchright-Python Workflow: Install, Patch, Build and Publish Patchright Python Package"
71+
needs: [check-release-version, run-patchright-tests]
72+
runs-on: ubuntu-latest
73+
environment:
74+
name: pypi
75+
url: https://pypi.org/p/patchright
76+
permissions:
77+
contents: write
78+
id-token: write # For trusted Publishing
79+
steps:
80+
- name: Checkout Repository
81+
uses: actions/checkout@v6
82+
83+
- name: Install uv
84+
uses: astral-sh/setup-uv@v7
85+
86+
- name: Set up Python
87+
run: uv python install
88+
5889
- name: Install Playwright-Python Package
59-
if: steps.version_check.outputs.proceed == 'true'
90+
env:
91+
playwright_version: ${{ needs.check-release-version.outputs.playwright_version }}
6092
run: |
6193
uv sync --all-groups
6294
if [ -n "$patchright_release" ]; then
63-
PATCHRIGHT_RELEASE="$patchright_release"
95+
PATCHRIGHT_RELEASE="${patchright_release#v}"
6496
else
6597
PLAYWRIGHT_MINOR=${playwright_version#v}
6698
PLAYWRIGHT_MINOR=${PLAYWRIGHT_MINOR%.*}
@@ -72,13 +104,11 @@ jobs:
72104
uv add -r playwright-python/local-requirements.txt --dev
73105
74106
- name: Patch Playwright-Python Package
75-
if: steps.version_check.outputs.proceed == 'true'
76107
run: |
77108
uv run patch_python_package.py
78109
uvx ruff format playwright-python
79110
80111
- name: Build Patchright-Python Package
81-
if: steps.version_check.outputs.proceed == 'true'
82112
run: |
83113
cd playwright-python
84114
uv pip install -e .
@@ -87,21 +117,19 @@ jobs:
87117
done
88118
89119
- name: Create Empty Versioning Release
90-
if: steps.version_check.outputs.proceed == 'true'
91120
uses: actions/create-release@v1
92121
env:
93122
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94123
with:
95-
tag_name: ${{ steps.version_check.outputs.playwright_version }}
96-
release_name: ${{ steps.version_check.outputs.playwright_version }}
124+
tag_name: ${{ needs.check-release-version.outputs.playwright_version }}
125+
release_name: ${{ needs.check-release-version.outputs.playwright_version }}
97126
body: |
98127
This is an automatic deployment in response to a new release of [microsoft/playwright-python](https://github.com/microsoft/playwright-python).
99128
This Release is only used for Versioning.
100129
draft: false
101130
prerelease: false
102131

103132
- name: Publish Patchright-Python Package
104-
if: steps.version_check.outputs.proceed == 'true'
105133
uses: pypa/gh-action-pypi-publish@release/v1
106134
with:
107135
packages-dir: playwright-python/dist/

.github/workflows/patchright_tests.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
name: Patchright Chromium Tests
22

33
on:
4+
workflow_call:
5+
inputs:
6+
playwright_version:
7+
description: 'Playwright Version to test against, e.g. v1.58.0 or 1.58.0. If empty, latest release is used.'
8+
required: false
9+
type: string
410
workflow_dispatch:
11+
inputs:
12+
playwright_version:
13+
description: 'Playwright Version to test against, e.g. v1.58.0 or 1.58.0. If empty, latest release is used.'
14+
required: false
15+
type: string
516
push:
617
branches: [main]
718
pull_request:
@@ -25,7 +36,12 @@ jobs:
2536
- name: Install Playwright-Python Package
2637
run: |
2738
uv sync --all-groups
28-
PLAYWRIGHT_TAG=$(curl -fsSL "https://api.github.com/repos/microsoft/playwright-python/releases/latest" | jq -r '.tag_name')
39+
PLAYWRIGHT_TAG="${{ inputs.playwright_version || github.event.inputs.playwright_version }}"
40+
if [ -z "$PLAYWRIGHT_TAG" ]; then
41+
PLAYWRIGHT_TAG=$(curl -fsSL "https://api.github.com/repos/microsoft/playwright-python/releases/latest" | jq -r '.tag_name')
42+
else
43+
PLAYWRIGHT_TAG="v${PLAYWRIGHT_TAG#v}"
44+
fi
2945
PLAYWRIGHT_MINOR=${PLAYWRIGHT_TAG#v}
3046
PLAYWRIGHT_MINOR=${PLAYWRIGHT_MINOR%.*}
3147
PATCHRIGHT_RELEASE=$(curl -fsSL "https://api.github.com/repos/Kaliiiiiiiiii-Vinyzu/patchright/releases?per_page=100" | jq -r --arg minor "$PLAYWRIGHT_MINOR" '[.[].tag_name | ltrimstr("v") | select(startswith($minor + ".")) | select((try (split(".") | map(tonumber) | length) catch 0) == 3)] | sort_by(split(".") | map(tonumber)) | last')

0 commit comments

Comments
 (0)