forked from nating/react-native-custom-qr-codes
-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (58 loc) · 2.16 KB
/
publish.yml
File metadata and controls
69 lines (58 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Publish to npm
on:
push:
branches:
- master
paths:
- 'package.json'
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Upgrade npm
run: npm install -g npm@latest
- name: Install dependencies
run: npm install
- name: Check if version changed
id: version_check
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
PUBLISHED_VERSION=$(npm view $(node -p "require('./package.json').name") version 2>/dev/null || echo "0.0.0")
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "published=$PUBLISHED_VERSION" >> $GITHUB_OUTPUT
if [ "$CURRENT_VERSION" != "$PUBLISHED_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
if: steps.version_check.outputs.changed == 'true'
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm publish --provenance --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub release
if: steps.version_check.outputs.changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version_check.outputs.current }}
name: v${{ steps.version_check.outputs.current }}
body: |
## @oguzhnatly/react-native-custom-qr-codes v${{ steps.version_check.outputs.current }}
Published to npm: https://www.npmjs.com/package/@oguzhnatly/react-native-custom-qr-codes
generate_release_notes: true
make_latest: true
- name: Skip (version unchanged)
if: steps.version_check.outputs.changed == 'false'
run: echo "Version ${{ steps.version_check.outputs.current }} is already published. Bump package.json version to trigger a new release."