-
Notifications
You must be signed in to change notification settings - Fork 76
269 lines (263 loc) · 9.93 KB
/
haskell.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
269
name: Haskell CI
on: [push]
env:
PANDOC_VERSION: "3.1.6.1"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
ghcver: ['9.4.5']
include:
- os: windows-latest
ghcver: '9.0.2'
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v2
with:
ghc-version: ${{matrix.ghcver}}
- name: Cabal init
shell: pwsh
run: |
$store = Join-Path $pwd ".cabal-store"
New-Item -ItemType Directory -Force "$store"
cabal user-config init --force --augment="store-dir: $store" `
--augment="install-method: copy"
- name: Cabal update
run: cabal v2-update
- name: Copy build config
shell: bash
run: cp misc/${{runner.os}}-build-cabal-config ./cabal.project
- name: Cabal configure
run: cabal v2-configure --constraint pandoc==${{ env.PANDOC_VERSION }} --constraint zip-archive'>='0.4.2.1 --enable-tests ${{matrix.extra-options}}
- uses: actions/cache@v2
with:
path: .cabal-store
key: r2-${{runner.os}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}}
restore-keys: |
r2-${{runner.os}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}}
r2-${{runner.os}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}-${{hashFiles('pandoc-crossref.cabal')}}
r2-${{runner.os}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}
- shell: bash
run: |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-* || true
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossr_-* || true
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pndc-crssrf-* || true
ls .cabal-store/ghc-${{matrix.ghcver}}/ || true
- name: Install dependencies
run: cabal v2-build --only-dependencies
- name: Build
run: cabal v2-build
- name: Run tests
run: cabal v2-test
- name: Install
shell: bash
run: |
mkdir pandoc-crossref-${{runner.os}}
export GIT_DIR="$PWD/.git"
cabal v2-install --installdir=$PWD/pandoc-crossref-${{runner.os}}
- name: Get Version
shell: bash
id: get_version
run: |
cd pandoc-crossref-${{runner.os}}/
case "${{runner.os}}" in
Windows)
VERSION="$(./pandoc-crossref.exe --version)"
;;
*) chmod +x pandoc-crossref
VERSION="$(./pandoc-crossref --version)"
;;
esac
echo "$VERSION"
echo "$VERSION" > version.txt
- uses: actions/upload-artifact@v2
with:
name: ${{runner.os}}-build
path: pandoc-crossref-${{runner.os}}
- shell: bash
run: |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-*
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossr_-*
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pndc-crssrf-*
build-nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
substituters = https://cache.nixos.org https://cache.iog.io
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
- uses: cachix/cachix-action@v12
with:
name: pandoc-crossref
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: nix build .#static
- run: |
cp -r result/bin/ pandoc-crossref-${{runner.os}}
chmod +w -R pandoc-crossref-${{runner.os}}
- name: Check pandoc version for static binary
run: |
./pandoc-crossref-${{runner.os}}/pandoc-crossref --version | grep -q 'Pandoc v${{ env.PANDOC_VERSION }}'
- run: nix run .#test
- run: nix run .#test-integrative
- run: nix develop -c echo ok
- name: Check pandoc version in shell
run: |
[ "$(nix develop -c pandoc --version | head -n1)" == "pandoc ${{ env.PANDOC_VERSION }}" ]
- name: Make manpage
run: |
nix develop -c pandoc -s -t man docs/index.md -o pandoc-crossref-${{runner.os}}/pandoc-crossref.1
- name: Get Version
shell: bash
id: get_version
run: |
cd pandoc-crossref-${{runner.os}}/
chmod +x pandoc-crossref
VERSION="$(./pandoc-crossref --version)"
echo "$VERSION"
echo "$VERSION" > version.txt
- uses: actions/upload-artifact@v2
with:
name: ${{runner.os}}-build-static
path: pandoc-crossref-${{runner.os}}
release:
needs: [build, build-nix]
runs-on: ubuntu-latest
container: alpine:3.15.0
steps:
- run: |
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
apk add --update --no-cache p7zip hub upx bash tar xz
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- name: Repack assets
run: |
mkdir assets
chmod +x Linux-build-static/pandoc-crossref
upx Linux-build-static/pandoc-crossref
chmod +x macOS-build/pandoc-crossref
echo not doing upx macOS-build/pandoc-crossref
tar cJf assets/pandoc-crossref-Linux-${{github.sha}}.tar.xz -C Linux-build-static pandoc-crossref pandoc-crossref.1
tar cJf assets/pandoc-crossref-macOS-${{github.sha}}.tar.xz -C macOS-build pandoc-crossref
cd Windows-build
upx pandoc-crossref.exe
7z a ../assets/pandoc-crossref-Windows-${{github.sha}}.7z pandoc-crossref.exe
- uses: actions/upload-artifact@v2
with:
name: release-assets
path: assets
- name: Generate description.md
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
echo -n "" > description.md
for i in *-build; do
os="${i%-build}"
desc="$(cat $i/version.txt)"
echo "${os}: ${desc}" >> description.md
done
ver="${GITHUB_REF##*/v}"
echo "### Changelog" >> description.md
sed -rn '/^## *'"${ver//./\\.}"'/,/^##[^#]/ p' CHANGELOG.md | head -n-1 | tail -n+2 >> description.md
echo "description.md"
cat description.md
- name: Rename assets for release
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
for i in assets/*; do
mv "$i" "${i/-${{github.sha}}/}"
done
- name: Create release
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
body_path: description.md
files: |
assets/*
fail_on_unmatched_files: true
- name: Extract branch name
if: "!startsWith(github.ref, 'refs/tags/v')"
shell: bash
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
id: extract_branch
- name: Generate description outputs
if: "!startsWith(github.ref, 'refs/tags/v')"
shell: bash
run: |
for i in *-build; do
os="${i%-build}"
desc="$(cat $i/version.txt)"
echo ::set-output name=${os}::${desc}
done
id: description
- name: Upload "nightly" for Linux
if: "!startsWith(github.ref, 'refs/tags/v')"
uses: WebFreak001/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label}
release_id: 44009421
asset_path: ./assets/pandoc-crossref-Linux-${{github.sha}}.tar.xz
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-Linux-$$.tar.xz
asset_content_type: application/x-gtar
max_releases: 21
- name: Upload "nightly" for macOS
if: "!startsWith(github.ref, 'refs/tags/v')"
uses: WebFreak001/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label}
release_id: 44009421
asset_path: ./assets/pandoc-crossref-macOS-${{github.sha}}.tar.xz
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-macOS-$$.tar.xz
asset_content_type: application/x-gtar
max_releases: 21
- name: Upload "nightly" for Windows
if: "!startsWith(github.ref, 'refs/tags/v')"
uses: WebFreak001/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label}
release_id: 44009421
asset_path: ./assets/pandoc-crossref-Windows-${{github.sha}}.7z
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-Windows-$$.7z
asset_content_type: application/x-7z-compressed
max_releases: 21
# TODO: where to put this?
# versionDescription: |
# Linux: ${{steps.description.outputs.Linux}}
# macOS: ${{steps.description.outputs.macOS}}
# Windows: ${{steps.description.outputs.Windows}}
build-stack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
wget https://get.haskellstack.org/stable/linux-x86_64.tar.gz
tar zxf linux-x86_64.tar.gz
mv stack-*/stack ./
chmod +x ./stack
- uses: actions/cache@v1
with:
path: /home/runner/.stack
key: ${{ runner.os }}-stack
- name: Build and test
run: ./stack build --test
- name: Verify version
shell: bash
run: |
stack exec -- pandoc-crossref --version | grep -q 'Pandoc v${{ env.PANDOC_VERSION }}'