@@ -13,38 +13,78 @@ defaults:
1313 shell : " bash"
1414
1515env :
16+ CI_PRERELEASE : " ${{ github.event_name == 'push' }}"
1617 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
1732
1833jobs :
1934 build :
2035 strategy :
2136 fail-fast : false # do not cancel builds for other OSes if one fails
2237 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"
2544
2645 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 }}"
2751
2852 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
2961 - uses : " actions/checkout@v2"
3062
31- - uses : " actions/setup-node@v1 "
63+ - uses : " actions/setup-node@v2 "
3264 with :
33- node-version : " 10 "
65+ node-version : " 14 "
3466
3567 - id : " haskell"
68+ name : " (Non-Linux only) Install Haskell"
69+ if : " ${{ runner.os != 'Linux' }}"
3670 uses : " haskell/actions/setup@v1"
3771 with :
3872 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 }}"
4174 stack-no-global : true
4275
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+
4382 - uses : " actions/cache@v2"
4483 with :
4584 path : |
85+ /root/.stack
4686 ${{ steps.haskell.outputs.stack-root }}
47- key : " ${{ runner.os }}-${{ hashFiles('stack.yaml') }}"
87+ key : " ${{ runner.os }}-MdyPsf- ${{ hashFiles('stack.yaml') }}"
4888
4989 - name : " (Windows only) Configure Stack to store its programs in STACK_ROOT"
5090 # This ensures that the local GHC and MSYS binaries that Stack installs
@@ -55,10 +95,38 @@ jobs:
5595 mkdir -p "$STACK_ROOT"
5696 echo "local-programs-path: $STACK_ROOT/programs" > $STACK_ROOT/config.yaml
5797
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
59117
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' }}"
62130 run : |
63131 os_name="${{ runner.os }}"
64132 case "$os_name" in
@@ -73,7 +141,16 @@ jobs:
73141 exit 1;;
74142 esac
75143 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
77154
78155 - name : " (Release only) Publish bundle"
79156 if : " ${{ env.CI_RELEASE == 'true' }}"
@@ -88,25 +165,30 @@ jobs:
88165 files : " sdist-test/bundle/*.{tar.gz,sha}"
89166
90167 lint :
91- runs-on : " ubuntu-18.04"
168+ runs-on : " ubuntu-latest"
169+ container : " haskell:8.10.7-stretch@sha256:100f8fb7d7d8d64adb5e106fe8136b8d4cbdc03aeb2cbd145a7597d74b69bafb"
92170
93171 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
94179 - uses : " actions/checkout@v2"
95180
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 .
102184
103185 - uses : " actions/cache@v2"
104186 with :
105187 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') }}"
108190
109- - run : " ci/run-hlint.sh --git"
191+ - run : " ci/fix-home ci/ run-hlint.sh --git"
110192 env :
111193 VERSION : " 2.2.11"
112194
@@ -127,16 +209,46 @@ jobs:
127209 # `allow-newer: true` is needed so that weeder-2.2.0 can be
128210 # installed with the dependencies present in LTS-18.
129211 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
131213
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"
133215
134- - run : " stack exec weeder"
216+ - run : " ci/fix-home stack exec weeder"
135217
136218 # Now do it again, with the test suite included. We don't want a
137219 # reference from our test suite to count in the above check; the fact
138220 # that a function is tested is not evidence that it's needed. But we also
139221 # 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"
141223
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