Skip to content
Merged
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
41 changes: 36 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,27 @@ jobs:
release:
needs: validate
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
issues: write
pull-requests: write
id-token: write # npm trusted publishing (OIDC)
if: >
github.event_name == 'push' &&
github.repository == 'testing-library/user-event' &&
contains('refs/heads/main,refs/heads/beta,refs/heads/alpha', github.ref)
contains('refs/heads/main,refs/heads/beta,refs/heads/alpha', github.ref) &&
vars.RELEASE_DRY != 'true'
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
# semantic-release needs full history + tags to see unreleased commits
fetch-depth: 0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 24
- name: ♻️ Restore node_modules
uses: actions/cache/restore@v4
with:
Expand All @@ -85,11 +96,31 @@ jobs:
- name: 🏗️ Run build script
run: npm run build

# JS action (not Docker) so GitHub OIDC works with npm trusted publishing
- name: 🚀 Release
uses: ph-fritsche/action-release@v2
uses: cycjimmy/semantic-release-action@v5
with:
# Only treat an explicit "true" as dry-run (unset/false publishes)
dry: ${{ vars.RELEASE_DRY == 'true' }}
semantic_version: 25
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Backfill npm when a git tag/GitHub release exists but npm publish was skipped
- name: 📦 Ensure latest tag is on npm
run: |
TAG=$(git describe --tags --abbrev=0)
VERSION=${TAG#v}
if npm view "@testing-library/user-event@${VERSION}" version >/dev/null 2>&1; then
echo "npm already has ${VERSION}"
exit 0
fi
echo "Publishing missing ${VERSION} to npm"
npm install -g npm@latest
npm version "${VERSION}" --no-git-tag-version
npm publish --access public

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backfill publishes wrong artifact

High Severity

The new npm backfill runs after a build at HEAD, then sets package.json to the latest reachable tag and runs npm publish without rebuilding at that tag. If main is ahead of that tag (e.g. CI fixes after v14.6.2), npm can get a tarball for an older version that includes unreleased source.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 33f7992. Configure here.

Loading