-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (136 loc) · 5 KB
/
Copy pathrelease.yml
File metadata and controls
141 lines (136 loc) · 5 KB
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
name: Manual NPM Publish
on:
workflow_dispatch:
inputs:
driver:
description: 'Which driver to release ("all" only releases packages changed since their last tag; picking one forces its release)'
required: true
type: choice
default: "all"
options:
- all
- edgedriver
- geckodriver
- safaridriver
releaseType:
description: "Release type - major, minor or patch"
required: true
type: choice
default: "patch"
options:
- patch
- minor
- major
distTag:
description: 'NPM tag (e.g. use "next" to release a test version)'
required: true
default: 'latest'
preRelease:
description: If latest release was a pre-release (e.g. X.X.X-alpha.0) and you want to push another one, pick "yes"
required: true
type: choice
default: "no"
options:
- "yes"
- "no"
dryRun:
description: Simulate the release (no git push, no GitHub release, no npm publish)
required: true
type: choice
default: "no"
options:
- "yes"
- "no"
env:
NPM_CONFIG_PROVENANCE: true
concurrency:
group: release
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set.outputs.packages }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: 'main'
fetch-depth: 0
fetch-tags: true
- id: set
# driver=all: auto-detect which packages changed since their last release tag
# and only release those (a package with no prior tag is always included).
# A specific driver is an explicit choice, so it's always released ("force").
run: |
if [ "${{ inputs.driver }}" = "all" ]; then
packages=()
for name in edgedriver geckodriver safaridriver; do
dir="packages/node-${name}"
last_tag=$(git tag -l "${name}@*" --sort=-v:refname | head -n1)
if [ -z "$last_tag" ]; then
echo "$name: no previous release tag, including"
packages+=("$dir")
elif ! git diff --quiet "$last_tag"..HEAD -- "$dir"; then
echo "$name: changes since $last_tag, including"
packages+=("$dir")
else
echo "$name: no changes since $last_tag, skipping"
fi
done
if [ ${#packages[@]} -eq 0 ]; then
packages_json="[]"
else
packages_json=$(printf '%s\n' "${packages[@]}" | jq -R . | jq -sc .)
fi
echo "packages=$packages_json" >> "$GITHUB_OUTPUT"
else
echo 'packages=["packages/node-${{ inputs.driver }}"]' >> "$GITHUB_OUTPUT"
fi
release:
needs: prepare
strategy:
fail-fast: false
max-parallel: 1
matrix:
package: ${{ fromJson(needs.prepare.outputs.packages) }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: 'main'
fetch-depth: 0
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
cache: 'pnpm'
- name: Upgrade npm for OIDC trusted publishing
# trusted publishing (OIDC) requires npm >= 11.5.1
run: npm install -g npm@latest
- name: Git Setup
run: |
git config --global user.email "bot@webdriver.io"
git config --global user.name "WebdriverIO Release Bot"
- name: Install Dependencies
run: pnpm ci
- name: Build
run: pnpm --filter "./${{ matrix.package }}" run build
- name: Release
# no NODE_AUTH_TOKEN: authentication is handled via OIDC trusted
# publishing (requires id-token: write + a trusted publisher configured
# for this package on npmjs.com)
working-directory: ${{ matrix.package }}
run: npx release-it ${{ inputs.releaseType }} --github.release --ci --npm.skipChecks --no-git.requireCleanWorkingDir --npm.tag=${{ inputs.distTag }} ${{ inputs.dryRun == 'yes' && '--dry-run' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.preRelease == 'no' }}
- name: Pre-Release
working-directory: ${{ matrix.package }}
run: npx release-it ${{ inputs.releaseType }} --github.release --ci --npm.skipChecks --no-git.requireCleanWorkingDir --preRelease=alpha --github.preRelease --npm.tag=next ${{ inputs.dryRun == 'yes' && '--dry-run' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.preRelease == 'yes' }}