Skip to content

Commit c739fb9

Browse files
committed
fix: downgrade date-fns to v3.x for CommonJS compatibility
date-fns v4.x is ESM-only which causes 'Cannot destructure property differenceInHours' error when used with CommonJS bundling in Strapi plugins.
1 parent 56c36ab commit c739fb9

13 files changed

+7731
-120806
lines changed

.github/workflows/npm-publish.yml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ on:
44
release:
55
types: [published]
66

7+
# OIDC Trusted Publishing - npm provenance for signed/verified packages
8+
# See: https://docs.npmjs.com/generating-provenance-statements
9+
710
permissions:
8-
id-token: write # Required for NPM OIDC
9-
contents: write # Required for Version Bump
11+
contents: write # Required for version bump commit
12+
id-token: write # Required for NPM OIDC provenance
1013

1114
jobs:
1215
publish:
@@ -20,38 +23,42 @@ jobs:
2023
- name: Setup Node.js
2124
uses: actions/setup-node@v4
2225
with:
23-
always-auth: true
24-
node-version: 22
25-
cache: 'npm'
26-
registry-url: 'https://registry.npmjs.org/'
27-
28-
- name: Update NPM CLI to latest
29-
run: npm i -g npm@latest
26+
node-version: '22'
27+
registry-url: 'https://registry.npmjs.org'
3028

3129
- name: Install dependencies
3230
run: npm ci
3331

34-
- name: Build the plugin
32+
- name: Build plugin
3533
run: npm run build
3634

37-
- name: Verify plugin
35+
- name: Verify plugin structure
3836
run: npm run verify
3937

40-
- name: Get the release tag version
41-
id: get_version
42-
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
38+
- name: Get release version
39+
id: version
40+
run: |
41+
RELEASE_TAG="${{ github.event.release.tag_name }}"
42+
VERSION="${RELEASE_TAG#v}"
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
echo "[INFO] Release version: $VERSION"
4345
44-
- name: Set package version
45-
run: npm version "${{ steps.get_version.outputs.VERSION }}" --no-git-tag-version
46+
- name: Update package version
47+
run: npm version "${{ steps.version.outputs.version }}" --no-git-tag-version
4648

47-
- name: Publish package
49+
- name: Publish to NPM with provenance
4850
run: npm publish --access public --provenance
4951
env:
5052
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5153

5254
- name: Push version bump
5355
uses: stefanzweifel/git-auto-commit-action@v5
5456
with:
55-
commit_message: 'chore: Bump version to ${{ steps.get_version.outputs.VERSION }}'
57+
commit_message: 'chore: bump version to ${{ steps.version.outputs.version }}'
5658
file_pattern: 'package.json package-lock.json'
5759
branch: main
60+
- name: Done
61+
run: |
62+
PKG_NAME=$(node -p "require('./package.json').name")
63+
echo "[SUCCESS] Published $PKG_NAME@${{ steps.version.outputs.version }} with provenance"
64+

0 commit comments

Comments
 (0)