Skip to content
Merged
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
13 changes: 1 addition & 12 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ on:
required: false
type: boolean
default: false
fetch-depth:
description: Number of commits to fetch (0 for full history, empty for auto-detect)
required: false
type: string
default: ''
cache-name:
description: Name for cache restore (restores {name}.gz with key {name}-)
required: false
Expand Down Expand Up @@ -120,16 +115,11 @@ jobs:
id: depth
shell: bash
env:
FETCH_DEPTH: ${{ inputs.fetch-depth }}
PR_COMMITS: ${{ github.event.pull_request.commits }}
run: |
# Use explicit value if provided
if [ -n "$FETCH_DEPTH" ]; then
echo "val=$FETCH_DEPTH" >> "$GITHUB_OUTPUT"
# For PRs, use commit count plus buffer for merge base
elif [ -n "$PR_COMMITS" ]; then
if [ -n "$PR_COMMITS" ]; then
echo "val=$((PR_COMMITS + 2))" >> "$GITHUB_OUTPUT"
# For push events, read commit count from event payload
else
COMMIT_COUNT=$(jq -e '.commits | length // 0' "$GITHUB_EVENT_PATH" 2>/dev/null) || COMMIT_COUNT=0
echo "val=$((COMMIT_COUNT + 1))" >> "$GITHUB_OUTPUT"
Expand All @@ -139,7 +129,6 @@ jobs:
with:
ref: ${{ inputs.ref || github.ref }}
fetch-depth: ${{ steps.depth.outputs.val }}
fetch-tags: ${{ inputs.fetch-depth != '' }}
- name: Pull latest changes from head ref for PRs
if: contains(github.head_ref, 'renovate/')
shell: bash
Expand Down
62 changes: 8 additions & 54 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,82 +117,36 @@ jobs:
secrets:
SELENIUM_CI_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}

