forked from haskell/haskell-language-server
272 lines (242 loc) · 9.66 KB
/
build.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
name: Builds
on:
workflow_dispatch:
inputs:
alpine:
description: 'Use alpine to build a fully static executable for linux'
required: false
default: 'false'
release:
types: [created]
jobs:
build:
runs-on: ${{ matrix.os }}
container: ${{ (github.event.inputs.alpine == 'true' && startsWith(matrix.os,'ubuntu') && 'alpine:3.12') || '' }}
defaults:
run:
shell: ${{ (startsWith(matrix.os,'windows') && 'bash') || 'sh' }}
strategy:
fail-fast: false
matrix:
ghc:
[ "9.2.1"
, "9.0.2"
, "9.0.1"
, "8.10.7"
, "8.10.6"
, "8.8.4"
, "8.6.5"
]
os: [ "ubuntu-18.04"
, "macOS-latest"
, "windows-latest"
]
cabal: ['3.6']
steps:
- name: Install system dependencies
if: github.event.inputs.alpine == 'true' && runner.os == 'Linux'
run: |
apk add --no-cache curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz gzip tar perl git bash sudo binutils-gold
apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static
- uses: actions/checkout@v2
- name: Disable tests and bechmarks
run: |
echo "tests: false" >> cabal.project.local
echo "benchmarks: false" >> cabal.project.local
- uses: ./.github/actions/setup-build
with:
ghc: ${{ matrix.ghc }}
os: ${{ runner.os }}
- name: (Windows) Platform specifics
if: runner.os == 'Windows'
run: |
echo "EXE_EXT=.exe" >> $GITHUB_ENV
- name: (Linux) Platform specifics
if: runner.os == 'Linux'
run: |
echo "CABAL_ARGS=--enable-executable-static --ghc-options=-split-sections" >> $GITHUB_ENV
- name: Build the server
# Try building it twice in case of flakey builds on Windows
run: |
cabal build exe:hls -O2 $CABAL_ARGS || cabal build exe:hls -O2 $CABAL_ARGS -j1
- name: Compress server binary
id: compress_server_binary
run: |
HLS_BUILD=$(find dist-newstyle \( -name 'hls' -o -name 'hls.exe' \) -type f)
HLS=haskell-language-server-${{ matrix.ghc }}
mv $HLS_BUILD $HLS${{ env.EXE_EXT }}
if [[ "${{ runner.os }}" == "Windows" ]]; then
7z a $HLS.zip $HLS${{ env.EXE_EXT }}
echo ::set-output name=path::$HLS.zip
echo ::set-output name=content_type::application/zip
echo ::set-output name=extension::zip
else
gzip --best $HLS
echo ::set-output name=path::$HLS.gz
echo ::set-output name=content_type::application/gzip
echo ::set-output name=extension::gz
fi
- name: Upload server to release
if: ${{ github.event.release.upload_url != ''}}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.compress_server_binary.outputs.path }}
asset_name: haskell-language-server-${{ runner.os }}-${{ matrix.ghc }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
asset_content_type: ${{ steps.compress_server_binary.outputs.content_type }}
- name: Upload server to workflow artifacts
uses: actions/upload-artifact@v2
with:
name: haskell-language-server-${{ runner.os }}-${{ matrix.ghc }}${{ env.EXE_EXT }}.${{ steps.compress_server_binary.outputs.extension }}
path: ${{ steps.compress_server_binary.outputs.path }}
- name: Build the wrapper
if: matrix.ghc == '8.10.7'
run: cabal build exe:hls-wrapper -O2 $LINUX_CABAL_ARGS
- name: Compress wrapper binary
if: matrix.ghc == '8.10.7'
id: compress_wrapper_binary
run: |
HLS_WRAPPER_BUILD=$(find dist-newstyle \( -name 'hls-wrapper' -o -name 'hls-wrapper.exe' \) -type f)
HLS_WRAPPER=haskell-language-server-wrapper
mv $HLS_WRAPPER_BUILD $HLS_WRAPPER${{ env.EXE_EXT }}
if [[ "${{ runner.os }}" == "Windows" ]]; then
7z a $HLS_WRAPPER.zip $HLS_WRAPPER${{ env.EXE_EXT }}
echo ::set-output name=path::$HLS_WRAPPER.zip
echo ::set-output name=content_type::application/zip
echo ::set-output name=extension::zip
else
gzip --best $HLS_WRAPPER
echo ::set-output name=path::$HLS_WRAPPER.gz
echo ::set-output name=content_type::application/gzip
echo ::set-output name=extension::gz
fi
- name: Upload wrapper to the release
if: ${{ matrix.ghc == '8.10.7' && github.event.release.upload_url != '' }}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.compress_wrapper_binary.outputs.path }}
asset_name: haskell-language-server-wrapper-${{ runner.os }}${{ env.EXE_EXT }}.${{ steps.compress_wrapper_binary.outputs.extension }}
asset_content_type: ${{ steps.compress_wrapper_binary.outputs.content_type}}
- name: Upload wrapper to workflow artifacts
uses: actions/upload-artifact@v2
if: matrix.ghc == '8.10.7'
with:
name: haskell-language-server-wrapper-${{ runner.os }}${{ env.EXE_EXT }}.${{ steps.compress_wrapper_binary.outputs.extension }}
path: ${{ steps.compress_wrapper_binary.outputs.path }}
# generates a custom tarball with sources, used by `ghcup compile hls`
src-tar:
needs: build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set hls release version
run: |
HLS_VER="${{ github.event.release.tag_name }}"
if [[ -z $HLS_VER ]]; then
HLS_VER=${{ github.sha }}
HLS_VER=${HLS_VER:0:5}
fi
echo "HLS_VER=$HLS_VER" >> $GITHUB_ENV
- name: Create source tarball
run: |
mkdir src-dist
git archive --prefix=haskell-language-server-${{ env.HLS_VER }}/ \
--format=tar.gz \
-o src-dist/haskell-language-server.tar.gz \
HEAD
- name: Upload source tarball to the release
if: ${{ github.event.release.upload_url != '' }}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: src-dist/haskell-language-server.tar.gz
asset_name: haskell-language-server-${{ env.HLS_VER }}-src.tar.gz
asset_content_type: application/gzip
- name: Upload source tarball to workflow artifacts
uses: actions/upload-artifact@v2
with:
name: haskell-language-server-${{ env.HLS_VER }}-src.tar.gz
path: src-dist/haskell-language-server.tar.gz
# this generates .gz tarfiles containing binaries for all GHC versions and OS's
# used by `ghcup install hls`
tar:
needs: build
runs-on: ubuntu-18.04
strategy:
matrix:
target-os: [ "Linux"
, "macOS"
, "Windows"
]
steps:
- uses: actions/download-artifact@v2
- name: Generate tarball with all binaries
run: |
# move the binaries for the specific platform into bin/
mkdir bin
mv haskell-language-server-${{ matrix.target-os }}-*/* bin
mv haskell-language-server-wrapper-${{ matrix.target-os }}.*/* bin
# decompress them
cd bin
if [[ "${{ matrix.target-os }}" == "Windows" ]]; then
7z x "*.zip"
rm *.zip
else
gzip -d *.gz
fi
tar -czpf haskell-language-server.tar.gz *
- name: Upload binaries tarball to the release
if: ${{ github.event.release.upload_url != '' }}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: bin/haskell-language-server.tar.gz
asset_name: haskell-language-server-${{ matrix.target-os }}-${{ github.event.release.tag_name }}.tar.gz
asset_content_type: application/gzip
- name: Set hls release version
run: |
HLS_VER="${{ github.event.release.tag_name }}"
if [[ -z $HLS_VER ]]; then
HLS_VER=${{ github.sha }}
HLS_VER=${HLS_VER:0:5}
fi
echo "HLS_VER=$HLS_VER" >> $GITHUB_ENV
- name: Upload binaries tarball to workflow artifacts
uses: actions/upload-artifact@v2
with:
name: haskell-language-server-${{ matrix.target-os }}-${{ env.HLS_VER }}.tar.gz
path: bin/haskell-language-server.tar.gz
sha256sum:
needs: [tar, src-tar]
runs-on: ubuntu-18.04
steps:
- uses: actions/download-artifact@v2
- name: Generate sha256 sums for all workflow artifacts
run: |
sha256sum --tag haskell-language-server*/* >> SHA256SUMS
# we clean up tags to match the release file names
sed -i 's/\/.*)/)/g' SHA256SUMS
- name: Upload sha256sums to the release
if: ${{ github.event.release.upload_url != '' }}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: SHA256SUMS
asset_name: SHA256SUMS
asset_content_type: plain/text
- name: Upload sha256sums to workflow artifacts
uses: actions/upload-artifact@v2
with:
name: SHA256SUMS
path: SHA256SUMS