@@ -3,150 +3,25 @@ name: Builds
33on :
44  workflow_dispatch :
55    inputs :
6-       alpine :
7-         description : ' Use alpine to build a fully static executable for linux' 
6+       version :
7+         description : ' HLS version' 
8+         required : true 
9+         type : string 
10+       tag :
11+         description : ' HLS tag' 
812        required : false 
9-         default : ' false' 
13+         type : string 
14+       project :
15+         description : ' Gitlab project number' 
16+         type : number 
17+         required : false 
18+         default : 1178 
1019  release :
1120    types : [created] 
1221
1322jobs :
14-   build :
15-     runs-on : ${{ matrix.os }} 
16-     container : ${{ (github.event.inputs.alpine == 'true' && startsWith(matrix.os,'ubuntu') && 'alpine:3.12') || '' }} 
17-     defaults :
18-       run :
19-         shell : ${{ (startsWith(matrix.os,'windows') && 'bash') || 'sh' }} 
20-     strategy :
21-       fail-fast : false 
22-       matrix :
23-         ghc :
24-           [ "9.2.1" 
25-           , "9.0.2" 
26-           , "9.0.1" 
27-           , "8.10.7" 
28-           , "8.10.6" 
29-           , "8.8.4" 
30-           , "8.6.5" 
31-           ] 
32-         os : [ "ubuntu-18.04" 
33-             , "macOS-latest" 
34-             , "windows-latest" 
35-             ] 
36-         cabal : ['3.6'] 
37- 
38-     steps :
39-     - name : Install system dependencies 
40-       if : github.event.inputs.alpine == 'true' && runner.os == 'Linux' 
41-       run : | 
42-         apk add --no-cache curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz gzip tar perl git bash sudo binutils-gold 
43-         apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static 
44-      - uses : actions/checkout@v2 
45- 
46-     - name : Disable tests and bechmarks 
47-       run : | 
48-         echo "tests: false" >> cabal.project.local 
49-         echo "benchmarks: false" >> cabal.project.local 
50- 
51-      - uses : ./.github/actions/setup-build 
52-       with :
53-         ghc : ${{ matrix.ghc }} 
54-         os :  ${{ runner.os }} 
55- 
56-     - name : (Windows) Platform specifics 
57-       if : runner.os == 'Windows' 
58-       run : | 
59-         echo "EXE_EXT=.exe" >> $GITHUB_ENV 
60- 
61-      - name : (Linux) Platform specifics 
62-       if : runner.os == 'Linux' 
63-       run : | 
64-         echo "CABAL_ARGS=--enable-executable-static --ghc-options=-split-sections" >> $GITHUB_ENV 
65- 
66-      - name : Build the server 
67-       #  Try building it twice in case of flakey builds on Windows
68-       run : | 
69-         cabal build exe:hls -O2 $CABAL_ARGS || cabal build exe:hls -O2 $CABAL_ARGS -j1 
70- 
71-      - name : Compress server binary 
72-       id : compress_server_binary 
73-       run : | 
74-         HLS_BUILD=$(find dist-newstyle \( -name 'hls' -o -name 'hls.exe' \) -type f) 
75-         HLS=haskell-language-server-${{ matrix.ghc }} 
76-         mv $HLS_BUILD $HLS${{ env.EXE_EXT }} 
77-         if [[ "${{ runner.os }}" == "Windows" ]]; then 
78-           7z a $HLS.zip $HLS${{ env.EXE_EXT }} 
79-           echo ::set-output name=path::$HLS.zip 
80-           echo ::set-output name=content_type::application/zip 
81-           echo ::set-output name=extension::zip 
82-         else 
83-           gzip --best $HLS 
84-           echo ::set-output name=path::$HLS.gz 
85-           echo ::set-output name=content_type::application/gzip 
86-           echo ::set-output name=extension::gz 
87-         fi 
88- 
89-      - name : Upload server to release 
90-       if : ${{ github.event.release.upload_url != ''}} 
91- 92-       env :
93-         GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
94-       with :
95-         upload_url : ${{ github.event.release.upload_url }} 
96-         asset_path : ${{ steps.compress_server_binary.outputs.path }} 
97-         asset_name : haskell-language-server-${{ runner.os }}-${{ matrix.ghc  }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }} 
98-         asset_content_type : ${{ steps.compress_server_binary.outputs.content_type }} 
99- 
100-     - name : Upload server to workflow artifacts 
101-       uses : actions/upload-artifact@v2 
102-       with :
103-         name : haskell-language-server-${{ runner.os }}-${{ matrix.ghc }}${{ env.EXE_EXT }}.${{ steps.compress_server_binary.outputs.extension }} 
104-         path : ${{ steps.compress_server_binary.outputs.path }} 
105- 
106-     - name : Build the wrapper 
107-       if : matrix.ghc == '8.10.7' 
108-       run : cabal build exe:hls-wrapper -O2 $CABAL_ARGS 
109- 
110-     - name : Compress wrapper binary 
111-       if : matrix.ghc == '8.10.7' 
112-       id : compress_wrapper_binary 
113-       run : | 
114-         HLS_WRAPPER_BUILD=$(find dist-newstyle \( -name 'hls-wrapper' -o -name 'hls-wrapper.exe' \) -type f) 
115-         HLS_WRAPPER=haskell-language-server-wrapper 
116-         mv $HLS_WRAPPER_BUILD $HLS_WRAPPER${{ env.EXE_EXT }} 
117-         if [[ "${{ runner.os }}" == "Windows" ]]; then 
118-           7z a $HLS_WRAPPER.zip $HLS_WRAPPER${{ env.EXE_EXT }} 
119-           echo ::set-output name=path::$HLS_WRAPPER.zip 
120-           echo ::set-output name=content_type::application/zip 
121-           echo ::set-output name=extension::zip 
122-         else 
123-           gzip --best $HLS_WRAPPER 
124-           echo ::set-output name=path::$HLS_WRAPPER.gz 
125-           echo ::set-output name=content_type::application/gzip 
126-           echo ::set-output name=extension::gz 
127-         fi 
128- 
129-      - name : Upload wrapper to the release 
130-       if : ${{ matrix.ghc == '8.10.7' && github.event.release.upload_url != '' }} 
131- 132-       env :
133-         GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
134-       with :
135-         upload_url : ${{ github.event.release.upload_url }} 
136-         asset_path : ${{ steps.compress_wrapper_binary.outputs.path }} 
137-         asset_name : haskell-language-server-wrapper-${{ runner.os }}${{ env.EXE_EXT }}.${{ steps.compress_wrapper_binary.outputs.extension }} 
138-         asset_content_type : ${{ steps.compress_wrapper_binary.outputs.content_type}} 
139- 
140-     - name : Upload wrapper to workflow artifacts 
141-       uses : actions/upload-artifact@v2 
142-       if : matrix.ghc == '8.10.7' 
143-       with :
144-         name : haskell-language-server-wrapper-${{ runner.os }}${{ env.EXE_EXT }}.${{ steps.compress_wrapper_binary.outputs.extension }} 
145-         path : ${{ steps.compress_wrapper_binary.outputs.path }} 
146- 
14723  #  generates a custom tarball with sources, used by `ghcup compile hls`
14824  src-tar :
149-     needs : build 
15025    runs-on : ubuntu-18.04 
15126
15227    steps :
@@ -189,43 +64,85 @@ jobs:
18964  #  this generates .gz tarfiles containing binaries for all GHC versions and OS's
19065  #  used by `ghcup install hls`
19166  tar :
192-     needs : build 
193-     runs-on : ubuntu-18.04 
194-     strategy :
195-       matrix :
196-         target-os : [ "Linux" 
197-                    , "macOS" 
198-                    , "Windows" 
199-                    ] 
67+     runs-on : ubuntu-latest 
20068    steps :
201-       - uses : actions/download-artifact@v2 
202- 
203-       - name : Generate tarball with all binaries 
69+       - name : Download tarballs from gitlab 
20470        run : | 
205-           # move the binaries for the specific platform into bin/ 
206-           mkdir bin 
207-           mv haskell-language-server-${{ matrix.target-os }}-*/* bin 
208-           mv haskell-language-server-wrapper-${{ matrix.target-os }}.*/* bin 
209-           # decompress them 
210-           cd bin 
211-           if [[ "${{ matrix.target-os }}" == "Windows" ]]; then 
212-             7z x "*.zip" 
213-             rm *.zip 
71+           set -eux 
72+ 
73+           if [ -n "${{ github.event.inputs.project }}" ] ; then 
74+             proj=${{ github.event.inputs.project }} 
21475          else 
215-             gzip -d *.gz 
76+             proj=1178 
77+           fi 
78+ 
79+           if [ -n "${{ github.event.release.tag_name }}" ] ; then 
80+             tag=${{ github.event.release.tag_name }} 
81+             ver=1.6.1.1 
82+             # ver=${tag/v/} 
83+           elif [ -n "${{ github.event.inputs.version }}" ] ; then 
84+             ver=${{ github.event.inputs.version }} 
85+             if [ -z "${{ github.event.inputs.tag }}" ] ; then 
86+                 tag=${{ github.event.inputs.tag }} 
87+             else 
88+                 tag=v${ver} 
89+             fi 
21690          fi 
217-           tar -czpf haskell-language-server.tar.gz * 
91+ 
92+           base_url="https://gitlab.haskell.org/api/v4/projects/${proj}/jobs/artifacts/${tag}/raw" 
93+ 
94+           # unix like platforms 
95+           for plat in aarch64-apple-darwin \ 
96+               aarch64-deb10-linux \ 
97+               armv7-deb10-linux \ 
98+               x86_64-apple-darwin \ 
99+               x86_64-unknown-freebsd12 \ 
100+               x86_64-unknown-freebsd13 \ 
101+               x86_64-alpine3.12-linux \ 
102+               x86_64-centos7-linux \ 
103+               x86_64-deb9-linux \ 
104+               x86_64-deb10-linux \ 
105+               x86_64-fedora27-linux ; do 
106+               url="${base_url}/out/haskell-language-server-${ver}-${plat}.tar.xz?job=tar-$(echo "${plat/alpine3.12/alpine}" | awk -F '-' '{ print ($3 == "darwin" || $2 == "unknown") ? $1 "-" $3 : $1 "-" $3 "-" $2 }')" 
107+               curl -f -o "haskell-language-server-${ver}-${plat}.tar.xz" "${url}" 
108+           done 
109+           unset plat url 
110+ 
111+           # windows 
112+           curl -f -o "haskell-language-server-${ver}-x86_64-unknown-mingw32.zip" \ 
113+               "${base_url}/out/haskell-language-server-${ver}-x86_64-unknown-mingw32.zip?job=tar-x86_64-windows" 
114+ 
115+           pwd 
116+           ls -lah 
117+          env :
118+           ver : ${{ github.event.inputs.version }} 
119+           tag : ${{ github.event.inputs.tag }} 
120+           proj : ${{ github.event.inputs.project }} 
218121
219122      - name : Upload binaries tarball to the release 
220123        if : ${{ github.event.release.upload_url != '' }} 
221- 222-         env :
223-           GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
124+         uses : actions/github-script@v2 
224125        with :
225-           upload_url : ${{ github.event.release.upload_url }} 
226-           asset_path : bin/haskell-language-server.tar.gz 
227-           asset_name : haskell-language-server-${{ matrix.target-os }}-${{ github.event.release.tag_name }}.tar.gz 
228-           asset_content_type : application/gzip 
126+           github-token : ${{secrets.GITHUB_TOKEN}} 
127+           script : | 
128+             console.log('environment', process.versions); 
129+ 
130+             const fs = require('fs').promises; 
131+ 
132+             const { repo: { owner, repo }, sha } = context; 
133+             console.log({ owner, repo, sha }); 
134+ 
135+             for (let file of await fs.readdir('.')) { 
136+               // do whatever filtering you want here, I'm just uploading all the files 
137+               console.log('uploading', file); 
138+ 
139+               await github.repos.uploadReleaseAsset({ 
140+                 owner, repo, 
141+                 release_id: ${{ github.event.release.id }}, 
142+                 name: file, 
143+                 data: await fs.readFile(`./${file}`) 
144+               }); 
145+             } 
229146
230147       - name : Set hls release version 
231148        run : | 
@@ -239,8 +156,7 @@ jobs:
239156       - name : Upload binaries tarball to workflow artifacts 
240157        uses : actions/upload-artifact@v2 
241158        with :
242-           name : haskell-language-server-${{ matrix.target-os }}-${{ env.HLS_VER }}.tar.gz 
243-           path : bin/haskell-language-server.tar.gz 
159+           path : ${{ github.workspace }}/* 
244160
245161  sha256sum :
246162    needs : [tar, src-tar] 
0 commit comments