-
Notifications
You must be signed in to change notification settings - Fork 314
192 lines (184 loc) · 8.14 KB
/
build.yml
File metadata and controls
192 lines (184 loc) · 8.14 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
name: "构建与发布"
run-name: 任务参数:${{ inputs.job }} ;分支:${{ github.ref_name }} # 每次运行的时候显示的名字
on:
workflow_dispatch: # 手动触发
inputs: # 定义触发的时候可以输入的参数
job: # 参数名称 通过 ${{ github.event.inputs.job }} 访问值 下面是参数的要求描述
description: "任务类型 all,push-npm,预构建:prebuild(linux和win,mac x64),alpine,alpine-arm,linux-arm"
required: true
default: prebuild
type: string
ubuntu_version:
description: 'ubuntu版本'
required: false
default: 'ubuntu-latest' # ${{ inputs.ubuntu_version || 'ubuntu-20.04' }} 也可以
win_version:
description: 'windows版本'
required: false
default: 'windows-latest'
env: # 用来定义环境变量 可用于工作流中所有作业的步骤的变量的 map
# See https://github.com/nodejs/release#release-schedule
# Node.js v16 EOL = 2023-09-11. v21 EOL = 2024-06-01.
# NODE_OLD_BUILD_CMD: npx --no-install prebuild -r node -t 14.0.0 -t 16.0.0 --include-regex
NODE_BUILD_CMD: npx --no-install prebuild -r node -t 16.0.0 -t 18.0.0 -t 20.0.0 -t 22.0.0 --include-regex
# Merge with NODE_BUILD_CMD when Node.js v18 is EOL
# NO_V18_NODE_BUILD_CMD: npx --no-install prebuild -r node -t 20.0.0 -t 22.0.0 --include-regex
# See https://www.electronjs.org/docs/latest/tutorial/electron-timelines#version-support-policy
# Electron v25 EOL = 2023-12-05. v26 EOL = 2024-02-20. v27 EOL = 2024-04-16. v28 EOL = 2024-06-11. v29 EOL = 2024-08-20.
ELECTRON_BUILD_CMD: npx --no-install prebuild -r electron -t 26.0.0 -t 27.0.0 -t 28.0.0 -t 29.0.0 -t 30.0.0 -t 31.0.0 -t 32.0.0 --include-regex
# 所有的jobs下的任务都会被执行
jobs:
test:
strategy:
matrix: # 定义在多个维度版本进行构建的 虚拟环境 矩阵(就是os * node的组合)
os:
- ubuntu-20.04
- macos-13
- macos-14
- windows-2019
node:
- 18
- 20
- 22
name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
if: ${{ github.event_name == 'test' }} # 让某个job执行
runs-on: ${{ matrix.os }} # 使用matrix.os中的 运行环境
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- if: ${{ startsWith(matrix.os, 'windows') }}
run: pip.exe install setuptools
- if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install python-setuptools
- if: ${{ !startsWith(matrix.os, 'windows') && !startsWith(matrix.os, 'macos') }}
run: python3 -m pip install setuptools
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install gcc-10 g++-10 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
- run: npm install --ignore-scripts
- run: npm run build-debug
- run: npm test
- name: Test SpatiaLite extension
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install libsqlite3-mod-spatialite -y
node -e "require('./lib/index.js')(':memory:').loadExtension('mod_spatialite').exec('SELECT InitSpatialMetaData();')"
publish-npm:
if: ${{ github.event.inputs.job == 'push-npm' || github.event.inputs.job == 'all'}}
name: Publishing to NPM
runs-on: ${{inputs.ubuntu_version}}
#needs: # 等待别的 job 任务完成
#- prebuild
#- prebuild-alpine
#- prebuild-alpine-arm
#- prebuild-linux-arm
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org
- run: |
npm install --ignore-scripts
npm run build
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
prebuild: # 执行node的 预构建
if: ${{ github.event.inputs.job == 'prebuild' || github.event.inputs.job == 'all' }}
strategy:
fail-fast: false
matrix:
os:
- ${{inputs.ubuntu_version}}
#- macos-13
#- macos-14
- ${{inputs.win_version}}
name: Prebuild on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
# needs: test
steps:
- uses: actions/checkout@v4 # 使用社区的指令
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install --ignore-scripts
- if: ${{ startsWith(matrix.os, 'windows') }}
run: pip.exe install setuptools
- if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install python-setuptools
- if: ${{ !startsWith(matrix.os, 'windows') && !startsWith(matrix.os, 'macos') }}
run: python3 -m pip install setuptools
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install gcc-10 g++-10 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
${{ env.NODE_BUILD_CMD }} "\.(node|exe|dll|pdb)" -u ${{ secrets.GITHUB_TOKEN }}
${{ env.ELECTRON_BUILD_CMD }} "\.(node|exe|dll|pdb)" -u ${{ secrets.GITHUB_TOKEN }}
- if: matrix.os == 'windows-2019'
run: |
${{ env.NODE_BUILD_CMD }} ('\.' -join ('node', 'exe', 'dll', 'pdb')) -u ${{ secrets.GITHUB_TOKEN }}
${{ env.NODE_BUILD_CMD }} ('\.' -join ('node', 'exe', 'dll', 'pdb')) --arch arm64 -u ${{ secrets.GITHUB_TOKEN }}
${{ env.NODE_BUILD_CMD }} ('\.' -join ('node', 'exe', 'dll', 'pdb')) --arch ia32 -u ${{ secrets.GITHUB_TOKEN }}
${{ env.ELECTRON_BUILD_CMD }} ('\.' -join ('node', 'exe', 'dll', 'pdb')) -u ${{ secrets.GITHUB_TOKEN }}
${{ env.ELECTRON_BUILD_CMD }} ('\.' -join ('node', 'exe', 'dll', 'pdb')) --arch arm64 -u ${{ secrets.GITHUB_TOKEN }}
${{ env.ELECTRON_BUILD_CMD }} ('\.' -join ('node', 'exe', 'dll', 'pdb')) --arch ia32 -u ${{ secrets.GITHUB_TOKEN }}
prebuild-alpine:
if: ${{ github.event.inputs.job == 'alpine' || github.event.inputs.job == 'all' }}
strategy:
fail-fast: false
name: Prebuild on alpine
runs-on: ${{inputs.ubuntu_version}}
container: node:18-alpine
#needs: test
steps:
- uses: actions/checkout@v4
- run: apk add build-base git python3 py3-setuptools --update-cache
- run: npm install --ignore-scripts
- run: |
${{ env.NODE_BUILD_CMD }} '\.(node|exe|dll|pdb)' -u ${{ secrets.GITHUB_TOKEN }}
prebuild-alpine-arm:
if: ${{ github.event.inputs.job == 'alpine-arm' || github.event.inputs.job == 'all' }}
strategy:
fail-fast: false
matrix:
arch:
- arm/v7
- arm64
name: Prebuild on alpine (${{ matrix.arch }})
runs-on: ${{inputs.ubuntu_version}}
#needs: test
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- run: |
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:18-alpine -c "\
apk add build-base git python3 py3-setuptools --update-cache && \
cd /tmp/project && \
npm install --ignore-scripts && \
${{ env.NODE_BUILD_CMD }} '\.(node|exe|dll|pdb)' -u ${{ secrets.GITHUB_TOKEN }}"
prebuild-linux-arm:
if: ${{ github.event.inputs.job == 'linux-arm' || github.event.inputs.job == 'all' }}
strategy:
fail-fast: false
matrix:
arch:
- arm/v7
- arm64
name: Prebuild on Linux (${{ matrix.arch }})
runs-on: ${{inputs.ubuntu_version}}
#needs: test
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- run: |
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:18-bullseye -c "\
cd /tmp/project && \
npm install --ignore-scripts && \
${{ env.NODE_BUILD_CMD }} '\.(node|exe|dll|pdb)' -u ${{ secrets.GITHUB_TOKEN }}"