forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 522
288 lines (276 loc) · 10.7 KB
/
ci.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: CI
on:
push:
branches:
- development
- linux
- linux-vnext
- 'linux-release-*'
tags:
- 'release-*.*.*-linux*'
- 'release-*.*.*-test*'
pull_request:
branches:
- linux
- linux-vnext
- 'linux-release-*'
env:
NODE_VERSION: 18.16.1
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
RELEASE_CHANNEL: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref }}
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- run: yarn
- run: yarn validate-electron-version
- run: yarn lint
- run: yarn validate-changelog
- name: Ensure a clean working directory
run: git diff --name-status --exit-code
build:
name: ${{ matrix.friendlyName }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.image }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os: [macos-13, windows-2019, ubuntu-20.04]
arch: [x64, arm64]
include:
- os: macos-13
friendlyName: macOS
- os: windows-2019
friendlyName: Windows
- os: ubuntu-20.04
friendlyName: Ubuntu
image: ubuntu:18.04
arch: x64
environment:
AS: as
STRIP: strip
AR: ar
CC: gcc
CPP: cpp
CXX: g++
LD: ld
FC: gfortran
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig
- os: ubuntu-20.04
friendlyName: Ubuntu
image: ubuntu:18.04
arch: arm64
environment:
AS: aarch64-linux-gnu-as
STRIP: aarch64-linux-gnu-strip
AR: aarch64-linux-gnu-ar
CC: aarch64-linux-gnu-gcc
CPP: aarch64-linux-gnu-cpp
CXX: aarch64-linux-gnu-g++
LD: aarch64-linux-gnu-ld
FC: aarch64-linux-gnu-gfortran
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
- os: ubuntu-20.04
friendlyName: Ubuntu
image: ubuntu:18.04
arch: arm
environment:
AS: arm-linux-gnueabihf-as
STRIP: arm-linux-gnueabihf-strip
AR: arm-linux-gnueabihf-ar
CC: arm-linux-gnueabihf-gcc
CPP: arm-linux-gnueabihf-cpp
CXX: arm-linux-gnueabihf-g++
LD: arm-linux-gnueabihf-ld
FC: arm-linux-gnueabihf-gfortran
PKG_CONFIG_PATH: /usr/lib/arm-linux-gnueabihf/pkgconfig
timeout-minutes: 60
env:
RELEASE_CHANNEL: ${{ inputs.environment }}
AS: ${{ matrix.environment.AS }}
STRIP: ${{ matrix.environment.STRIP }}
AR: ${{ matrix.environment.AR }}
CC: ${{ matrix.environment.CC }}
CPP: ${{ matrix.environment.CPP }}
CXX: ${{ matrix.environment.CXX }}
LD: ${{ matrix.environment.LD }}
FC: ${{ matrix.environment.FC }}
PKG_CONFIG_PATH: ${{ matrix.environment.PKG_CONFIG_PATH }}
npm_config_arch: ${{ matrix.arch }}
steps:
- name: Install dependencies into dockerfile on Ubuntu
if: matrix.friendlyName == 'Ubuntu'
run: |
# ubuntu dockerfile is very minimal (only 122 packages are installed)
# add dependencies expected by scripts
apt update
apt install -y software-properties-common lsb-release \
sudo wget curl build-essential jq autoconf automake \
pkg-config ca-certificates rpm
# install new enough git to run actions/checkout
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt update
sudo apt install -y git
# avoid "fatal: detected dubious ownership in repository at '/__w/shiftkey/desktop'" error
git config --global --add safe.directory '*'
- name: Add additional dependencies for Ubuntu x64
if: ${{ matrix.friendlyName == 'Ubuntu' && matrix.arch == 'x64' }}
run: |
# add electron unit test dependencies
sudo apt install -y libasound2 libatk-bridge2.0-0 libatk1.0-0 \
libatspi2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libdrm2 \
libexpat1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 \
libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 \
libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 \
libsecret-1-0
- name: Add additional dependencies for Ubuntu arm64
if: ${{ matrix.friendlyName == 'Ubuntu' && matrix.arch == 'arm64' }}
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Add additional dependencies for Ubuntu arm
if: ${{ matrix.friendlyName == 'Ubuntu' && matrix.arch == 'arm' }}
run: |
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf
sudo sed -i "s/^deb/deb [arch=amd64,i386]/g" /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ $(lsb_release -s -c) main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ $(lsb_release -s -c)-updates main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y libx11-dev:armhf libx11-xcb-dev:armhf libxkbfile-dev:armhf libsecret-1-dev:armhf
- uses: actions/checkout@v3
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref }}
submodules: recursive
- uses: actions/setup-python@v5
if: matrix.friendlyName != 'Ubuntu'
with:
python-version: '3.11'
- name: Use Node.js ${{ env.NODE_VERSION }}
if: matrix.friendlyName != 'Ubuntu'
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name:
Install unofficial-builds Node.js ${{ env.NODE_VERSION }} on Ubuntu
if: matrix.friendlyName == 'Ubuntu'
run: |
# This version supports older GLIBC (official builds required a minimum of GLIBC 2.28)
# this might break if you bump the `env.NODE_VERSION` version - ensure you are on the latest version
# of which ever major/minor release which should have this variant available
#
# See https://github.com/nodejs/unofficial-builds/ for more information on these versions.
#
curl -sL 'https://unofficial-builds.nodejs.org/download/release/v${{ env.NODE_VERSION }}/node-v${{ env.NODE_VERSION }}-linux-x64-glibc-217.tar.xz' | xzcat | sudo tar -vx --strip-components=1 -C /usr/local/
sudo npm install --global yarn
# This step can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
#
# This version is pinned to 18.16.0 as the later version does not have the required
# `win-arm64/node.lib` output that we can consume in this CI build.
- name: Get NodeJS node-gyp lib for Windows arm64
if: ${{ matrix.os == 'windows-2019' && matrix.arch == 'arm64' }}
run: .\script\download-nodejs-win-arm64.ps1 18.16.0
- name: Get app version
id: version
run: echo version=$(jq -r ".version" app/package.json) >> $GITHUB_OUTPUT
- name: Install and build dependencies
run: yarn
- name: Build production app
run: yarn build:prod
- name: Prepare testing environment
if: matrix.arch == 'x64'
run: yarn test:setup
env:
npm_config_arch: ${{ matrix.arch }}
- name: Run unit tests
if: matrix.arch == 'x64'
run: yarn test:unit
- name: Run script tests
if: matrix.arch == 'x64'
run: yarn test:script
- name: Package application
run: yarn run package
if: ${{ matrix.friendlyName == 'Ubuntu' }}
- name: Upload output artifacts
uses: actions/upload-artifact@v3
if: matrix.friendlyName == 'Ubuntu'
with:
name: ${{ matrix.friendlyName }}-${{ matrix.arch }}-artifacts
path: |
dist/*.AppImage
dist/*.deb
dist/*.rpm
dist/*.sha256
retention-days: 5
publish:
name: Create GitHub release
needs: [build, lint]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.14.0
uses: actions/setup-node@v4
with:
node-version: 18.14.0
cache: yarn
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: './artifacts'
- name: Display structure of downloaded files
run: ls -R
working-directory: './artifacts'
- name: Get tag name without prefix
run: |
RELEASE_TAG=${GITHUB_REF/refs\/tags\//}
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
tagNameWithoutPrefix="${RELEASE_TAG:8}"
echo "RELEASE_TAG_WITHOUT_PREFIX=${tagNameWithoutPrefix}" >> $GITHUB_ENV
# TODO: generate release notes
# - pull in default if version matches X.Y.Z-linux1
# - otherwise stub template
- name: Generate release notes
run: |
node -v
yarn
node -r ts-node/register script/generate-release-notes.ts "${{ github.workspace }}/artifacts" "${{ env.RELEASE_TAG_WITHOUT_PREFIX }}"
RELEASE_NOTES_FILE=script/release_notes.txt
if [[ ! -f "$RELEASE_NOTES_FILE" ]]; then
echo "$RELEASE_NOTES_FILE does not exist. Something might have gone wrong while generating the release notes."
exit 1
fi
echo "Release notes:"
echo "---"
cat ${RELEASE_NOTES_FILE}
echo "---"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: GitHub Desktop for Linux ${{ env.RELEASE_TAG_WITHOUT_PREFIX }}
body_path: script/release_notes.txt
files: |
artifacts/**/*.AppImage
artifacts/**/*.deb
artifacts/**/*.rpm
artifacts/**/*.sha256
draft: true
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}