-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (169 loc) · 5.36 KB
/
ci.yml
File metadata and controls
198 lines (169 loc) · 5.36 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
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
name: Build and Deploy
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get Change
id: changes
run: |
echo "# ${{ github.ref }}" > changes.txt
sed -n \
"$(sed -n '/^## /=' CHANGELOG.md | sed -n '1'p),$(sed -n '/^## /=' CHANGELOG.md | sed -n '2'p)"p \
CHANGELOG.md > tmp_changes.txt
VERSION=$(head -1 tmp_changes.txt | cut -d '[' -f 2 | cut -d ']' -f 1)
if [ "refs/tags/v$VERSION" != "${{ github.ref }}" ]; then
echo $VERSION
echo "${{ github.ref }}"
echo "changelog version mismatch";
exit 1;
fi
cat tmp_changes.txt | head -n -1 >> changes.txt
echo ::set-output name=log::$(cat changes.txt)
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16 # Since I added the nvmrc we should cat that
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ~/.yarn
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
run: |
yarn global add node-gyp
yarn install --immutable
- name: Build
run: yarn release
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: ubuntu-latest
path: dist
- name: Upload change
uses: actions/upload-artifact@v2
with:
name: changes
path: changes.txt
build:
needs: test
strategy:
fail-fast: true
matrix:
os: [macos-latest, windows-latest]
max-parallel: 3
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ~/.yarn
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
run: |
yarn install --immutable
- name: Build
run: yarn release
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}
path: dist
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Get Changes
uses: actions/download-artifact@v2
with:
name: changes
- name: Get deployment refs
id: get_source
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
# body: ${{ steps.changes.outputs.log }}
body_path: changes.txt
# body: ${{ needs.build.outputs.log }}
# echo ::set-env name=FOO::$(echo -n "hello world")
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
source_tag: ${{ steps.get_source.outputs.SOURCE_TAG }}
upload:
needs: release
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
max-parallel: 3
steps:
- uses: actions/download-artifact@v2
with:
name: ${{ matrix.os }}
path: vad
- name: list path
if: startsWith(matrix.os, 'windows')
run: dir vad
- name: Compress folder
if: startsWith(matrix.os, 'windows')
run: cd vad && 7za a ../vad.zip
- name: Compress folder
if: startsWith(matrix.os, 'windows') != true
run: zip -r -j vad.zip vad/*
- name: Upload Linux Asset
if: startsWith(matrix.os, 'ubuntu')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: vad.zip
asset_name: vad-linux.zip
asset_content_type: application/zip
- name: Upload Mac Asset
if: startsWith(matrix.os, 'macos')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: vad.zip
asset_name: vad-mac.zip
asset_content_type: application/zip
- name: Upload Windows Asset
if: startsWith(matrix.os, 'windows')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: vad.zip
asset_name: vad-windows.zip
asset_content_type: application/zip