-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (129 loc) · 4.69 KB
/
build-windows-x86_64.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
on:
push:
branches:
- distribute
- windows
name: Build Windows x86_64
jobs:
build-packages:
name: Build Windows Libraries
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
submodules: true
# First, check if the specific cache exists, so we don't waste ~3m of build
# time restoring the 1.5GB cache for no reason.
- uses: actions/cache@v3
id: cache
with:
lookup-only: true
path: |
~\AppData\Local\Programs\stack
.stack-work
C:\sr
key: ${{ runner.os }}-${{ hashFiles('stack.yaml.lock') }}
# If it doesn't exist, setup our cache action, while also trying to restore
# a prior broader matching cache if it exists (saves a lot of time if just
# modifying a few packages).
- uses: actions/cache@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
~\AppData\Local\Programs\stack
.stack-work
C:\sr
key: ${{ runner.os }}-${{ hashFiles('stack.yaml.lock') }}
restore-keys: |
${{ runner.os }}-
# Now setup Haskell, given we're comitted to actually doing a lib build
- uses: haskell-actions/setup@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
enable-stack: true
stack-no-global: true
stack-version: 'latest'
# Install just our dependencies, this can take ~30m from scratch and is the
# most part valuable to cache.
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: stack build --only-dependencies --ghc-options '-optl"-Wl,-Bstatic,-lstdc++,-lgcc_s,-lwinpthread,-Bdynamic"'
# The install step is split to a separate job, so that if the we were building
# from scratch and just spent 30 minutes building all the libraries, but then
# the actual compile failed, we wouldn't throw away all that hard work without
# caching it first. On a clean compile this means we'll save+restore the cache
# unecessarily once (+~3m), but over all subsequent runs with a cache hit the
# whole lib step will be skipped almost immediately so its worth it.
install:
name: Build Windows Executable
runs-on: windows-latest
needs: build-packages
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-no-global: true
stack-version: 'latest'
- uses: actions/cache@v3
with:
path: |
~\AppData\Local\Programs\stack
.stack-work
C:\sr
key: ${{ runner.os }}-${{ hashFiles('stack.yaml.lock') }}
restore-keys: |
${{ runner.os }}-
# Use a retry action because inexplicably sometimes stack install stalls
# indefinitely after the `compiling Main` step, but then succeeds immediately
# with a second stack install. 🤷🏻♂️
- uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 4
shell: bash # otherwise defaults to powershell on windows
# https://gitlab.haskell.org/ghc/ghc/-/issues/20878
# https://gitlab.haskell.org/ghc/ghc/-/issues/20010#note_359766
command: stack install --ghc-options '-optl"-Wl,-Bstatic,-lstdc++,-lgcc_s,-lwinpthread,-Bdynamic"'
- name: Copy binary files, dlls & check
run: |
mkdir lamdera
cp ~/AppData/Roaming/local/bin/lamdera.exe lamdera/lamdera.exe
cp distribution/dlls/* lamdera/
./lamdera/lamdera.exe --version-full
- name: Create distribution zip
uses: vimtor/action-zip@v1
with:
files: lamdera/
recursive: false
dest: lamdera.zip
- name: Archive lamdera.zip artifact
uses: actions/upload-artifact@v3
with:
name: lamdera-next.zip
path: lamdera.zip
upload:
needs: install
name: Upload lamdera-next.zip to SFTP
runs-on: lamdera-community-linux-x86_64
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: lamdera-next.zip
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.GH_USER_SCP_KEY }}
name: id_ed25519
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- run: |
pwd
ls -alh
echo "put lamdera.zip next/lamdera-next-windows-x86_64.zip" | sftp -i ~/.ssh/id_ed25519 -P 22 [email protected]