mbkauthe 1.4.1 → 1.4.2
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.
- package/.github/PACKAGE.md +1 -1
- package/.github/workflows/publish.yml +35 -2
- package/docs/api.md +1 -1
- package/package.json +1 -1
package/.github/PACKAGE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: Publish to npm
|
|
1
|
+
name: Publish to npm and GitHub Packages
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
4
|
branches:
|
|
@@ -36,19 +36,52 @@ jobs:
|
|
|
36
36
|
run: |
|
|
37
37
|
for i in {1..3}; do npm install && break || sleep 10; done
|
|
38
38
|
|
|
39
|
+
- name: Check if version exists on npm
|
|
40
|
+
id: check_version
|
|
41
|
+
run: |
|
|
42
|
+
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
43
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
44
|
+
if npm view $PACKAGE_NAME@$VERSION version 2>/dev/null; then
|
|
45
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
46
|
+
echo "Version $VERSION already exists on npm"
|
|
47
|
+
else
|
|
48
|
+
echo "exists=false" >> $GITHUB_OUTPUT
|
|
49
|
+
echo "Version $VERSION does not exist, will publish"
|
|
50
|
+
fi
|
|
51
|
+
|
|
39
52
|
- name: Publish to npm
|
|
53
|
+
if: steps.check_version.outputs.exists == 'false'
|
|
40
54
|
run: npm publish
|
|
41
55
|
env:
|
|
42
56
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
43
57
|
|
|
58
|
+
- name: Check if version exists on GitHub Packages
|
|
59
|
+
id: check_github_version
|
|
60
|
+
run: |
|
|
61
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
62
|
+
if curl -f -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
|
63
|
+
https://npm.pkg.github.com/@mibnekhalid/mbkauthe/$VERSION 2>/dev/null; then
|
|
64
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
65
|
+
echo "Version $VERSION already exists on GitHub Packages"
|
|
66
|
+
else
|
|
67
|
+
echo "exists=false" >> $GITHUB_OUTPUT
|
|
68
|
+
echo "Version $VERSION does not exist on GitHub Packages, will publish"
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
- name: Modify package.json for GitHub Packages
|
|
72
|
+
if: steps.check_github_version.outputs.exists == 'false'
|
|
73
|
+
run: |
|
|
74
|
+
node -e "const pkg = require('./package.json'); pkg.name = '@mibnekhalid/mbkauthe'; pkg.publishConfig = { registry: 'https://npm.pkg.github.com' }; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
|
|
75
|
+
|
|
44
76
|
- name: Setup Node.js for GitHub Packages
|
|
77
|
+
if: steps.check_github_version.outputs.exists == 'false'
|
|
45
78
|
uses: actions/setup-node@v3
|
|
46
79
|
with:
|
|
47
80
|
node-version: '18'
|
|
48
81
|
registry-url: 'https://npm.pkg.github.com'
|
|
49
|
-
scope: '@MIbnEKhalid'
|
|
50
82
|
|
|
51
83
|
- name: Publish to GitHub Packages
|
|
84
|
+
if: steps.check_github_version.outputs.exists == 'false'
|
|
52
85
|
run: npm publish
|
|
53
86
|
env:
|
|
54
87
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/docs/api.md
CHANGED