@@ -13,38 +13,78 @@ defaults:
13
13
shell : " bash"
14
14
15
15
env :
16
+ CI_PRERELEASE : " ${{ github.event_name == 'push' }}"
16
17
CI_RELEASE : " ${{ github.event_name == 'release' }}"
18
+ STACK_VERSION : " 2.7.3"
19
+
20
+ concurrency :
21
+ # We never want two prereleases building at the same time, since they would
22
+ # likely both claim the same version number. Pull request builds can happen
23
+ # in parallel with anything else, since they don't mutate global state with a
24
+ # release. Release builds don't change their behavior based on published
25
+ # state, so they don't interfere with each other and there's no point in
26
+ # canceling a prerelease build if a release build starts; and we would never
27
+ # want a release build to be canceled by a prerelease build either. (GitHub
28
+ # Actions is either too cheap to give us `if` expressions or too lazy to
29
+ # document them, but we have untyped boolean operators to fall back on.)
30
+ group : " ${{ github.event_name != 'push' && github.run_id || 'continuous-deployment' }}"
31
+ cancel-in-progress : true
17
32
18
33
jobs :
19
34
build :
20
35
strategy :
21
36
fail-fast : false # do not cancel builds for other OSes if one fails
22
37
matrix :
23
- # If upgrading Ubuntu, also upgrade it in the lint job below
24
- os : [ "ubuntu-18.04", "macOS-10.15", "windows-2016" ]
38
+ include :
39
+ - # If upgrading the Haskell image, also upgrade it in the lint job below
40
+ os : " ubuntu-latest"
41
+ image : " haskell:8.10.7-stretch@sha256:100f8fb7d7d8d64adb5e106fe8136b8d4cbdc03aeb2cbd145a7597d74b69bafb"
42
+ - os : " macOS-10.15"
43
+ - os : " windows-2019"
25
44
26
45
runs-on : " ${{ matrix.os }}"
46
+ container : " ${{ matrix.image }}"
47
+
48
+ outputs :
49
+ do-not-prerelease : " ${{ steps.build.outputs.do-not-prerelease }}"
50
+ version : " ${{ steps.build.outputs.version }}"
27
51
28
52
steps :
53
+ - # We need a proper Git repository, but the checkout step will unpack a tarball instead of doing a clone
54
+ # if the Git version is less than 2.18.
55
+ name : " (Linux only) Install a newer version of Git"
56
+ if : " ${{ runner.os == 'Linux' }}"
57
+ run : |
58
+ . /etc/os-release
59
+ echo deb http://deb.debian.org/debian "$VERSION_CODENAME"-backports main >> /etc/apt/sources.list
60
+ apt-get update && apt-get install -y git/"$VERSION_CODENAME"-backports
29
61
- uses : " actions/checkout@v2"
30
62
31
- - uses : " actions/setup-node@v1 "
63
+ - uses : " actions/setup-node@v2 "
32
64
with :
33
- node-version : " 10 "
65
+ node-version : " 14 "
34
66
35
67
- id : " haskell"
68
+ name : " (Non-Linux only) Install Haskell"
69
+ if : " ${{ runner.os != 'Linux' }}"
36
70
uses : " haskell/actions/setup@v1"
37
71
with :
38
72
enable-stack : true
39
- # If upgrading Stack, also upgrade it in the lint job below
40
- stack-version : " 2.7.1"
73
+ stack-version : " ${{ env.STACK_VERSION }}"
41
74
stack-no-global : true
42
75
76
+ - name : " (Linux only) Check Stack version and fix working directory ownership"
77
+ if : " ${{ runner.os == 'Linux' }}"
78
+ run : |
79
+ [ "$(stack --numeric-version)" = "$STACK_VERSION" ]
80
+ chown root:root .
81
+
43
82
- uses : " actions/cache@v2"
44
83
with :
45
84
path : |
85
+ /root/.stack
46
86
${{ steps.haskell.outputs.stack-root }}
47
- key : " ${{ runner.os }}-${{ hashFiles('stack.yaml') }}"
87
+ key : " ${{ runner.os }}-MdyPsf- ${{ hashFiles('stack.yaml') }}"
48
88
49
89
- name : " (Windows only) Configure Stack to store its programs in STACK_ROOT"
50
90
# This ensures that the local GHC and MSYS binaries that Stack installs
@@ -55,10 +95,38 @@ jobs:
55
95
mkdir -p "$STACK_ROOT"
56
96
echo "local-programs-path: $STACK_ROOT/programs" > $STACK_ROOT/config.yaml
57
97
58
- - run : " ci/build.sh"
98
+ - id : " build"
99
+ run : " ci/fix-home ci/build.sh"
100
+
101
+ - name : " (Linux only) Build the entire package set"
102
+ if : " ${{ runner.os == 'Linux' }}"
103
+ # We build in this directory in build.sh, so this is where we need to
104
+ # launch `stack exec`. The actual package-set building happens in a
105
+ # temporary directory.
106
+ working-directory : " sdist-test"
107
+ # The presence or absence of the --haddock flag changes the location
108
+ # into which stack places all build artifacts. Since we use --haddock
109
+ # in our CI builds, in order to actually get stack to find the purs
110
+ # binary it created, we need to use the flag here as well.
111
+ #
112
+ # Moreover, npm has a hook issue that will cause spago to fail to install
113
+ # We upgrade npm to fix this
114
+ run : |
115
+ npm i -g npm@8.8.0
116
+ ../ci/fix-home stack --haddock exec ../ci/build-package-set.sh
59
117
60
- - name : " (Release only) Create bundle"
61
- if : " ${{ env.CI_RELEASE == 'true' }}"
118
+ - name : Verify that 'libtinfo' isn't in binary
119
+ if : runner.os == 'Linux'
120
+ working-directory : " sdist-test"
121
+ run : |
122
+ if [ $(ldd $(stack path --local-doc-root)/../bin/purs | grep 'libtinfo' | wc -l) -ge 1 ]; then
123
+ echo "libtinfo detected"
124
+ ldd $(stack path --local-doc-root)/../bin/purs | grep 'libtinfo'
125
+ exit 1
126
+ fi
127
+
128
+ - name : " (Release/prerelease only) Create bundle"
129
+ if : " ${{ env.CI_RELEASE == 'true' || env.CI_PRERELEASE == 'true' && steps.build.outputs.do-not-prerelease != 'true' }}"
62
130
run : |
63
131
os_name="${{ runner.os }}"
64
132
case "$os_name" in
@@ -73,7 +141,16 @@ jobs:
73
141
exit 1;;
74
142
esac
75
143
cd sdist-test
76
- bundle/build.sh "$bundle_os"
144
+ ../ci/fix-home bundle/build.sh "$bundle_os"
145
+
146
+ - name : " (Prerelease only) Upload bundle"
147
+ if : " ${{ env.CI_PRERELEASE == 'true' && steps.build.outputs.do-not-prerelease != 'true' }}"
148
+ uses : " actions/upload-artifact@v3"
149
+ with :
150
+ name : " ${{ runner.os }}-bundle"
151
+ path : |
152
+ sdist-test/bundle/*.sha
153
+ sdist-test/bundle/*.tar.gz
77
154
78
155
- name : " (Release only) Publish bundle"
79
156
if : " ${{ env.CI_RELEASE == 'true' }}"
@@ -88,25 +165,30 @@ jobs:
88
165
files : " sdist-test/bundle/*.{tar.gz,sha}"
89
166
90
167
lint :
91
- runs-on : " ubuntu-18.04"
168
+ runs-on : " ubuntu-latest"
169
+ container : " haskell:8.10.7-stretch@sha256:100f8fb7d7d8d64adb5e106fe8136b8d4cbdc03aeb2cbd145a7597d74b69bafb"
92
170
93
171
steps :
172
+ - # We need a proper Git repository, but the checkout step will unpack a tarball instead of doing a clone
173
+ # if the Git version is less than 2.18.
174
+ name : " Install a newer version of Git"
175
+ run : |
176
+ . /etc/os-release
177
+ echo deb http://deb.debian.org/debian "$VERSION_CODENAME"-backports main >> /etc/apt/sources.list
178
+ apt-get update && apt-get install -y git/"$VERSION_CODENAME"-backports
94
179
- uses : " actions/checkout@v2"
95
180
96
- - id : " haskell"
97
- uses : " haskell/actions/setup@v1"
98
- with :
99
- enable-stack : true
100
- stack-version : " 2.7.1"
101
- stack-no-global : true
181
+ - name : " Fix working directory ownership"
182
+ run : |
183
+ chown root:root .
102
184
103
185
- uses : " actions/cache@v2"
104
186
with :
105
187
path : |
106
- ${{ steps.haskell.outputs. stack-root }}
107
- key : " ${{ runner.os }}-lint-${{ hashFiles('stack.yaml') }}"
188
+ /root/. stack
189
+ key : " ${{ runner.os }}-UnWw0N- lint-${{ hashFiles('stack.yaml') }}"
108
190
109
- - run : " ci/run-hlint.sh --git"
191
+ - run : " ci/fix-home ci/ run-hlint.sh --git"
110
192
env :
111
193
VERSION : " 2.2.11"
112
194
@@ -127,16 +209,46 @@ jobs:
127
209
# `allow-newer: true` is needed so that weeder-2.2.0 can be
128
210
# installed with the dependencies present in LTS-18.
129
211
echo 'allow-newer: true' >> stack-weeder.yaml
130
- stack --no-terminal --jobs=2 build --copy-compiler-tool --stack-yaml ./stack-weeder.yaml weeder-2.2.0
212
+ ci/fix-home stack --no-terminal --jobs=2 build --copy-compiler-tool --stack-yaml ./stack-weeder.yaml weeder-2.2.0
131
213
132
- - run : " stack --no-terminal --jobs=2 build --fast --ghc-options -fwrite-ide-info"
214
+ - run : " ci/fix-home stack --no-terminal --jobs=2 build --fast --ghc-options -fwrite-ide-info"
133
215
134
- - run : " stack exec weeder"
216
+ - run : " ci/fix-home stack exec weeder"
135
217
136
218
# Now do it again, with the test suite included. We don't want a
137
219
# reference from our test suite to count in the above check; the fact
138
220
# that a function is tested is not evidence that it's needed. But we also
139
221
# don't want to leave weeds lying around in our test suite either.
140
- - run : " stack --no-terminal --jobs=2 build --fast --test --no-run-tests --ghc-options -fwrite-ide-info"
222
+ - run : " ci/fix-home stack --no-terminal --jobs=2 build --fast --test --no-run-tests --ghc-options -fwrite-ide-info"
141
223
142
- - run : " stack exec weeder"
224
+ - run : " ci/fix-home stack exec weeder"
225
+
226
+ make-prerelease :
227
+ runs-on : " ubuntu-latest"
228
+ needs :
229
+ - " build"
230
+ - " lint"
231
+ if : " ${{ github.event_name == 'push' && needs.build.outputs.do-not-prerelease != 'true' }}"
232
+ steps :
233
+ - uses : " actions/download-artifact@v3"
234
+ - uses : " ncipollo/release-action@v1.10.0"
235
+ with :
236
+ tag : " v${{ needs.build.outputs.version }}"
237
+ artifacts : " *-bundle/*"
238
+ prerelease : true
239
+ body : " This is an automated preview release. Get the latest stable release [here](https://github.com/purescript/purescript/releases/latest)."
240
+ - uses : " actions/checkout@v3"
241
+ - uses : " actions/setup-node@v3"
242
+ with :
243
+ node-version : " 16.x"
244
+ registry-url : " https://registry.npmjs.org"
245
+ - name : " Publish npm package"
246
+ working-directory : " npm-package"
247
+ env :
248
+ BUILD_VERSION : " ${{ needs.build.outputs.version }}"
249
+ NODE_AUTH_TOKEN : " ${{ secrets.NPM_TOKEN }}"
250
+ run : |
251
+ src_version=$(node -pe 'require("./package.json").version')
252
+ npm version --allow-same-version "$BUILD_VERSION"
253
+ sed -i -e "s/--purs-ver=${src_version//./\\.}/--purs-ver=$BUILD_VERSION/" package.json
254
+ npm publish --tag next
0 commit comments