-
Notifications
You must be signed in to change notification settings - Fork 74
244 lines (242 loc) · 8.49 KB
/
npm-publish.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: Publish packages
on:
push:
branches:
- dev
- rc
- release
env:
REF: ${{ github.event.pull_request && github.head_ref || github.ref_name }}
jobs:
shared:
name: Publish shared
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
needs: test
defaults:
run:
working-directory: ./shared
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check package version
id: pkgver
run: |
echo "::set-output name=local::$(node -p -e "require('./package.json').version")"
echo "::set-output name=remote::$(yarn info -s $(node -p -e "require('./package.json').name") version)"
- name: Publish package
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: ./shared/package.json
access: public
tag: ${{ env.REF == 'release' && 'latest' || env.REF }}
client:
name: Publish client
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
needs: test
defaults:
run:
working-directory: ./client
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check package version
id: pkgver
run: |
echo "::set-output name=local::$(node -p -e "require('./package.json').version")"
echo "::set-output name=remote::$(yarn info -s $(node -p -e "require('./package.json').name") version)"
- name: Publish package
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: ./client/package.json
access: public
tag: ${{ env.REF == 'release' && 'latest' || env.REF }}
webview:
name: Publish webview
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
needs: test
defaults:
run:
working-directory: ./webview
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check package version
id: pkgver
run: |
echo "::set-output name=local::$(node -p -e "require('./package.json').version")"
echo "::set-output name=remote::$(yarn info -s $(node -p -e "require('./package.json').name") version)"
- name: Publish package
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: ./webview/package.json
access: public
tag: ${{ env.REF == 'release' && 'latest' || env.REF }}
worker:
name: Publish worker
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
needs: test
defaults:
run:
working-directory: ./worker
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check package version
id: pkgver
run: |
echo "::set-output name=local::$(node -p -e "require('./package.json').version")"
echo "::set-output name=remote::$(yarn info -s $(node -p -e "require('./package.json').name") version)"
- name: Publish package
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: ./worker/package.json
access: public
tag: ${{ env.REF == 'release' && 'latest' || env.REF }}
natives:
name: Publish natives
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
needs: test
defaults:
run:
working-directory: ./natives
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Set up .Net SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 5.0.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Check package version
id: pkgver
run: |
echo "::set-output name=local::$(node -p -e "require('./package.json').version")"
echo "::set-output name=remote::$(yarn info -s $(node -p -e "require('./package.json').name") version)"
- name: Checkout generator
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: actions/checkout@v2
with:
persist-credentials: false
repository: altmp/altv-native-gen
ref: c40614e276bcbdd002cb4d78d6109c59d7884307
path: ./gen
- name: Checkout nativedb
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
run: |
mkdir "../nativedb"
curl "https://natives.altv.mp/natives" -A "AltPublicAgent" > "../nativedb/natives.json"
- name: Run generator
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
run: dotnet run -p "../gen/Durty.AltV.NativesTypingsGenerator.Console" --disableHeader --nativesPath "../nativedb/natives.json" --outPath "./index.d.ts" --outIndent " "
- name: Commit changes
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add "./index.d.ts"
git diff-index --quiet HEAD || git commit -m "chore: Update natives/index.d.ts" -m "Co-authored-by: $(git diff-tree ${{ github.sha }} --pretty='format:%an <%ae>' -s)"
- name: Push changes
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.REF }}
- name: Publish package
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: ./natives/package.json
access: public
tag: ${{ env.REF == 'release' && 'latest' || env.REF }}
server:
name: Publish server
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
needs: test
defaults:
run:
working-directory: ./server
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check package version
id: pkgver
run: |
echo "::set-output name=local::$(node -p -e "require('./package.json').version")"
echo "::set-output name=remote::$(yarn info -s $(node -p -e "require('./package.json').name") version)"
- name: Publish package
if: ${{ steps.pkgver.outputs.local != steps.pkgver.outputs.remote }}
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: ./server/package.json
access: public
tag: ${{ env.REF == 'release' && 'latest' || env.REF }}
test:
name: Test changes
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install dependencies
run: yarn install
- name: Test
run: yarn run test
- name: Lint
run: yarn run lint