-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (221 loc) · 7.11 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
# Copyright (C) 2023 Toitware ApS. All rights reserved.
name: CI
on:
workflow_dispatch:
inputs:
sign_macos:
description: Sign the macOS binary
type: boolean
required: true
default: false
sign_windows:
description: Sign the Windows binary
type: boolean
required: true
default: false
release:
types: [published]
push:
branches:
- "*"
- "*/*"
env:
TOIT_VERSION: v2.0.0-alpha.119
APP_NAME: pngdiff
jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Toit
shell: bash
run: |
if [[ "$RUNNER_OS" = "Windows" ]]; then
BIN_EXTENSION=".exe"
fi
echo "BIN_EXTENSION=$BIN_EXTENSION" >> $GITHUB_ENV
export NATIVE_DOWNLOAD_DIR="${{ github.workspace }}/downloads"
echo "NATIVE_DOWNLOAD_DIR=$NATIVE_DOWNLOAD_DIR" >> $GITHUB_ENV
export DOWNLOAD_DIR="$PWD/downloads"
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV
TOIT_SDK_DIR=$DOWNLOAD_DIR/toit
echo "TOITRUN=$TOIT_SDK_DIR/bin/toit.run$BIN_EXTENSION" >> $GITHUB_ENV
echo "TOITC=$TOIT_SDK_DIR/bin/toit.compile$BIN_EXTENSION" >> $GITHUB_ENV
echo "TOITPKG=$TOIT_SDK_DIR/bin/toit.pkg$BIN_EXTENSION" >> $GITHUB_ENV
TOIT_SDK_FILE=toit-$(echo $RUNNER_OS | tr '[:upper:]' '[:lower:]').tar.gz
TOIT_SDK_BASE_URL=https://github.com/toitlang/toit/releases
echo "TOIT_SDK_URL=$TOIT_SDK_BASE_URL/download/$TOIT_VERSION/$TOIT_SDK_FILE" >> $GITHUB_ENV
- uses: suisei-cn/[email protected]
name: Download Toit
with:
url: ${{ env.TOIT_SDK_URL }}
target: ${{ env.NATIVE_DOWNLOAD_DIR }}
- name: Extract Toit
shell: bash
run: |
cd "$DOWNLOAD_DIR"
for f in *.tar.gz; do
tar x -f $f
done
ls $TOITRUN
ls $TOITC
ls $TOITPKG
# Fetch the dependencies. Different for each platform.
- name: Install dependencies - Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install ninja-build
ninja --version
cmake --version
- name: Install dependencies - macOS
if: runner.os == 'macOS'
run: |
brew install ninja
ninja --version
cmake --version
- name: Install dependencies - Windows
if: runner.os == 'Windows'
run: |
choco install ninja
ninja --version
cmake --version
- name: Run cmake
shell: bash
run: |
make rebuild-cmake
cmake \
-DTOITC="$TOITC" \
-DTOITPKG="$TOITPKG" \
-DTOITRUN="$TOITRUN" \
build
- name: Build binaries
shell: bash
run: |
make
- name: Run tests
shell: bash
run: |
make test
- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
name: binaries-${{ runner.os }}
path: build/png*
sign-windows:
runs-on: windows-signing
needs: [build]
if: github.event_name == 'release' || inputs.sign_windows
steps:
- name: Clean workspace
run: |
rm -Recurse -Force ${{ github.workspace }}\*
- uses: actions/download-artifact@v3
with:
name: binaries-Windows
path: in
- name: Copy to build
run: |
mkdir build/windows
copy in/${{env.APP_NAME}}.exe build/${{env.APP_NAME}}.exe
- name: Sign ${{env.APP_NAME}}
working-directory: ./build
# Signs in place.
run: |
signtool sign /debug /n "Toitware ApS" /t http://timestamp.digicert.com/ $PWD/${{env.APP_NAME}}.exe
- name: Copy signed to out
run: |
mkdir out
copy build/${{env.APP_NAME}}.exe out/${{env.APP_NAME}}.exe
- name: Zip signed
run: |
cd out
7z a ${{env.APP_NAME}}-windows.zip ${{env.APP_NAME}}.exe
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: binaries-Windows-signed
path: ./out
- name: Upload release Windows executable
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: out/${{env.APP_NAME}}-windows.zip
tag: ${{ github.event.release.tag_name }}
overwrite: true
sign_macos:
runs-on: macos-latest
needs: [build]
if: github.event_name == 'release' || inputs.sign_macos
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: binaries-macOS
path: in
- name: Install dependencies
run: |
set -e
brew install create-dmg
brew install zip
- name: Copy to build
run: |
mkdir -p build
cp in/${{env.APP_NAME}} build/${{env.APP_NAME}}
- name: Setup binary rights
run: |
chmod +x build/${{env.APP_NAME}}
- name: Sign and notarize
uses: toitlang/[email protected]
with:
certificate: ${{ secrets.MACOS_CERTIFICATE }}
certificate-password: ${{ secrets.MACOS_CERTIFICATE_PWD }}
username: ${{ secrets.AC_USERNAME }}
password: ${{ secrets.AC_PASSWORD }}
apple-team-id: 33DS2ZRDST
# Signs in place.
app-path: build/${{env.APP_NAME}}
- name: Create out folder
run: |
mkdir -p out
- name: Create a DMG
run: |
# Use an empty directory as source so we don't accidentally add other files than the
# ${{env.APP_NAME}} binary.
set -e
mkdir empty
create-dmg \
--volname "${{env.APP_NAME}}" \
--add-file ${{env.APP_NAME}} build/${{env.APP_NAME}} 0 0 \
out/${{env.APP_NAME}}-macos.dmg \
empty
- name: Create a ZIP
run: |
zip -j out/${{env.APP_NAME}}-macos.zip build/${{env.APP_NAME}}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: binaries-macOS-signed
path: ./out
- name: Upload release macOS executable DMG
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: out/${{env.APP_NAME}}-macos.dmg
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload release macOS executable ZIP
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: out/${{env.APP_NAME}}-macos.zip
tag: ${{ github.event.release.tag_name }}
overwrite: true