Skip to content

Commit

Permalink
Fix static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed Jul 4, 2024
1 parent b14c6f1 commit a0678ee
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 72 deletions.
140 changes: 75 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
- name: Install
run: cabal install --project-file=cabal.release.project --installdir=distribution --install-method=copy

- name: File type
run: file distribution/confer

- name: Package the confer-head executable
run: |
CONFER_EXEC=distribution/confer
Expand All @@ -78,68 +81,75 @@ jobs:
name: confer-${{ runner.os }}-${{ env.ARCH }}
path: ${{ env.CONFER_EXEC_TAR }}

# build-alpine:
# name: Build statically linked using alpine
# runs-on: ubuntu-latest
# container: 'alpine:3.19'
# needs: ['tests']
# steps:
# - name: Install extra dependencies
# shell: sh
# run: |
# apk add bash curl sudo jq pkgconfig \
# zlib-dev zlib-static binutils-gold curl \
# gcc g++ gmp-dev libc-dev libffi-dev make \
# musl-dev ncurses-dev perl tar xz git upx
#
# - uses: actions/checkout@v4
#
# - uses: haskell-actions/setup@v2
# id: setup-haskell
# with:
# ghc-version: '9.8.2'
# cabal-version: 'latest'
#
# - name: Configure
# run: |
# ARCHITECTURE=$(uname -m)
# echo "ARCH=$ARCHITECTURE" >> $GITHUB_ENV
# echo ${{ env.ARCH }}
# cabal configure --enable-tests
#
# - name: Freeze
# run: cabal freeze --project-file=cabal.static.project
#
# - uses: actions/cache@v4
# with:
# path: ${{ steps.setup-haskell.outputs.cabal-store }}
# key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-${{ hashFiles('**/plan.json') }}
# restore-keys: ${{ runner.os }}-${{ steps.setup.outputs.ghc-version }}-
#
# - name: Build
# run: cabal build --project-file=cabal.static.project
#
# - name: Test
# run: cabal test --project-file=cabal.static.project all
#
# - name: Install
# run: cabal install --project-file=cabal.static.project --installdir=distribution --install-method=copy
#
# - name: Tar cabal head executable
# run: |
# CONFER_EXEC=distribution/confer
# .github/workflows/process-binaries.sh
# DIR=$(dirname $CONFER_EXEC)
# FILE=$(basename $CONFER_EXEC)
# CONFER_EXEC_TAR=confer-head-${{ runner.os }}-static-${{ env.ARCH }}.tar.gz
# tar -czvf $CONFER_EXEC_TAR -C $DIR $FILE
# echo CONFER_EXEC_TAR=$CONFER_EXEC_TAR >> $GITHUB_ENV
#
# - name: Upload confer executable to workflow artifacts
# uses: actions/upload-artifact@v4
# with:
# name: confer-${{ runner.os }}-static-x86_64
# path: ${{ env.CONFER_EXEC_TAR }}
build-alpine:
name: 9.8.2 on alpine-3.19
runs-on: ubuntu-latest
container: 'alpine:3.19'
needs: generate-matrix
steps:
- name: Install extra dependencies
shell: sh
run: |
apk add bash binutils-gold curl \
curl file g++ gcc git gmp-dev \
jq libc-dev libffi-dev make \
musl-dev ncurses-dev perl pkgconfig \
sudo tar upx xz zlib-dev zlib-static
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: '9.8.2'
cabal-version: 'latest'

- name: Configure
run: |
ARCHITECTURE=$(uname -m)
echo "ARCH=$ARCHITECTURE" >> $GITHUB_ENV
echo ${{ env.ARCH }}
cabal configure --enable-tests
- name: Freeze
run: cabal freeze --project-file=cabal.static.project

- uses: actions/cache@v4
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ runner.os }}-${{ steps.setup.outputs.ghc-version }}-

- name: Build
run: cabal build --project-file=cabal.static.project

- name: Test
run: cabal test --project-file=cabal.static.project all

- name: Install
run: |
bin=$(cabal -v0 --project-file=cabal.static.project list-bin confer)
mkdir distribution
install ${bin} distribution/confer
- name: File type
run: file distribution/confer

- name: Tar cabal head executable
run: |
CONFER_EXEC=distribution/confer
.github/workflows/process-binaries.sh
DIR=$(dirname $CONFER_EXEC)
FILE=$(basename $CONFER_EXEC)
CONFER_EXEC_TAR=confer-head-${{ runner.os }}-static-${{ env.ARCH }}.tar.gz
tar -czvf $CONFER_EXEC_TAR -C $DIR $FILE
echo CONFER_EXEC_TAR=$CONFER_EXEC_TAR >> $GITHUB_ENV
- name: Upload confer executable to workflow artifacts
uses: actions/upload-artifact@v4
with:
name: confer-${{ runner.os }}-static-x86_64
path: ${{ env.CONFER_EXEC_TAR }}

prerelease-head:
name: Create a GitHub prerelease with the binary artifacts
Expand All @@ -155,9 +165,9 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: confer-Linux-static-x86_64
# - uses: actions/download-artifact@v3
# with:
# name: confer-Linux-static-x86_64
- uses: actions/download-artifact@v3
with:
name: confer-Linux-static-x86_64

- uses: actions/download-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/process-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CONFER_PATH="distribution/confer"

case "$(uname -s)" in
Linux*)
strip $CONFER_PATH
upx -9 $CONFER_PATH
;;
Darwin*)
Expand Down
5 changes: 1 addition & 4 deletions cabal.static.project
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import: ./cabal.release.project

executable-static: true

package confer
ghc-options: -static
ld-options: -static -pthread
split-sections: True
2 changes: 1 addition & 1 deletion src/Confer/CLI/Cmd/Deploy.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Confer.CLI.Cmd.Deploy (deploy) where

import Control.Monad
import Control.Placeholder

import Data.Text.Display
import Data.Text.IO qualified as Text
import Data.Vector (Vector)
Expand Down
2 changes: 1 addition & 1 deletion src/Confer/Config/ConfigFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Confer.Config.ConfigFile
) where

import Control.Monad (when)
import Control.Placeholder

import Data.Text qualified as Text
import Data.Text.Display
import Data.Text.IO qualified as Text
Expand Down
2 changes: 1 addition & 1 deletion src/Confer/Config/Evaluator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Confer.Config.Evaluator
) where

import Control.Monad (void, when)
import Control.Placeholder

import Data.Maybe (isNothing)
import Data.Text (Text)
import Data.Text qualified as Text
Expand Down

0 comments on commit a0678ee

Please sign in to comment.