📦 SeleniumHQ / selenium

📄 pre-release.yml · 234 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234name: Release Preparation

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'Selenium version to release'
        required: true
      chrome_channel:
        description: 'Chrome Channel for CDP'
        required: true
        type: choice
        default: "stable"
        options:
          - stable
          - early-stable

permissions:
  contents: read

jobs:
  get-approval:
    name: Get Approval
    uses: ./.github/workflows/get-approval.yml
    with:
      title: Release approval needed
      message: |
        Selenium ${{ github.event.inputs.version }} release preparation started.
        Please approve to lock trunk when ready.
    secrets:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

  # Rust jobs run in parallel with approval since work is not on trunk
  update-rust:
    name: Update Rust Version
    runs-on: ubuntu-latest
    if: github.event.repository.fork == false
    steps:
      - name: "Checkout repo"
        uses: actions/checkout@v4
        with:
          persist-credentials: false
          fetch-depth: 0
      - name: Setup Bazel
        uses: bazel-contrib/setup-bazel@0.18.0
        with:
          cache-save: false
          bazelisk-cache: true
          external-cache: |
            manifest:
              crates: rust/Cargo.Bazel.lock
              rules_ruby++ruby+ruby: rb/.ruby-version
          repository-cache: true
          bazelrc: common --color=yes
      - name: "Prep git"
        run: |
          git config --local user.email "selenium-ci@users.noreply.github.com"
          git config --local user.name "Selenium CI Bot"
          if git rev-parse --verify rust-release-${{ github.event.inputs.version }} >/dev/null 2>&1; then
            git branch -D rust-release-${{ github.event.inputs.version }}
          fi
          git checkout -b rust-release-${{ github.event.inputs.version }}
      - name: Update Rust Version
        run: ./go rust:version ${{ github.event.inputs.version }}
      - name: Commit Rust updates
        run: git commit -m "update selenium manager version and rust changelog"
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.SELENIUM_CI_TOKEN }}
          branch: rust-release-${{ github.event.inputs.version }}
          force: true

  selenium-manager:
    name: Release Selenium Manager
    needs: update-rust
    uses: ./.github/workflows/ci-rust.yml
    with:
      release: true
      branch: rust-release-${{ github.event.inputs.version }}
    secrets:
      SELENIUM_CI_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}

  cleanup-rust-branch:
    name: Cleanup Rust Branch
    needs: selenium-manager
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout repo"
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.SELENIUM_CI_TOKEN }}
      - name: "Delete rust release branch"
        run: |
          git push origin --delete rust-release-${{ github.event.inputs.version }}

  restrict-trunk:
    name: Restrict Trunk Branch
    needs: [get-approval, selenium-manager]
    uses: ./.github/workflows/restrict-trunk.yml
    with:
      restrict: true
    secrets: inherit

  update-files:
    name: Update Files
    runs-on: ubuntu-latest
    needs: restrict-trunk
    steps:
      - name: "Checkout project"
        uses: actions/checkout@v4
        with:
          persist-credentials: false
          fetch-depth: 0
          fetch-tags: true
          ref: trunk
      - name: Get latest trunk
        run: git pull --ff-only origin trunk
      - name: Setup curl for Ubuntu
        run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
      - name: Setup Bazel
        uses: bazel-contrib/setup-bazel@0.18.0
        with:
          cache-save: false
          bazelisk-cache: true
          external-cache: |
            manifest:
              crates: rust/Cargo.Bazel.lock
              rules_ruby++ruby+ruby: rb/.ruby-version
          repository-cache: true
          bazelrc: common --color=yes
      - name: "Prep git"
        run: |
          git config --local user.email "selenium-ci@users.noreply.github.com"
          git config --local user.name "Selenium CI Bot"
      - name: Normalize version
        id: version
        shell: bash
        run: |
          VERSION="${{ github.event.inputs.version }}"
          VERSION="${VERSION//[[:space:]]/}"
          if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
            VERSION="${VERSION}.0"
          elif [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            echo "::error::Invalid version format: '$VERSION'. Expected major.minor or major.minor.patch"
            exit 1
          fi
          echo "value=$VERSION" >> "$GITHUB_OUTPUT"
      - name: Update browser versions
        id: browsers
        run: |
          ./go update_browsers ${{ github.event.inputs.chrome_channel }}
          if git diff --staged --quiet; then
            echo "updated=false" >> "$GITHUB_OUTPUT"
          else
            git commit -m "update pinned browser versions"
            echo "updated=true" >> "$GITHUB_OUTPUT"
          fi
      - name: Update devtools versions
        id: devtools
        run: |
          ./go all:update_cdp ${{ github.event.inputs.chrome_channel }}
          if git diff --staged --quiet; then
            echo "updated=false" >> "$GITHUB_OUTPUT"
          else
            git commit -m "update devtools versions"
            echo "updated=true" >> "$GITHUB_OUTPUT"
          fi
      - name: Update Selenium Manager versions
        id: manager
        run: |
          ./go update_manager
          if git diff --staged --quiet; then
            echo "updated=false" >> "$GITHUB_OUTPUT"
          else
            git commit -m "update selenium manager versions"
            echo "updated=true" >> "$GITHUB_OUTPUT"
          fi
      - name: Update Dependency versions
        id: dependencies
        run: |
          ./go java:update
          ./go node:update
          if git diff --staged --quiet; then
            echo "updated=false" >> "$GITHUB_OUTPUT"
          else
            git commit -m "update dependency versions"
            echo "updated=true" >> "$GITHUB_OUTPUT"
          fi
      - name: Update Authors file
        id: authors
        run: |
          ./go authors
          if git diff --staged --quiet; then
            echo "updated=false" >> "$GITHUB_OUTPUT"
          else
            git commit -m "update authors file"
            echo "updated=true" >> "$GITHUB_OUTPUT"
          fi
      - name: Bump versions
        run: |
          ./go all:version ${{ steps.version.outputs.value }}
          git commit -m "bump versions in preparation for release"
      - name: Update changelogs
        run: |
          ./go all:changelogs
          git commit -m "changelogs updated"
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v6
        with:
          token: ${{ secrets.SELENIUM_CI_TOKEN }}
          author: Selenium CI Bot <selenium-ci@users.noreply.github.com>
          delete-branch: true
          branch: release-preparation-${{ steps.version.outputs.value }}
          base: trunk
          title: "[build] Prepare for release of Selenium ${{ steps.version.outputs.value }}"
          body: |

            ### Updates Applied
            | Component | Status |
            |-----------|--------|
            | Browser  and driver versions | ${{ steps.browsers.outputs.updated == 'true' && '✅ Updated' || '⏭️ Skipped (no changes)' }} |
            | CDP version | ${{ steps.devtools.outputs.updated == 'true' && '✅ Updated' || '⏭️ Skipped (no changes)' }} |
            | Selenium Manager version | ${{ steps.manager.outputs.updated == 'true' && '✅ Updated' || '⏭️ Skipped (no changes)' }} |
            | Dependencies | ${{ steps.dependencies.outputs.updated == 'true' && '✅ Updated' || '⏭️ Skipped (no changes)' }} |
            | Update Authors | ${{ steps.authors.outputs.updated == 'true' && '✅ Updated' || '⏭️ Skipped (no changes)' }} |
            | Bump Versions | ✅ Updated |
            | Draft Changelogs | ✅ Updated |

            ---
            Auto-generated by [release-preparation workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
          labels: C-build
          draft: true