File tree Expand file tree Collapse file tree 1 file changed +33
-8
lines changed
Expand file tree Collapse file tree 1 file changed +33
-8
lines changed Original file line number Diff line number Diff line change 1- name : NPM Package
1+ name : Publish to NPM
22
33on :
44 push :
5- branches :
6- - main
5+ tags :
6+ - " v*"
7+ workflow_dispatch :
78
89jobs :
910 publish :
1011 runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+ id-token : write
1115
1216 steps :
1317 - name : Checkout code
@@ -16,16 +20,37 @@ jobs:
1620 - name : Set up Node.js
1721 uses : actions/setup-node@v4
1822 with :
19- node-version : ' 20.x '
23+ node-version : " 24.x "
2024 registry-url : " https://registry.npmjs.org"
2125
26+ - name : Ensure npm supports trusted publishing
27+ run : npm i -g npm@11.5.1
28+
2229 - name : Install dependencies
2330 run : npm ci
31+ env :
32+ NODE_AUTH_TOKEN : ${{ secrets.NPM_READ_TOKEN }}
2433
2534 - name : Build
2635 run : npm run build
2736
28- - name : Publish to NPM
29- run : npm publish
30- env :
31- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
37+ - name : Check Version
38+ id : check-version
39+ run : |
40+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
41+ NPM_VERSION=$(npm view react-native-lab version 2>/dev/null || echo "0.0.0")
42+
43+ echo "Package Version: $PACKAGE_VERSION"
44+ echo "NPM Version: $NPM_VERSION"
45+
46+ if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
47+ echo "New version detected. Proceeding with publish."
48+ echo "IS_NEW_VERSION=true" >> $GITHUB_ENV
49+ else
50+ echo "Version $PACKAGE_VERSION already exists on NPM. Skipping publish."
51+ echo "IS_NEW_VERSION=false" >> $GITHUB_ENV
52+ fi
53+
54+ - name : Publish to NPM (OIDC)
55+ if : env.IS_NEW_VERSION == 'true'
56+ run : npm publish --access public
You can’t perform that action at this time.
0 commit comments