|
1 |
| -name: Builds |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_dispatch:
|
5 | 5 | 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' |
8 | 12 | required: false
|
9 |
| - default: 'false' |
| 13 | + type: string |
| 14 | + project: |
| 15 | + description: 'Gitlab project number' |
| 16 | + type: number |
| 17 | + required: false |
| 18 | + default: 1180 |
10 | 19 | release:
|
11 | 20 | types: [created]
|
12 | 21 |
|
13 | 22 | jobs:
|
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 |
| - |
147 | 23 | # generates a custom tarball with sources, used by `ghcup compile hls`
|
148 | 24 | src-tar:
|
149 |
| - needs: build |
150 | 25 | runs-on: ubuntu-18.04
|
151 | 26 |
|
152 | 27 | steps:
|
@@ -189,58 +64,85 @@ jobs:
|
189 | 64 | # this generates .gz tarfiles containing binaries for all GHC versions and OS's
|
190 | 65 | # used by `ghcup install hls`
|
191 | 66 | 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 |
200 | 68 | steps:
|
201 |
| - - uses: actions/download-artifact@v2 |
202 |
| - |
203 |
| - - name: Generate tarball with all binaries |
| 69 | + - name: Download tarballs from gitlab |
204 | 70 | 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 }} |
214 | 75 | else
|
215 |
| - gzip -d *.gz |
| 76 | + proj=1180 |
| 77 | + fi |
| 78 | +
|
| 79 | + if [ -n "${{ github.event.release.tag_name }}" ] ; then |
| 80 | + tag=${{ github.event.release.tag_name }} |
| 81 | + ver=${tag#v} |
| 82 | + elif [ -n "${{ github.event.inputs.version }}" ] ; then |
| 83 | + ver=${{ github.event.inputs.version }} |
| 84 | + if [ -n "${{ github.event.inputs.tag }}" ] ; then |
| 85 | + tag=${{ github.event.inputs.tag }} |
| 86 | + else |
| 87 | + tag=v${ver} |
| 88 | + fi |
216 | 89 | fi
|
217 |
| - tar -czpf haskell-language-server.tar.gz * |
218 | 90 |
|
| 91 | + base_url="https://gitlab.haskell.org/api/v4/projects/${proj}/jobs/artifacts/${tag}/raw" |
| 92 | +
|
| 93 | + # unix like platforms |
| 94 | + for plat in aarch64-apple-darwin \ |
| 95 | + aarch64-deb10-linux \ |
| 96 | + armv7-deb10-linux \ |
| 97 | + x86_64-apple-darwin \ |
| 98 | + x86_64-unknown-freebsd12 \ |
| 99 | + x86_64-unknown-freebsd13 \ |
| 100 | + x86_64-alpine3.12-linux \ |
| 101 | + x86_64-centos7-linux \ |
| 102 | + x86_64-deb9-linux \ |
| 103 | + x86_64-deb10-linux \ |
| 104 | + x86_64-fedora27-linux ; do |
| 105 | + 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 }')" |
| 106 | + curl -f -o "haskell-language-server-${ver}-${plat}.tar.xz" "${url}" |
| 107 | + done |
| 108 | + unset plat url |
| 109 | +
|
| 110 | + # windows |
| 111 | + curl -f -o "haskell-language-server-${ver}-x86_64-unknown-mingw32.zip" \ |
| 112 | + "${base_url}/out/haskell-language-server-${ver}-x86_64-unknown-mingw32.zip?job=tar-x86_64-windows" |
| 113 | +
|
| 114 | + pwd |
| 115 | + ls -lah |
| 116 | +
|
| 117 | + # from https://github.com/actions/upload-release-asset/issues/47#issuecomment-659071145 |
219 | 118 | - name: Upload binaries tarball to the release
|
220 | 119 | if: ${{ github.event.release.upload_url != '' }}
|
221 |
| - |
222 |
| - env: |
223 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + uses: actions/github-script@v2 |
224 | 121 | 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 |
| 122 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 123 | + script: | |
| 124 | + console.log('environment', process.versions); |
229 | 125 |
|
230 |
| - - name: Set hls release version |
231 |
| - run: | |
232 |
| - HLS_VER="${{ github.event.release.tag_name }}" |
233 |
| - if [[ -z $HLS_VER ]]; then |
234 |
| - HLS_VER=${{ github.sha }} |
235 |
| - HLS_VER=${HLS_VER:0:5} |
236 |
| - fi |
237 |
| - echo "HLS_VER=$HLS_VER" >> $GITHUB_ENV |
| 126 | + const fs = require('fs').promises; |
| 127 | +
|
| 128 | + const { repo: { owner, repo }, sha } = context; |
| 129 | + console.log({ owner, repo, sha }); |
| 130 | +
|
| 131 | + for (let file of await fs.readdir('.')) { |
| 132 | + console.log('uploading', file); |
| 133 | +
|
| 134 | + await github.repos.uploadReleaseAsset({ |
| 135 | + owner, repo, |
| 136 | + release_id: ${{ github.event.release.id }}, |
| 137 | + name: file, |
| 138 | + data: await fs.readFile(`./${file}`) |
| 139 | + }); |
| 140 | + } |
238 | 141 |
|
239 | 142 | - name: Upload binaries tarball to workflow artifacts
|
240 | 143 | uses: actions/upload-artifact@v2
|
241 | 144 | with:
|
242 |
| - name: haskell-language-server-${{ matrix.target-os }}-${{ env.HLS_VER }}.tar.gz |
243 |
| - path: bin/haskell-language-server.tar.gz |
| 145 | + path: ${{ github.workspace }}/* |
244 | 146 |
|
245 | 147 | sha256sum:
|
246 | 148 | needs: [tar, src-tar]
|
|
0 commit comments