Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github Action - Prepare Python Release #12596

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/update-python-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Prepare Python Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (format X.Y.Z)'
required: true
default: ''
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update_version:
name: Update Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Run Update Version script with input.version
run: ./scripts/github-actions/update-version.sh
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: Commit files
id: git
run: |
export CHANGES=$(git status -s)
if [ -n "$CHANGES" ]; then
git config --local user.email "selenium-ci@users.noreply.github.com"
git config --local user.name "Selenium CI Bot"
git add common/mirror/selenium
git commit -m "Update Python Release Version files (`date`)" -a
echo "::set-output name=commit::true"
fi
- name: Push changes
if: steps.git.outputs.commit == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SELENIUM_CI_TOKEN }}
branch: ${{ github.ref }}
4 changes: 3 additions & 1 deletion py/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
import os
import os.path
from ...version import SE_VERSION

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -56,7 +57,8 @@
# built documents.
#
# The short X.Y version.
version = '4.10'
version = ".".join(SE_VERSION.split(".", 2)[:2])

# The full version, including alpha/beta/rc tags.
release = version

Expand Down
Empty file modified py/docs/source/index.rst
100755 → 100644
Empty file.
5 changes: 2 additions & 3 deletions py/selenium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.


__version__ = "4.11.2"
from ..version import SE_VERSION
__version__ = SE_VERSION
3 changes: 2 additions & 1 deletion py/selenium/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
from .wpewebkit.options import Options as WPEWebKitOptions # noqa
from .wpewebkit.service import Service as WPEWebKitService # noqa
from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa
from ...version import SE_VERSION

__version__ = "4.11.2"
__version__ = SE_VERSION

# We need an explicit __all__ because the above won't otherwise be exported.
__all__ = [
Expand Down
3 changes: 2 additions & 1 deletion py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from os.path import dirname, join, abspath
from setuptools import setup
from setuptools.command.install import install
from version import SE_VERSION


for scheme in INSTALL_SCHEMES.values():
Expand All @@ -27,7 +28,7 @@
setup_args = {
'cmdclass': {'install': install},
'name': 'selenium',
'version': "4.11.2",
'version': SE_VERSION,
'license': 'Apache 2.0',
'description': 'Python bindings for Selenium',
'long_description': open(join(abspath(dirname(__file__)), "README.rst")).read(),
Expand Down
1 change: 1 addition & 0 deletions py/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SE_VERSION = "4.11.2"
42 changes: 42 additions & 0 deletions scripts/github-actions/update-python-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

RELEASE_VERSION=$RELEASE_VERSION

if [[ -z "$RELEASE_VERSION" ]]; then
echo "Usage: $0 <release-version>"
exit 1
fi

# Regular expression pattern for #.#.# format
version_pattern="^[0-9]+\.[0-9]+\.[0-9]+$"

if ! [[ "$RELEASE_VERSION" =~ $version_pattern ]]; then
echo "Invalid version format. Please use the format #.#.#"
exit 1
fi

# Go to python dir
cd "$(dirname "$0")"/../../py

# Replace version in py/version.py
awk -v new_version="$RELEASE_VERSION" '/SE_VERSION =/ && !found { sub(/SE_VERSION = "[0-9]+\.[0-9]+\.[0-9]+"/, "SE_VERSION = \"" new_version "\""); found = 1 } { print }' version.py > tmp.txt && mv tmp.txt version.py

# Replace SE_VERSION in py/BUILD.bazel
awk -v new_version="$RELEASE_VERSION" '/SE_VERSION =/ && !found { sub(/SE_VERSION = "[0-9]+\.[0-9]+\.[0-9]+"/, "SE_VERSION = \"" new_version "\""); found = 1 } { print }' BUILD.bazel > tmp.txt && mv tmp.txt BUILD.bazel

# Replace selenium-#.#.#.tar.gz with selenium-RELEASE_VERSION.tar.gz in docs/source/index.rst
awk -v new_version="$RELEASE_VERSION" '/selenium-[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz/ && !found { sub(/selenium-[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz/, "selenium-" new_version ".tar.gz"); found = 1 } { print }' docs/source/index.rst > tmp.txt && mv tmp.txt docs/source/index.rst