-
-
Notifications
You must be signed in to change notification settings - Fork 389
166 lines (145 loc) · 6.34 KB
/
hackage.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
name: Hackage
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
upload:
description: 'Whether packages should be uploaded'
required: true
default: 'false'
publish:
description: 'Wheter packages should be published as definitive'
required: true
default: 'false'
push:
branches:
- '*-hackage'
jobs:
check-and-upload-tarballs:
runs-on: ubuntu-latest
strategy:
fail-fast: ${{ github.event.inputs.upload != 'false' }}
matrix:
package: ["hie-compat", "hls-graph", "shake-bench",
"hls-plugin-api", "ghcide", "hls-test-utils",
"hls-brittany-plugin", "hls-floskell-plugin", "hls-fourmolu-plugin",
"hls-ormolu-plugin", "hls-stylish-haskell-plugin",
"hls-class-plugin", "hls-eval-plugin", "hls-explicit-imports-plugin",
"hls-haddock-comments-plugin", "hls-hlint-plugin",
"hls-module-name-plugin", "hls-pragmas-plugin",
"hls-refine-imports-plugin", "hls-rename-plugin", "hls-retrie-plugin",
"hls-splice-plugin", "hls-tactics-plugin",
"hls-call-hierarchy-plugin", "hls-alternate-number-format-plugin",
"hls-qualify-imported-names-plugin", "hls-code-range-plugin",
"haskell-language-server"]
ghc: [ "9.0.2"
, "8.10.7"
, "8.8.4"
, "8.6.5"
]
exclude:
- ghc: "9.0.2"
package: "hls-stylish-haskell-plugin"
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build
with:
ghc: ${{ matrix.ghc }}
os: ${{ runner.os }}
shorten-hls: 'false'
- name: "Run cabal check"
run: |
if [[ ${{ matrix.package }} == *plugin ]]; then
cd plugins
fi
if [[ ${{ matrix.package }} != haskell-language-server ]]; then
cd ${{ matrix.package }}
fi
cabal check
- name: "Generate package dist tarball"
id: generate-dist-tarball
run: |
if [[ ${{ matrix.package }} == haskell-language-server ]]; then
cabal sdist --builddir=./
else
cabal sdist ${{ matrix.package }} --builddir=./
fi
echo ::set-output name=path::$(ls ./sdist/${{ matrix.package }}-*)
- name: "Unpack package source in an isolated location"
run: cabal unpack ${{ steps.generate-dist-tarball.outputs.path }} --destdir=./incoming
- name: "Try to get the current hackage version"
id: get-hackage-version
run: |
cd ./incoming
if cabal get $(ls -d ${{ matrix.package }}-*) --destdir=../current; then
echo ::set-output name=exists::true
else
echo ::set-output name=exists::false
fi
- name: "Compare the incoming and the current hackage version of the package"
id: compare-current-version
if: steps.get-hackage-version.outputs.exists == 'true'
run: |
# This will throw an error if there is any difference cause we have to bump up the package version
diff -r -x "*.md" -x "data" $(ls -d ./incoming/${{ matrix.package }}-*) $(ls -d ./current/${{ matrix.package }}-*)
- name: "Create appropiate cabal.project"
if: steps.get-hackage-version.outputs.exists != 'true'
run: |
cd $(ls -d ./incoming/${{ matrix.package }}-*)
echo "packages: . ../../* ../../plugins/*" > cabal.project
# These tweaks are already in cabal-901.project but we dont want to use the entire file,
# Only the tricks needed by the solver which we know will not make the hackage build fail.
# The solver takes in account all project packages, even if they are not gonna be effectively built
# (like brittany or stylish-haskell for ghc-9.0)
- name: "Add temporary needed allow-newer for ghc-9.0"
if: steps.get-hackage-version.outputs.exists != 'true' && matrix.ghc == '9.0.2'
run: |
cd $(ls -d ./incoming/${{ matrix.package }}-*)
# For brittany
echo "allow-newer:" >> cabal.project
echo " butcher:base, multistate:base, data-tree-print:base," >> cabal.project
# For stylish-haskell
echo " stylish-haskell:Cabal,stylish-haskell:ghc-lib-parser,stylish-haskell:aeson" >> cabal.project
- name: "Build main package components in isolation"
if: steps.get-hackage-version.outputs.exists != 'true'
run: |
cd $(ls -d ./incoming/${{ matrix.package }}-*)
cabal build
- name: "Build package tests and benchmarks in isolation"
if: steps.get-hackage-version.outputs.exists != 'true'
run: |
cd $(ls -d ./incoming/${{ matrix.package }}-*)
cabal build --enable-tests --enable-benchmarks
- name: "Generate haddock for hackage"
if: steps.get-hackage-version.outputs.exists != 'true'
run: |
cd $(ls -d ./incoming/${{ matrix.package }}-*)
cabal haddock --haddock-for-hackage
- name: "Upload package dist tarball"
if: steps.get-hackage-version.outputs.exists != 'true' && matrix.ghc == '8.10.7'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.package }}
path: ${{ steps.generate-dist-tarball.outputs.path }}
upload-package:
# Runs triggered by *-hackage branches will upload packages
# cause inputs are blank when the workflow is not triggered manually
if: github.event.inputs.upload != 'false'
needs: check-and-upload-tarballs
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
path: packages
- name: "Join all tarballs"
run: find ./packages -type f -name '*.tar.gz' -exec cp {} ./packages \;
- name: "Upload all tarballs to hackage"
uses: haskell-actions/hackage-publish@v1
with:
hackageToken: ${{ secrets.HACKAGE_AUTH_TOKEN }}
packagesPath: packages
# runs triggered by *-hackage branches will not publish packages definitely
publish: ${{ github.event.inputs.publish == 'true' }}