forked from bsv-blockchain/wallet-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (120 loc) · 4.71 KB
/
Copy pathpush.yaml
File metadata and controls
145 lines (120 loc) · 4.71 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Test and Publish Package
on:
push:
branches:
- master
- main
pull_request:
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
publish:
runs-on: ubuntu-latest
needs: test
# Only run on push to master/main, not on PRs
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
always-auth: false
- run: npm ci
- run: npm run build --if-present
- name: Sync client version with root
run: |
ROOT_VERSION=$(node -p "require('./package.json').version")
cd client
npm version $ROOT_VERSION --no-git-tag-version --allow-same-version
cd ..
- name: Sync mobile version with root
run: |
ROOT_VERSION=$(node -p "require('./package.json').version")
cd mobile
npm version $ROOT_VERSION --no-git-tag-version --allow-same-version
cd ..
- name: Check if root version already published
id: check-root-version
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Root Package: $PACKAGE_NAME@$PACKAGE_VERSION"
# Check if this version exists on npm
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
echo "Root version $PACKAGE_VERSION already published"
echo "should_publish_root=false" >> $GITHUB_OUTPUT
else
echo "Root version $PACKAGE_VERSION not yet published"
echo "should_publish_root=true" >> $GITHUB_OUTPUT
fi
- name: Publish root to npm
if: steps.check-root-version.outputs.should_publish_root == 'true'
run: npm publish
- name: Skip publishing root
if: steps.check-root-version.outputs.should_publish_root == 'false'
run: echo "Skipping publish root - version already exists on npm"
- name: Check if client version already published
id: check-client-version
run: |
cd client
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Client Package: $PACKAGE_NAME@$PACKAGE_VERSION"
# Check if this version exists on npm
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
echo "Client version $PACKAGE_VERSION already published"
echo "should_publish_client=false" >> $GITHUB_OUTPUT
else
echo "Client version $PACKAGE_VERSION not yet published"
echo "should_publish_client=true" >> $GITHUB_OUTPUT
fi
cd ..
- name: Publish client to npm
if: steps.check-client-version.outputs.should_publish_client == 'true'
run: |
cd client
npm publish
cd ..
- name: Skip publishing client
if: steps.check-client-version.outputs.should_publish_client == 'false'
run: echo "Skipping publish client - version already exists on npm"
- name: Check if mobile version already published
id: check-mobile-version
run: |
cd mobile
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Mobile Package: $PACKAGE_NAME@$PACKAGE_VERSION"
# Check if this version exists on npm
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
echo "Mobile version $PACKAGE_VERSION already published"
echo "should_publish_mobile=false" >> $GITHUB_OUTPUT
else
echo "Mobile version $PACKAGE_VERSION not yet published"
echo "should_publish_mobile=true" >> $GITHUB_OUTPUT
fi
cd ..
- name: Publish mobile to npm
if: steps.check-mobile-version.outputs.should_publish_mobile == 'true'
run: |
cd mobile
npm publish
cd ..
- name: Skip publishing mobile
if: steps.check-mobile-version.outputs.should_publish_mobile == 'false'
run: echo "Skipping publish mobile - version already exists on npm"