Skip to content

Commit

Permalink
Rename binaries before uploading
Browse files Browse the repository at this point in the history
Also use zip as compression method for Windows
Fixes haskell#225
  • Loading branch information
lukel97 committed Jul 27, 2020
1 parent f2384e1 commit e121d68
Showing 1 changed file with 46 additions and 29 deletions.
75 changes: 46 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Builds

defaults:
run:
shell: bash

on:
release:
types: [created]
Expand Down Expand Up @@ -28,14 +32,7 @@ jobs:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2'

- name: Cache Cabal
uses: actions/cache@v1.2.0
with:
path: ~/.cabal
key: ${{ runner.OS }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}

- name: Shorten binary names
shell: bash
run: |
sed -i.bak -e 's/haskell-language-server/hls/g' \
-e 's/haskell_language_server/hls/g' \
Expand All @@ -45,7 +42,6 @@ jobs:
- name: Set some window specific things
if: matrix.os == 'windows-latest'
shell: bash
run: |
echo '::set-env name=EXE_EXT::.exe'
Expand All @@ -55,47 +51,68 @@ jobs:
echo '::set-env name=LINUX_CABAL_ARGS::--enable-executable-static --ghc-options=-split-sections'
- name: Build Server
shell: bash
# Try building it twice in case of flakey builds on Windows
run: |
cabal build exe:hls -O2 --disable-documentation $LINUX_CABAL_ARGS || \
cabal build exe:hls -O2 --disable-documentation $LINUX_CABAL_ARGS
- name: Find Server Binary
id: find_server_binary
shell: bash
- name: Compress Server Binary
id: compress_server_binary
env:
GHC_VER: ${{ matrix.ghc }}
run: |
HLS=$(find dist-newstyle \( -name 'hls' -o -name 'hls.exe' \) -type f)
gzip --best $HLS
echo ::set-output name=hls_binary::$HLS.gz
HLS_BUILD=$(find dist-newstyle \( -name 'hls' -o -name 'hls.exe' \) -type f)
HLS=haskell-language-server-$GHC_VER
mv $HLS_BUILD $HLS
if [[ "$OSTYPE" == "msys" ]]; then
7z a $HLS.zip $HLS
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 Binary
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.find_server_binary.outputs.hls_binary }}
asset_name: haskell-language-server-${{ runner.OS }}-${{ matrix.ghc }}${{env.EXE_EXT}}.gz
asset_content_type: application/gzip
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 }}

- uses: actions/upload-artifact@v2
with:
name: haskell-language-server-${{ runner.OS }}-${{ matrix.ghc }}${{env.EXE_EXT}}.gz
path: ${{ steps.find_server_binary.outputs.hls_binary }}
path: ${{ steps.compress_server_binary.outputs.path }}

- name: Build Wrapper
if: matrix.ghc == '8.10.1'
run: cabal build exe:hls-wrapper -O2 --disable-documentation $WIN_CABAL_ARGS $LINUX_CABAL_ARGS

- name: Find Wrapper Binary
- name: Compress Wrapper Binary
if: matrix.ghc == '8.10.1'
id: find_wrapper_binary
shell: bash
id: compress_wrapper_binary
run: |
HLS_WRAPPER=$(find dist-newstyle \( -name 'hls-wrapper' -o -name 'hls-wrapper.exe' \) -type f)
gzip --best $HLS_WRAPPER
echo ::set-output name=hls_wrapper_binary::$HLS_WRAPPER.gz
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
if [[ "$OSTYPE" == "msys" ]]; then
zip $HLS_WRAPPER.zip $HLS_WRAPPER
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
if: matrix.ghc == '8.10.1'
Expand All @@ -104,13 +121,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.find_wrapper_binary.outputs.hls_wrapper_binary }}
asset_name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.gz
asset_content_type: application/gzip
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}}

- uses: actions/upload-artifact@v2
if: matrix.ghc == '8.10.1'
with:
name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.gz
path: ${{ steps.find_wrapper_binary.outputs.hls_wrapper_binary }}
path: ${{ steps.compress_wrapper_binary.outputs.path }}

0 comments on commit e121d68

Please sign in to comment.