Skip to content

Commit bd79171

Browse files
authored
Merge pull request #9649 from haskell/wip/static-pre-releases
Add static pre-release job
2 parents 663e98f + fa333bb commit bd79171

File tree

3 files changed

+109
-3
lines changed

3 files changed

+109
-3
lines changed

.github/workflows/validate.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,68 @@ jobs:
283283
EXTRA_GHC: "/opt/ghc/${{ matrix.extra-ghc }}/bin/ghc-${{ matrix.extra-ghc }}"
284284
run: sh validate.sh ${{ env.COMMON_FLAGS }} --lib-only -s lib-suite-extras --extra-hc ${{ env.EXTRA_GHC }}
285285

286+
build-alpine:
287+
name: Build statically linked using alpine
288+
runs-on: "ubuntu-latest"
289+
container: "alpine:3.19"
290+
steps:
291+
- name: Install extra dependencies
292+
shell: sh
293+
run: |
294+
apk add bash curl sudo jq pkgconfig \
295+
zlib-dev zlib-static binutils-gold curl \
296+
gcc g++ gmp-dev libc-dev libffi-dev make \
297+
musl-dev ncurses-dev perl tar xz
298+
299+
- uses: actions/checkout@v4
300+
301+
# See https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#hackage-revisions
302+
- name: Manually supplied constraints/allow-newer
303+
if: ${{ github.event_name == 'workflow_dispatch' }}
304+
run: |
305+
echo 'allow-newer:' ${ALLOWNEWER} >> cabal.project.validate
306+
echo 'constraints:' ${CONSTRAINTS} >> cabal.project.validate
307+
308+
# See the following link for a breakdown of the following step
309+
# https://github.com/haskell/actions/issues/7#issuecomment-745697160
310+
- uses: actions/cache@v3
311+
with:
312+
# validate.sh uses a special build dir
313+
path: |
314+
${{ steps.setup-haskell.outputs.cabal-store }}
315+
dist-*
316+
key: ${{ runner.os }}-${{ env.GHC_FOR_RELEASE }}-${{ github.sha }}
317+
restore-keys: ${{ runner.os }}-${{ env.GHC_FOR_RELEASE }}-
318+
319+
- uses: haskell-actions/setup@v2
320+
id: setup-haskell
321+
with:
322+
ghc-version: ${{ env.GHC_FOR_RELEASE }}
323+
cabal-version: latest # latest is mandatory for cabal-testsuite, see https://github.com/haskell/cabal/issues/8133
324+
325+
- name: Enable statically linked executables
326+
run: |
327+
echo 'executable-static: true' >> cabal.project.validate
328+
329+
- name: Build
330+
run: sh validate.sh $FLAGS -s build
331+
332+
- name: Tar cabal head executable
333+
run: |
334+
CABAL_EXEC=$(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ env.GHC_FOR_RELEASE }} --project-file=cabal.project.validate cabal-install:exe:cabal)
335+
# We have to tar the executable to preserve executable permissions
336+
# see https://github.com/actions/upload-artifact/issues/38
337+
export CABAL_EXEC_TAR="cabal-head-${{ runner.os }}-static-x86_64.tar.gz"
338+
tar -czvf $CABAL_EXEC_TAR -C $(dirname "$CABAL_EXEC") $(basename "$CABAL_EXEC")
339+
echo "CABAL_EXEC_TAR=$CABAL_EXEC_TAR" >> $GITHUB_ENV
340+
341+
- name: Upload cabal-install executable to workflow artifacts
342+
uses: actions/upload-artifact@v3
343+
with:
344+
name: cabal-${{ runner.os }}-static-x86_64
345+
path: ${{ env.CABAL_EXEC_TAR }}
346+
347+
286348
# The previous jobs use a released version of cabal to build cabal HEAD itself
287349
# This one uses the cabal HEAD generated executable in the previous step
288350
# to build itself again, as sanity check
@@ -346,7 +408,7 @@ jobs:
346408
if: github.ref == 'refs/heads/master'
347409

