Repository navigation
83 lines (72 loc) · 2.63 KB
/
Copy pathpublish.yml
File metadata and controls
83 lines (72 loc) · 2.63 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
name: Cypress CLI Publish
on:
workflow_dispatch:
inputs:
version:
description: Version to publish, e.g. 1.38.1 (1.38.1-tp.0 for a non-latest dist-tag)
required: true
type: string
npm_tag:
description: npm dist-tag
required: true
default: latest
type: string
release_notes:
description: GitHub release notes (markdown). The release is created only for the latest dist-tag
required: false
type: string
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
VERSION: ${{ inputs.version }}
NPM_TAG: ${{ inputs.npm_tag }}
steps:
- name: Validate inputs
run: |
num='(0|[1-9][0-9]*)'
id='(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)'
if [ "$NPM_TAG" = latest ]; then
pattern="^$num\\.$num\\.$num\$"
else
pattern="^$num\\.$num\\.$num-$id(\\.$id)*\$"
fi
if ! [[ "$VERSION" =~ $pattern ]]; then
echo "::error::version '$VERSION' does not match $pattern for dist-tag '$NPM_TAG'"
exit 1
fi
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
# No registry-url: setup-node would write an .npmrc token line that shadows OIDC.
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
- run: npm install -g npm@11.21.0
- name: Upgrade version
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
npm version "$VERSION"
- name: Publish
run: npm publish --access public --tag "$NPM_TAG"
- name: Push tag
if: inputs.npm_tag != 'latest'
run: git push origin "v$VERSION"
- name: Push tag and version bump branch
if: inputs.npm_tag == 'latest'
run: |
branch="release-$(date +%s)"
git push --follow-tags origin "HEAD:refs/heads/$branch"
echo "Open the version bump PR: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/$GITHUB_REF_NAME...$branch?expand=1" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Create GitHub release
if: inputs.npm_tag == 'latest' && inputs.release_notes != ''
env:
GH_TOKEN: ${{ github.token }}
RELEASE_NOTES: ${{ inputs.release_notes }}
run: gh release create "v$VERSION" --verify-tag --title "Public Beta v$VERSION" --notes "$RELEASE_NOTES"