-
Notifications
You must be signed in to change notification settings - Fork 8
271 lines (228 loc) · 7.94 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
name: CI
on:
push:
branches: ["main"]
tags: ["v*"]
pull_request:
branches: ["*"]
env:
JAVA_OPTS: "-Xmx4G"
JVM_OPTS: "-Xmx4G"
SBT_OPTS: "-Xmx4G"
LLVM_VERSION: 17
jobs:
macos_build:
name: MacOS (${{ matrix.OS }})
strategy:
fail-fast: true
matrix:
OS: ["macos-12", "macos-14"]
runs-on: ${{ matrix.OS }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Install SBT
run: |
curl -Lo sbt https://raw.githubusercontent.com/sbt/sbt/1.9.x/sbt && \
chmod +x sbt
- name: Install LLVM
run: brew install llvm@$LLVM_VERSION
- name: Sets env vars for release
run: |
echo "SCALANATIVE_MODE=release-fast" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')
- name: Sets env vars for LLVM
run: |
if [ $(arch) == "arm64" ]; then
echo "LLVM_BIN=/opt/homebrew/opt/llvm@$LLVM_VERSION/bin" >> $GITHUB_ENV
else
echo "LLVM_BIN=/usr/local/opt/llvm@$LLVM_VERSION/bin" >> $GITHUB_ENV
fi
- name: CI and build the binary
run: ./sbt ci buildPlatformBinary
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: bin/sn-bindgen-*
name: ${{ matrix.os }}-binaries
if-no-files-found: error
linux_build:
name: Linux
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Setup Unix-like
run: ./build/setup_unix.sh
- name: Sets env vars for release
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')
run: |
echo "SCALANATIVE_MODE=release-fast" >> $GITHUB_ENV
- name: Sets env vars for LLVM
run: |
echo "LLVM_BIN=/usr/lib/llvm-$LLVM_VERSION/bin" >> $GITHUB_ENV
- name: CI and build the binary
run: sbt ci buildPlatformBinary
- name: Build site
run: sbt buildWebsite
- name: Upload Intel artifacts
uses: actions/upload-artifact@v4
with:
path: bin/sn-bindgen-*
name: linux-binaries
if-no-files-found: error
linux_arm64_build:
name: Linux (Arm64)
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
# if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# - name: Arm64 build
# run: |
# docker build -f .github/workflows/fixtures/Dockerfile . -t sn-bindgen-docker
# docker run -v $PWD:/source -it sn-bindgen-docker sbt clean buildPlatformBinary
# - name: Upload Arm64 artifacts
# uses: actions/upload-artifact@master
# with:
# path: bin/sn-bindgen-*
# name: binaries
# if-no-files-found: error
windows_build:
name: Windows (Intel)
strategy:
fail-fast: false
runs-on: windows-2019
env:
LLVM_BIN: 'C:\Program Files\LLVM\bin'
LLVM_VERSION: "17.0.6"
steps:
# This step is important to make sure scalafmt
# checks don't fail
- name: Setup git config
run: git config --global core.autocrlf false
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
# See https://github.com/scala-native/scala-native/blob/master/.github/actions/windows-setup-env/action.yml#L14 SN_RELE
# for details
- name: Configure Pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 4GB
maximum-size: 16GB
- run: clang -v
shell: cmd
- name: Sets env vars for release
run: |
echo "SCALANATIVE_MODE=release-fast" >> $env:GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')
shell: pwsh
- name: Install clang and SBT
shell: pwsh
run: |
choco install llvm --version="$Env:LLVM_VERSION" --allow-downgrade
choco install sbt --version=1.9.7
clang --version
- name: SBT remote cache
id: remote-cache
uses: actions/cache@v3
with:
path: ./target/remote-cache
key: ${{ runner.os }}-remote-cache
- name: Pull cache
run: sbt pullRemoteCache || echo 'remote cache not found'
# Can't make shell type come from a matrix parameter:
# https://github.community/t/using-matrix-to-specify-shell-is-it-possible/17065/2
- name: CI (windows)
run: sbt ci buildPlatformBinary
shell: cmd
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: bin/sn-bindgen-*
name: windows-binaries
if-no-files-found: error
release:
if: ${{ always() }}
needs: [linux_build, linux_arm64_build, windows_build, macos_build]
name: Release
runs-on: ubuntu-20.04
env:
BINARIES: binaries/
LLVM_BIN: /usr/lib/llvm-17/bin
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Download binaries
uses: actions/download-artifact@v4
id: download
with:
path: binaries
- name: List downloaded binaries
run: ls -R binaries
- name: Check published artifacts
run: |
set -e
ls -R binaries/
sbt checkDetectedArtifacts versionDump binaryArtifacts/publishLocal iface3/publishLocal iface/publishLocal iface2_12/publishLocal
curl -fLo cs https://git.io/coursier-cli-"$(uname | tr LD ld)"
chmod +x cs
./cs resolve com.indoorvivants:bindgen-interface_2.13:$(cat version)
./cs resolve com.indoorvivants:bindgen-interface_3:$(cat version)
./cs resolve com.indoorvivants:bindgen-interface_2.12:$(cat version)
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier osx-x86_64 --artifact-type jar
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier osx-aarch64 --artifact-type jar
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier linux-x86_64 --artifact-type jar
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier linux-aarch64 --artifact-type jar
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier windows-x86_64 --artifact-type jar
- name: Publish
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')
run: |
sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
- name: Setup Unix-like
run: ./build/setup_unix.sh
- name: Build site
run: sbt buildWebsite
- name: Publish gh-pages
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
- name: Upload release binaries
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: "${{steps.download.outputs.download-path}}/**/sn-bindgen-*"