-
-
Notifications
You must be signed in to change notification settings - Fork 323
207 lines (176 loc) · 7.83 KB
/
binaries-linux-x64.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Runs on any push to ci-linux-x64.
# Produces optimised static x64 linux binaries,
# using the GHC version below and (cabal or stack)
# and Alpine linux, which provides the statically-linkable musl.
# Currently runs no tests.
# Was using ghc 9.0 to avoid segfaults with the ghc 9.2 binaries on alpine, https://gitlab.haskell.org/ghc/ghc/-/issues/20266
# Trying latest ghc 9.8 now.
name: binaries-linux-x64
on:
push:
branches: [ binaries-linux-x64, binaries ]
#tags:
# - '[0-9]+.[0-9]+'
# - '[0-9]+.[0-9]+-*'
# - '[0-9]+.[0-9]+.[0-9]+'
# - '[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container: alpine:edge
steps:
- name: Check out
uses: actions/checkout@v3
# have to fetch everything for git describe for --version
with:
fetch-depth: 0
- name: Check embedded files
run: |
tools/checkembeddedfiles
if: env.CONTINUE
- name: Uncache ghcup-installed tools
id: ghcup
uses: actions/cache@v3
with:
path: ~/.ghcup
key: ${{ runner.os }}-ghcup-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-ghcup
# - name: Uncache cabal-installed libs
# id: cabal
# uses: actions/cache@v3
# with:
# path: ~/.cabal
# key: ${{ runner.os }}-cabal-${{ hashFiles('**.yaml') }}
# restore-keys: |
# ${{ runner.os }}-cabal
- name: Uncache stack global package db
id: stack-global
uses: actions/cache@v3
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-20240417-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-20240417
if: env.CONTINUE
- name: Uncache stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache@v3
with:
path: ~/.local/bin
key: ${{ runner.os }}-stack-programs-20240417-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-programs-20240417
if: env.CONTINUE
- name: Uncache .stack-work
uses: actions/cache@v3
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-20240417-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-work-20240417
if: env.CONTINUE
- name: Uncache hledger-lib/.stack-work
uses: actions/cache@v3
with:
path: hledger-lib/.stack-work
key: ${{ runner.os }}-hledger-lib-stack-work-20240417-${{ hashFiles('hledger-lib/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-lib-stack-work-20240417
if: env.CONTINUE
- name: Uncache hledger/.stack-work
uses: actions/cache@v3
with:
path: hledger/.stack-work
key: ${{ runner.os }}-hledger-stack-work-20240417-${{ hashFiles('hledger/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-stack-work-20240417
if: env.CONTINUE
- name: Uncache hledger-ui/.stack-work
uses: actions/cache@v3
with:
path: hledger-ui/.stack-work
key: ${{ runner.os }}-hledger-ui-stack-work-20240417-${{ hashFiles('hledger-ui/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-ui-stack-work-20240417
if: env.CONTINUE
- name: Uncache hledger-web/.stack-work
uses: actions/cache@v3
with:
path: hledger-web/.stack-work
key: ${{ runner.os }}-hledger-web-stack-work-20240417-${{ hashFiles('hledger-web/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-web-stack-work-20240417
if: env.CONTINUE
- name: Install general tools with system package manager
run: |
apk --no-cache add binutils-gold curl gcc g++ git gmp-dev ncurses-dev ncurses-static libffi-dev make xz tar perl zlib-dev zlib-static
- name: Fix $HOME for following steps (workaround from https://github.com/actions/runner/issues/863)
run: |
apk --no-cache add sudo
echo "setting HOME=/root"
echo HOME=/root | sudo tee -a $GITHUB_ENV
# stack will also need --allow-different-user for some reason
- name: Add .ghcup/bin to PATH for following steps
run: |
echo "$HOME/.ghcup/bin/" >> $GITHUB_PATH
- name: Install haskell tools with ghcup if needed
run: |
if [[ ! -x ~/.ghcup/bin/ghcup ]]; then mkdir -p ~/.ghcup/bin && curl https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup > ~/.ghcup/bin/ghcup && chmod +x ~/.ghcup/bin/ghcup; fi; printf "ghcup: "; ghcup --version
# if [[ ! -x ~/.ghcup/bin/ghc-9.8.2 ]]; then ~/.ghcup/bin/ghcup install ghc 9.8.2 && ~/.ghcup/bin/ghcup set ghc 9.8.2; fi; printf "ghc: "; ghc --version
if [[ ! -x ~/.ghcup/bin/cabal ]]; then ~/.ghcup/bin/ghcup install cabal 3.10.3.0 && ~/.ghcup/bin/ghcup set cabal 3.10.3.0; fi; printf "cabal: "; cabal --version
if [[ ! -x ~/.ghcup/bin/stack ]]; then ~/.ghcup/bin/ghcup install stack 2.15.5 && ~/.ghcup/bin/ghcup set stack 2.15.5; fi; printf "stack: "; stack --version
# build with cabal
# failing with: lto1: fatal error: bytecode stream in file '/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../lib/libgmp.a' generated with LTO version 13.0 instead of the expected 13.1
# - name: Update cabal package index
# run: |
# cabal update
# - name: Build with cabal
# run: |
# cabal build --enable-executable-static hledger || (echo "ERROR: building hledger failed"; false)
# cabal build --enable-executable-static hledger-ui || (echo "ERROR: building hledger-ui failed"; false)
# cabal build --enable-executable-static hledger-web || (echo "ERROR: building hledger-web failed"; false)
# - name: Gather binaries
# run: |
# mkdir tmp
# cp dist-newstyle/build/x86_64-linux/ghc-*/hledger-*/x/hledger/build/hledger/hledger tmp
# cp dist-newstyle/build/x86_64-linux/ghc-*/hledger-ui-*/x/hledger-ui/build/hledger-ui/hledger-ui tmp
# cp dist-newstyle/build/x86_64-linux/ghc-*/hledger-web-*/x/hledger-web/build/hledger-web/hledger-web tmp
# cd tmp
# strip hledger
# strip hledger-ui
# strip hledger-web
# tar cvf hledger-linux-x64.tar hledger hledger-ui hledger-web
# build with stack
# --allow-different-user is needed because of #863 above, or because we're in a docker container and stack didn't notice
- name: Install GHC with stack
run: |
stack --allow-different-user setup --install-ghc
- name: Build with stack
run: |
stack --allow-different-user build --split-objs --ghc-options='-optl-static -fPIC' hledger # || (echo "ERROR: building hledger failed"; false)
stack --allow-different-user build --split-objs --ghc-options='-optl-static -fPIC' hledger-ui # || (echo "ERROR: building hledger-ui failed"; false)
stack --allow-different-user build --split-objs --ghc-options='-optl-static -fPIC' hledger-web # || (echo "ERROR: building hledger-web failed"; false)
- name: Run built-in unit tests
run: |
stack exec -- hledger test
- name: Gather binaries
run: |
mkdir tmp
cd tmp
cp ~/.local/bin/hledger .
cp ~/.local/bin/hledger-ui .
cp ~/.local/bin/hledger-web .
strip hledger
strip hledger-ui
strip hledger-web
tar cvf hledger-mac-x64.tar hledger hledger-ui hledger-web
# upload-artifact loses execute permissions, so we tar the binaries to preserve them.
# github UI always zips artifacts when they are downloaded, so we don't bother compressing the tar.
# Unfortunately it means users must both unzip and untar.
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: hledger-linux-x64
path: tmp/hledger-linux-x64.tar