348410
# IMPORTANT! Any job added to the workflow should be added here too
349-
needs: [validate, validate-old-ghcs, dogfooding]
411+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
350412

351413
steps:
352414
- uses: actions/download-artifact@v3
@@ -357,6 +419,10 @@ jobs:
357419
with:
358420
name: cabal-Linux-x86_64
359421

422+
- uses: actions/download-artifact@v3
423+
with:
424+
name: cabal-Linux-static-x86_64
425+
360426
- uses: actions/download-artifact@v3
361427
with:
362428
name: cabal-macOS-x86_64
@@ -371,6 +437,7 @@ jobs:
371437
files: |
372438
cabal-head-Windows-x86_64.tar.gz
373439
cabal-head-Linux-x86_64.tar.gz
440+
cabal-head-Linux-static-x86_64.tar.gz
374441
cabal-head-macOS-x86_64.tar.gz
375442
376443
# We use this job as a summary of the workflow
@@ -382,7 +449,7 @@ jobs:
382449
name: Validate post job
383450
runs-on: ubuntu-latest
384451
# IMPORTANT! Any job added to the workflow should be added here too
385-
needs: [validate, validate-old-ghcs, dogfooding]
452+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
386453

387454
steps:
388455
- run: |

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,25 @@ Currently, [@emilypi](https://github.com/emilypi), [@fgaz](https://github.com/fg
337337
`haskell.org/cabal`, and [@Mikolaj](https://github.com/Mikolaj) is the point of contact for getting
338338
permissions.
339339

340+
Preview Releases
341+
----------------
342+
343+
We make preview releases available to facilitate testing of development builds.
344+
345+
Artifacts can be found on the [`cabal-head` release page](https://github.com/haskell/cabal/releases/tag/cabal-head).
346+
The Validate CI pipeline generates tarballs with a `cabal` executable. The executable gets uploaded to this release by the pipelines that run on `master`.
347+
348+
We currently make available builds for:
349+
- Linux, dynamically linked (requiring `zlib`, `gmp`, `glibc`)
350+
- Linux, statically linked
351+
- MacOS
352+
- Windows
353+
354+
The statically linked Linux executables are built using Alpine.
355+
To reproduce these locally, set up an Alpine build environment using GHCup,
356+
and then build by calling `cabal build cabal-install --enable-executable-static`.
357+
358+
340359
API Documentation
341360
-----------------
342361

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Ways to get the `cabal-install` binary
3030
2. _[Download from official website](https://www.haskell.org/cabal/download.html)_:
3131
the `cabal-install` binary download for your platform should contain the `cabal` executable.
3232
33+
#### Preview Releases
34+
3335
_Getting unreleased versions of `cabal-install`_: gives you a chance to try out yet-unreleased features.
3436
Currently, we only provide binaries for `x86_64` platforms.
3537
@@ -40,10 +42,28 @@ Currently, we only provide binaries for `x86_64` platforms.
4042
```
4143
4244
Replace "Linux" with "Windows" or "macOS" as appropriate.
45+
46+
The default Linux build is dynamically linked against `zlib`, `gmp` and `glibc`.
47+
You will need to have appropriate versions of these libraries installed to use it.
48+
Alternatively a statically linked "Linux-static" binary is also provided.
49+
50+
You might need to add the following to your `cabal.project` file
51+
if your build fails because of an out-of-date `Cabal` library:
52+
```
53+
allow-newer:
54+
*:Cabal,
55+
*:Cabal-syntax
56+
57+
source-repository-package
58+
type: git
59+
location: https://github.com/haskell/cabal.git
60+
subdir: Cabal Cabal-syntax
61+
```
4362
4463
4564
2. Even more cutting-edge binaries built from pull requests are always available
46-
from the `Validate` worklow page on GitHub, at the very bottom of the page.
65+
from the `Validate` worklow page on GitHub, at the very bottom of the page,
66+
or from the `build-alpine` workflow for statically linked Linux builds.
4767
4868
Ways to build `cabal-install` for everyday use
4969
--------------------------------------------

0 commit comments

Comments
 (0)