privacycash 1.0.7 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,67 +1,55 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Publish to npm
1
+ name: Publish to npm when version changes
5
2
 
6
3
  on:
7
4
  push:
8
5
  branches:
9
6
  - main
7
+ - master
8
+ paths:
9
+ - "package.json"
10
+
11
+ permissions:
12
+ id-token: write
13
+ contents: read
10
14
 
11
15
  jobs:
12
16
  publish:
13
17
  runs-on: ubuntu-latest
18
+
14
19
  steps:
15
20
  - name: Checkout repository
16
- uses: actions/checkout@v3
17
- with:
18
- fetch-depth: 0
21
+ uses: actions/checkout@v4
19
22
 
20
23
  - name: Setup Node.js
21
24
  uses: actions/setup-node@v4
22
25
  with:
23
- node-version: "20"
24
- registry-url: "https://registry.npmjs.org"
25
- cache: "npm"
26
+ node-version: 24
27
+ registry-url: https://registry.npmjs.org/
26
28
 
27
- # Get previous version from the last commit in origin/main
28
- - name: Get previous package.json version
29
- run: |
30
- PREV=$(git show origin/main~1:package.json | jq -r .version)
31
- echo "Previous version: $PREV"
32
- echo "PREV_VERSION=$PREV" >> $GITHUB_ENV
33
-
34
- # Get current version from package.json
35
- - name: Get current package.json version
36
- run: |
37
- CURR=$(jq -r .version package.json)
38
- echo "CURR_VERSION=$CURR"
39
- echo "CURR_VERSION=$CURR" >> $GITHUB_ENV
29
+ - name: Get current package version
30
+ id: pkg
31
+ run: echo "version=$(node -p 'require(\"./package.json\").version')" >> $GITHUB_OUTPUT
40
32
 
41
- # Compare previous and current versions
42
- - name: Compare versions
33
+ - name: Check if version already exists on npm
34
+ id: check
43
35
  run: |
44
- if [ "$PREV_VERSION" = "$CURR_VERSION" ]; then
45
- echo "Version unchanged, skip publish"
46
- echo "SHOULD_PUBLISH=false" >> $GITHUB_ENV
36
+ PKG_NAME=$(node -p 'require("./package.json").name')
37
+ PUBLISHED=$(npm view $PKG_NAME versions --json | grep -o "\"${{ steps.pkg.outputs.version }}\"" || true)
38
+ if [ -n "$PUBLISHED" ]; then
39
+ echo "exists=true" >> $GITHUB_OUTPUT
40
+ echo "Version ${{ steps.pkg.outputs.version }} already exists on npm. Skipping publish."
47
41
  else
48
- echo "Version changed, will publish"
49
- echo "SHOULD_PUBLISH=true" >> $GITHUB_ENV
42
+ echo "exists=false" >> $GITHUB_OUTPUT
50
43
  fi
51
44
 
52
- # Install dependencies only if publish is needed
53
45
  - name: Install dependencies
54
- if: env.SHOULD_PUBLISH == 'true'
55
- run: npm ci
46
+ run: npm install
56
47
 
57
- # Run build script before publishing
58
- - name: Build project
59
- if: env.SHOULD_PUBLISH == 'true'
60
- run: npm run build
48
+ - name: Build source
49
+ run: npm run build || echo "No build script defined."
61
50
 
62
- # Publish to npm
63
51
  - name: Publish to npm
64
- if: env.SHOULD_PUBLISH == 'true'
65
- run: npm publish
66
- env:
67
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52
+ if: steps.check.outputs.exists == 'false'
53
+ run: |
54
+ echo "Publishing version ${{ steps.pkg.outputs.version }}..."
55
+ npm publish --access public
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "privacycash",
3
- "version": "1.0.7",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
+ "repository": "https://github.com/Privacy-Cash/privacy-cash-sdk",
6
7
  "exports": {
7
8
  ".": "./dist/index.js",
8
9
  "./utils": "./dist/exportUtils.js"