forked from serenadeai/speech-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
245 lines (207 loc) · 7.46 KB
/
release.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
245
# .github/workflows/release.yml
name: Create release and publish
run-name: v${{inputs.version}}
on:
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
prerelease:
description: "Is this a prerelease?"
default: true
required: false
type: boolean
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: self-hosted-macos-arm
arch: arm64
name: darwin
- os: macos-latest
arch: x64
name: darwin
- os: ubuntu-latest
arch: x64
name: linux
- os: windows-2019
arch: x64
name: win32
- os: ubuntu-latest
arch: x64
name: linux
steps:
- uses: actions/checkout@v3
- if: matrix.os == 'windows-2019'
name: Setup MSBuild
uses: seanmiddleditch/gha-setup-vsdevenv@master
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install NPM build dependencies
run: npm install node-gyp prebuild
- name: Update package version
uses: jaywcjlove/github-action-package@main
with:
version: ${{inputs.version}}
- name: Setup x64 python
if: matrix.arch != 'arm64'
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup arm64 python
if: matrix.arch == 'arm64'
run: |
brew install [email protected] cmake
echo "NODE_GYP_FORCE_PYTHON=/opt/homebrew/bin/python3.10" >> $GITHUB_ENV
- name: Setup system dependencies
run: bash ./setup.sh ${{ matrix.arch }}
- name: Build
run: bash ./build.sh ${{ matrix.arch }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-${{matrix.name}}-${{matrix.arch}}
path: build/Release
retention-days: 1
package:
runs-on: self-hosted-macos-arm
needs: build
steps:
- name: Download win build artifacts
uses: actions/download-artifact@v3
with:
name: build-win32-x64
path: build/Release
- name: Compress win artifacts
uses: a7ul/[email protected]
with:
command: c
files: ./build/Release
outPath: speech-recorder-v${{inputs.version}}-napi-v6-win32-x64.tar.gz
- name: Cleanup win build
run: rm -rf build/Release
- name: Download x64 macOS build artifacts
uses: actions/download-artifact@v3
with:
name: build-darwin-x64
path: build/Release-x64
- name: Download arm64 macOS build artifacts
uses: actions/download-artifact@v3
with:
name: build-darwin-arm64
path: build/Release-arm64
- name: Create universal macOS build
run: |
mkdir -p build/Release
lipo -create -output build/Release/libonnxruntime.1.10.0.dylib build/Release-x64/libonnxruntime.1.10.0.dylib build/Release-arm64/libonnxruntime.1.10.0.dylib
lipo -create -output build/Release/libportaudio.dylib build/Release-x64/libportaudio.dylib build/Release-arm64/libportaudio.dylib
lipo -create -output build/Release/libspeechrecorder.dylib build/Release-x64/libspeechrecorder.dylib build/Release-arm64/libspeechrecorder.dylib
lipo -create -output build/Release/speechrecorder.node build/Release-x64/speechrecorder.node build/Release-arm64/speechrecorder.node
- name: Compress macOS arm artifacts
uses: a7ul/[email protected]
with:
command: c
files: ./build/Release
outPath: speech-recorder-v${{inputs.version}}-napi-v6-darwin-arm64.tar.gz
- name: Compress macOS x64 artifacts
uses: a7ul/[email protected]
with:
command: c
files: ./build/Release
outPath: speech-recorder-v${{inputs.version}}-napi-v6-darwin-x64.tar.gz
- name: Cleanup macos build
run: rm -rf build/Release
- name: Download linux build artifacts
uses: actions/download-artifact@v3
with:
name: build-linux-x64
path: build/Release
- name: Compress linux artifacts
uses: a7ul/[email protected]
with:
command: c
files: ./build/Release
outPath: speech-recorder-v${{inputs.version}}-napi-v6-linux-x64.tar.gz
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: speech-recorder-dist
path: speech-recorder-*.tar.gz
retention-days: 1
- name: Cleanup linux build
run: rm -rf build/Release
release-and-publish:
name: Create release and publish
runs-on: ubuntu-latest
needs: package
steps:
- name: Checkout to base branch
uses: actions/checkout@v3
- name: Get base version number from input
id: get-base-version
uses: frabert/replace-string-action@v2
with:
pattern: '-rc\d*'
string: "v${{inputs.version}}"
replace-with: ""
- name: Check if release tag exists
uses: mukunku/[email protected]
id: check-release
with:
tag: ${{steps.get-base-version.outputs.replaced}}
- name: Create release branch
if: steps.check-release.outputs.exists == 'false'
run: git checkout -b release/${{steps.get-base-version.outputs.replaced}} && git push -u origin release/${{steps.get-base-version.outputs.replaced}}
- name: Merge base into release
if: steps.check-release.outputs.exists == 'true'
uses: everlytic/[email protected]
with:
github_token: ${{secrets.GITHUB_TOKEN}}
source_ref: ${{ github.ref }}
target_branch: release/${{steps.get-base-version.outputs.replaced}}
commit_message_template: "[Automated] Merged {source_ref} into target {target_branch}"
- name: Checkout to release branch
uses: actions/checkout@v3
with:
ref: release/${{steps.get-base-version.outputs.replaced}}
- name: Update package version
uses: jaywcjlove/github-action-package@main
with:
version: ${{inputs.version}}
- run: npm install --ignore-scripts
- name: Commit changes to release branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Bump package version to v${{inputs.version}}"
file_pattern: package*.json
tagging_message: v${{inputs.version}}
- name: Update the release tag
uses: richardsimko/update-tag@v1
with:
tag_name: ${{steps.get-base-version.outputs.replaced}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download speech-recorder artifacts
uses: actions/download-artifact@v3
with:
name: speech-recorder-dist
- uses: ncipollo/release-action@v1
with:
artifacts: speech-recorder-*
allowUpdates: true
generateReleaseNotes: true
name: ${{steps.get-base-version.outputs.replaced}}
prerelease: ${{inputs.prerelease}}
tag: ${{steps.get-base-version.outputs.replaced}}
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}