forked from agda/agda
-
Notifications
You must be signed in to change notification settings - Fork 0
268 lines (248 loc) · 10.9 KB
/
deploy.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
######################################################
## ##
## !!!! Autogenerated YAML file, do not edit !!!! ##
## ##
## Edit source in /src/github/workflows/ instead! ##
## ##
######################################################
defaults:
run:
shell: bash
jobs:
auto-cancel:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion
== 'success' }}
runs-on: Ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build:
env:
ARGS: --disable-executable-profiling --disable-library-profiling
LINUX_ARGS: --enable-executable-static --enable-split-sections
MACOS_ARGS: --flags=enable-cluster-counting
WIN64_ARGS: --flags=enable-cluster-counting --enable-split-sections
if: ${{ !cancelled() }}
needs: auto-cancel
outputs:
sha: ${{ steps.vars.outputs.sha }}
runs-on: ${{ matrix.os }}
steps:
- name: Check out the master branch
uses: actions/checkout@v4
- id: vars
name: Set up platform-dependent variables
run: |
sha="$(git rev-parse --short=7 HEAD)"
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
suffix=${GITHUB_REF_NAME}
else
suffix=nightly-${sha}
fi
bindist=Agda-${suffix}
echo sha="${sha}" >> "${GITHUB_OUTPUT}"
echo bindist="${bindist}" >> "${GITHUB_OUTPUT}"
if [[ "$OSTYPE" == "msys"* ]]; then
filename="${bindist}-win64.zip"
echo args="${ARGS} ${WIN64_ARGS}" >> "${GITHUB_OUTPUT}"
echo compress-cmd="7z a ${filename} ${bindist} -bb -mx=9" >> "${GITHUB_OUTPUT}"
echo content-type="application/zip" >> "${GITHUB_OUTPUT}"
echo exe="agda.exe" >> "${GITHUB_OUTPUT}"
echo filename="${filename}" >> "${GITHUB_OUTPUT}"
elif [[ "$OSTYPE" == "darwin"* ]]; then
filename="${bindist}-macOS.tar.xz"
echo args="${ARGS} ${MACOS_ARGS}" >> "${GITHUB_OUTPUT}"
echo compress-cmd="tar -a -cvf ${filename} ${bindist}" >> "${GITHUB_OUTPUT}"
echo content-type="application/x-xz" >> "${GITHUB_OUTPUT}"
echo exe="agda" >> "${GITHUB_OUTPUT}"
echo filename="${filename}" >> "${GITHUB_OUTPUT}"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
filename="${bindist}-linux.tar.xz"
echo args="${ARGS} ${LINUX_ARGS}" >> "${GITHUB_OUTPUT}"
echo compress-cmd="tar -a -cvf ${filename} ${bindist}" >> "${GITHUB_OUTPUT}"
echo content-type="application/x-xz" >> "${GITHUB_OUTPUT}"
echo exe="agda" >> "${GITHUB_OUTPUT}"
echo filename="${filename}" >> "${GITHUB_OUTPUT}"
fi
- name: Display build variables
run: |
echo "GITHUB_REF = ${GITHUB_REF}"
echo "GITHUB_REF_NAME = ${GITHUB_REF_NAME}"
echo "args = ${{ steps.vars.outputs.args }}"
echo "compress-cmd = ${{ steps.vars.outputs.compress-cmd }}"
echo "content-type = ${{ steps.vars.outputs.content-type }}"
echo "filename = ${{ steps.vars.outputs.filename }}"
echo "bindist = ${{ steps.vars.outputs.bindist }}"
- if: ${{ runner.os == 'Linux' }}
name: Set up Alpine Linux with GHC and the static library for ICU
uses: jirutka/setup-alpine@v1
with:
packages: |
cabal g++ gcc icu-static ncurses-dev ncurses-static musl-dev zlib-static zlib-dev
- id: setup-haskell
if: ${{ runner.os != 'Linux' }}
uses: haskell-actions/setup@v2
with:
cabal-version: ${{ matrix.cabal-ver }}
ghc-version: ${{ matrix.ghc-ver }}
- name: Environment settings based on the Haskell setup
run: |
GHC_VER=$(ghc --numeric-version)
CABAL_VER=$(cabal --numeric-version)
echo "GHC_VER = ${GHC_VER}"
echo "CABAL_VER = ${CABAL_VER}"
echo "GHC_VER=${GHC_VER}" >> "${GITHUB_ENV}"
echo "CABAL_VER=${CABAL_VER}" >> "${GITHUB_ENV}"
- if: ${{ runner.os == 'Windows' }}
name: Install the required packages (Windows)
run: |
$env:PATH = "C:\msys64\usr\bin;$env:PATH"
pacman -v --noconfirm -S mingw-w64-x86_64-pkgconf mingw-w64-x86_64-icu mingw-w64-x86_64-binutils
echo "C:\msys64\mingw64\bin" | Out-File -FilePath "$env:GITHUB_PATH" -Append
shell: pwsh
- if: ${{ runner.os == 'macOS' }}
name: Set up for the ICU library (macOS)
run: |
ICU4C=$(brew --prefix)/opt/icu4c
# echo "${ICU4C}/bin" >> "${GITHUB_PATH}" ## Only needed for uconv
ICU_DIR=${ICU4C}/lib
echo "ICU_DIR=${ICU_DIR}"
echo "ICU_DIR=${ICU_DIR}" >> "${GITHUB_ENV}"
echo "PKG_CONFIG_PATH=${ICU_DIR}/pkgconfig" >> "${GITHUB_ENV}"
- name: Determine the ICU version
run: |
ICU_VER=$(pkg-config --modversion icu-i18n)
echo "ICU_VER=${ICU_VER}"
echo "ICU_VER=${ICU_VER}" >> "${GITHUB_ENV}"
ICU_MAJOR_VER=$(cut -d '.' -f 1 <<< "${ICU_VER}")
echo "ICU_MAJOR_VER=${ICU_MAJOR_VER}"
echo "ICU_MAJOR_VER=${ICU_MAJOR_VER}" >> "${GITHUB_ENV}"
- if: ${{ runner.os != 'Linux' }}
name: Configure the build plan
run: |
cabal configure ${{ steps.vars.outputs.args }}
cabal build --dry-run
- id: cache
if: ${{ runner.os != 'Linux' }}
name: Cache dependencies
uses: actions/cache@v4
with:
key: deploy.yml-${{ runner.os }}-ghc-${{ env.GHC_VER }}-cabal-${{ env.CABAL_VER
}}-${{ hashFiles('**/plan.json') }}
path: ${{ steps.setup-haskell.outputs.cabal-store }}
restore-keys: deploy.yml-${{ runner.os }}-ghc-${{ env.GHC_VER }}-cabal-${{
env.CABAL_VER }}-
- if: ${{ runner.os == 'Linux' }}
name: Build dependencies (on Alpine Linux)
run: |
cabal update # Liang-Ting, 2024-01-26: Alpine Linux has its own GHC toolchain
cabal configure ${{ steps.vars.outputs.args }}
cabal build exe:agda exe:agda-mode --only-dependencies
shell: alpine.sh {0}
- if: ${{ steps.cache.outputs.cache-hit != 'true' && runner.os != 'Linux' }}
name: Build dependencies
run: cabal build exe:agda exe:agda-mode --only-dependencies
- if: ${{ runner.os == 'Linux' }}
name: Build Agda (on Alpine Linux)
run: cabal build exe:agda exe:agda-mode
shell: alpine.sh {0}
- if: ${{ runner.os != 'Linux' }}
name: Build Agda
run: cabal build exe:agda exe:agda-mode
- name: Move artefacts to ${{ steps.vars.outputs.bindist }}
run: |
bindist="${{ steps.vars.outputs.bindist }}"
mkdir -p "${bindist}"/bin
cp -a src/data "${bindist}"
if [[ "$OSTYPE" == "msys"* ]]; then
find dist-newstyle/build \( -name 'agda.exe' -o -name 'agda-mode.exe' \) -type f -exec cp {} "${bindist}"/bin \;
cp -a .github/*.bat "${bindist}"
cp /c/msys64/mingw64/bin/libicu*.dll "${bindist}"/bin/
strip "${bindist}"/bin/*
else
find dist-newstyle/build \( -name 'agda' -o -name 'agda-mode' \) -type f -exec cp {} "${bindist}"/bin \;
strip "${bindist}"/bin/*
cp -a .github/*.sh "${bindist}"
if [[ "$OSTYPE" == "darwin"* ]]; then
# Change the path to the dynamic library icu4c to the run-time search path:
#
# 1. the same directory of executable, i.e. @executable_path
# 2. @executable_path/../lib
# 3. the default location of system-wide icu4c installed by homebrew, ie. /usr/local/opt/icu4c/lib
#
mkdir "${bindist}"/lib
cp "${ICU_DIR}/libicuuc.${ICU_MAJOR_VER}.dylib" "${ICU_DIR}/libicui18n.${ICU_MAJOR_VER}.dylib" "${ICU_DIR}/libicudata.${ICU_MAJOR_VER}.dylib" "${bindist}"/lib
install_name_tool -change "${ICU_DIR}/libicuuc.${ICU_MAJOR_VER}.dylib" "@rpath/libicuuc.${ICU_MAJOR_VER}.dylib" "${bindist}"/bin/agda
install_name_tool -change "${ICU_DIR}/libicui18n.${ICU_MAJOR_VER}.dylib" "@rpath/libicui18n.${ICU_MAJOR_VER}.dylib" "${bindist}"/bin/agda
install_name_tool -add_rpath @executable_path -add_rpath @executable_path/../lib -add_rpath "${ICU_DIR}" "${bindist}"/bin/agda
otool -L "${bindist}"/bin/agda
fi
fi
file "${{ steps.vars.outputs.bindist }}/bin/agda"
- name: Display the version information
run: |
${{ steps.vars.outputs.bindist }}/bin/agda --version
- name: Pack artefacts
run: |
${{ steps.vars.outputs.compress-cmd }}
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ steps.vars.outputs.filename }}
path: ${{ steps.vars.outputs.filename }}
retention-days: 3
strategy:
fail-fast: false
matrix:
cabal-ver:
- latest
ghc-ver:
- '9.8'
os:
- windows-latest
- macos-latest
- ubuntu-latest
deploy:
if: ${{ !cancelled() }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .
- uses: actions/download-artifact@v4
with:
path: artifacts
- env:
GITHUB_TOKEN: ${{ github.token }}
if: ${{ github.ref == 'refs/heads/master' }}
name: Create/replace the nightly release and upload artifacts as release assets
run: |
gh release delete 'nightly' --repo ${GITHUB_REPOSITORY} --cleanup-tag --yes || true
ls -R artifacts
gh release create 'nightly' artifacts/**/* --repo ${GITHUB_REPOSITORY} --generate-notes --notes-start-tag v2.6.4.3 --prerelease --title "${{ needs.build.outputs.sha }}@master"
- env:
GITHUB_TOKEN: ${{ github.token }}
if: startsWith(github.ref, 'refs/tags/v')
name: Create a release with the bindist as release assets
run: |
echo "GITHUB_REF_NAME=${GITHUB_REF_NAME}"
echo "GITHUB_REPOSITORY=${GITHUB_REPOSITORY}"
gh release delete "${GITHUB_REF_NAME}" --repo ${GITHUB_REPOSITORY} --yes || true
gh release create "${GITHUB_REF_NAME}" -d --notes-file CHANGELOG.md --title "${GITHUB_REF_NAME}"
ls -R artifacts
gh release upload "${GITHUB_REF_NAME}" artifacts/**/* --repo ${GITHUB_REPOSITORY}
name: Deploy
'on':
push:
tags:
- v[2-9]+.*
workflow_dispatch: null
workflow_run:
branches:
- master
types:
- completed
workflows:
- Build, Test, and Benchmark