calculate-changelog-depth:
name: Calculate Changelog Depth
needs: [parse-tag, commit-versions]
runs-on: ubuntu-latest
outputs:
depth: ${{ steps.calc.outputs.depth }}
steps:
- name: Calculate fetch depth from tag
id: calc
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.parse-tag.outputs.version }}
TAG: ${{ needs.parse-tag.outputs.tag }}
shell: bash
run: |
set -euo pipefail
if [[ "$VERSION" =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}

if [ "$PATCH" -gt 1 ]; then
PREV="selenium-${MAJOR}.${MINOR}.$((PATCH-1))"
elif [ "$PATCH" -eq 1 ]; then
PREV="selenium-${MAJOR}.${MINOR}.0"
elif [ "$MINOR" -gt 0 ]; then
PREV="selenium-${MAJOR}.$((MINOR-1)).0"
else
# First release of major version (X.0.0), use full history
echo "depth=0" >> "$GITHUB_OUTPUT"
exit 0
fi

COUNT=$(gh api "repos/${{ github.repository }}/compare/${PREV}...staging/release-${TAG}" --jq '.total_commits' 2>/dev/null) || {
echo "::warning::Failed to get commit count, using full history"
echo "depth=0" >> "$GITHUB_OUTPUT"
exit 0
}
echo "depth=$((COUNT + 1))" >> "$GITHUB_OUTPUT"
else
echo "depth=0" >> "$GITHUB_OUTPUT"
fi

update-changelogs:
name: Generate Changelogs
needs: [parse-tag, calculate-changelog-depth]
needs: [parse-tag, commit-versions]
uses: ./.github/workflows/bazel.yml
with:
name: Update changelogs
ref: staging/release-${{ needs.parse-tag.outputs.tag }}
run: ./go ${{ needs.parse-tag.outputs.language }}:changelogs
run: ./scripts/github-actions/deepen-fetch-to-tag.sh ${{ needs.parse-tag.outputs.tag }} && ./go ${{ needs.parse-tag.outputs.language }}:changelogs
Comment thread
titusfortner marked this conversation as resolved.
artifact-name: patch-changelogs
fetch-depth: ${{ needs.calculate-changelog-depth.outputs.depth }}

update-rust-changelogs:
name: Update Rust Changelogs
needs: [parse-tag, commit-versions, calculate-changelog-depth]
needs: [parse-tag, commit-versions]
if: needs.parse-tag.outputs.language == 'all'
uses: ./.github/workflows/bazel.yml
with:
name: Update Rust Changelogs
ref: staging/release-${{ needs.parse-tag.outputs.tag }}
run: ./go rust:changelogs
run: ./scripts/github-actions/deepen-fetch-to-tag.sh ${{ needs.parse-tag.outputs.tag }} && ./go rust:changelogs
artifact-name: patch-rust-changelogs
fetch-depth: ${{ needs.calculate-changelog-depth.outputs.depth }}

update-authors:
name: Update Authors
needs: [parse-tag, calculate-changelog-depth]
needs: [parse-tag, commit-versions]
if: needs.parse-tag.outputs.language == 'all'
uses: ./.github/workflows/bazel.yml
with:
name: Update Authors
run: ./go authors
run: ./scripts/github-actions/deepen-fetch-to-tag.sh ${{ needs.parse-tag.outputs.tag }} && ./go authors
artifact-name: patch-authors
fetch-depth: ${{ needs.calculate-changelog-depth.outputs.depth }}

update-manager:
name: Update Selenium Manager Binaries
Expand Down Expand Up @@ -297,7 +251,7 @@ jobs:

unlock-trunk-on-failure:
name: Unlock Trunk on Failure
needs: [parse-tag, restrict-trunk, generate-rust-version, push-rust-version, selenium-manager, update-versions, commit-versions, calculate-changelog-depth, update-changelogs, update-rust-changelogs, update-authors, update-manager, create-pr]
needs: [parse-tag, restrict-trunk, generate-rust-version, push-rust-version, selenium-manager, update-versions, commit-versions, update-changelogs, update-rust-changelogs, update-authors, update-manager, create-pr]
if: always() && needs.restrict-trunk.result == 'success' && needs.create-pr.result != 'success'
uses: ./.github/workflows/restrict-trunk.yml
with:
Expand All @@ -309,7 +263,7 @@ jobs:
on-prerelease-failure:
name: On Pre-release Failure
runs-on: ubuntu-latest
needs: [parse-tag, verify-cdp, restrict-trunk, generate-rust-version, push-rust-version, selenium-manager, update-versions, commit-versions, calculate-changelog-depth, update-changelogs, update-rust-changelogs, update-authors, update-manager, create-pr]
needs: [parse-tag, verify-cdp, restrict-trunk, generate-rust-version, push-rust-version, selenium-manager, update-versions, commit-versions, update-changelogs, update-rust-changelogs, update-authors, update-manager, create-pr]
if: failure() || cancelled()
steps:
- name: Slack Notification
Expand Down
2 changes: 1 addition & 1 deletion rake_tasks/python.rake
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ end
desc 'Update Python changelog'
task :changelogs do
header = "Selenium #{python_version}"
SeleniumRake.update_changelog(python_version, 'py', 'py/selenium/webdriver', 'py/CHANGES', header)
SeleniumRake.update_changelog(python_version, 'python', 'py/selenium/webdriver', 'py/CHANGES', header)
Comment thread
titusfortner marked this conversation as resolved.
end

desc 'Update Python version'
Expand Down
2 changes: 1 addition & 1 deletion rake_tasks/ruby.rake
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ end
desc 'Update Ruby changelog'
task :changelogs do
header = "#{ruby_version} (#{Time.now.strftime('%Y-%m-%d')})\n========================="
SeleniumRake.update_changelog(ruby_version, 'rb', 'rb/lib/', 'rb/CHANGES', header)
SeleniumRake.update_changelog(ruby_version, 'ruby', 'rb/lib/', 'rb/CHANGES', header)
end

desc 'Update Ruby version'
Expand Down
30 changes: 30 additions & 0 deletions scripts/github-actions/deepen-fetch-to-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Deepen a shallow checkout back through the release before the given one and fetch the tags the
# changelog tasks look up. Takes the release tag being prepared, e.g. selenium-4.51.0 or selenium-4.51.2-python.
set -euo pipefail

release="${1:?release tag required}"
head="$(git rev-parse HEAD)"

IFS=.- read -r _ major minor patch language <<< "$release"

# Determine the previous release tag to compare against depending on tag pattern
Comment thread
titusfortner marked this conversation as resolved.
if [ "$patch" -gt 1 ]; then previous_release="selenium-${major}.${minor}.$((patch-1))-${language}"
elif [ "$patch" -eq 1 ]; then previous_release="selenium-${major}.${minor}.0"
elif [ "$minor" -gt 0 ]; then previous_release="selenium-${major}.$((minor-1)).0"
else previous_release="$(git ls-remote --tags --refs origin "selenium-$((major-1)).*" | awk -F/ '{print $NF}' | grep -E '^selenium-[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)"
Comment thread
titusfortner marked this conversation as resolved.
fi

# Fetch history backward from HEAD to the previous release tag
git fetch --no-tags --shallow-exclude="$previous_release" origin "$head"

# Make the previous release commit available for symmetric difference commands (`<tag>...HEAD`).
git fetch --no-tags --deepen=1 origin "$head"

# Determine which tags the changelog generator needs.
# Minor: get any patch release tags of the previous minor line
# Patch: only needs the previous release tag.
if [ "$patch" -eq 0 ]; then pattern="${previous_release%.*}.*"; else pattern="$previous_release"; fi

# Label tags locally without fetching additional/unnecessary data.
git fetch --no-tags origin "+refs/tags/${pattern}:refs/tags/${pattern}"