-
Notifications
You must be signed in to change notification settings - Fork 50
133 lines (116 loc) · 4.08 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches: [master]
release:
types: [published]
env:
SERVER_ASSET: trypurescript-server
CLIENT_ASSET: trypurescript-client
jobs:
build_server:
name: Build server
# Note that this must be kept in sync with the version of Ubuntu which the
# Try PureScript server is running, otherwise the server binary may fail to
# run.
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
with:
enable-stack: true
stack-version: "2.5.1"
stack-no-global: true
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.stack
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('trypurescript.cabal') }}
- name: Build server code
run: stack --no-terminal -j1 build
- name: Build server assets
if: github.event_name == 'release'
run: |
mkdir ${{ env.SERVER_ASSET }}
cp $(stack path --dist-dir)/build/trypurescript/trypurescript ${{ env.SERVER_ASSET }}/
cp LICENSE ${{ env.SERVER_ASSET }}/
cp -r deploy/ ${{ env.SERVER_ASSET }}/
cp -r staging/ ${{ env.SERVER_ASSET}}/
tar czf ${{ env.SERVER_ASSET }}.tar.gz -C ${{ env.SERVER_ASSET }}/ .
- name: Persist server assets
uses: actions/upload-artifact@v2
if: github.event_name == 'release'
with:
name: ${{ env.SERVER_ASSET }}.tar.gz
path: ${{ env.SERVER_ASSET }}.tar.gz
retention-days: 1
build_client:
name: Build client
# Note that this must be kept in sync with the version of Ubuntu which the
# Try PureScript server is running, otherwise the server binary may fail to
# run.
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Build client code
run: |
cd client
npm install
npm run build
npm run test
npm run build:production
npm run bundle
- name: Check SharedConfig.purs versions
run: |
cd client
cp src/Try/SharedConfig.purs sharedConfig.out
node updateSharedConfigVersions.mjs sharedConfig.out
diff src/Try/SharedConfig.purs sharedConfig.out || {
echo 'PureScript and/or package set versions in "client/src/Try/SharedConfig.purs"'
echo 'do not match the versions extracted from "stack.yaml" and "staging/packages.dhall".'
echo 'Please run "cd client && npm run updateConfigVersions". CI will fail until then.'
exit 1
}
- name: Build client assets
if: github.event_name == 'release'
run: |
mkdir ${{ env.CLIENT_ASSET }}
cp LICENSE ${{ env.CLIENT_ASSET }}/
cp -r client/public/ ${{ env.CLIENT_ASSET }}/
tar czf ${{ env.CLIENT_ASSET }}.tar.gz -C ${{ env.CLIENT_ASSET }}/ .
- name: Persist client assets
uses: actions/upload-artifact@v2
if: github.event_name == 'release'
with:
name: ${{ env.CLIENT_ASSET }}.tar.gz
path: ${{ env.CLIENT_ASSET }}.tar.gz
retention-days: 1
release:
name: Release
# Note that this must be kept in sync with the version of Ubuntu which the
# Try PureScript server is running, otherwise the server binary may fail to
# run.
runs-on: ubuntu-20.04
if: github.event_name == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
needs:
- build_server
- build_client
steps:
- name: Retrieve server assets
uses: actions/download-artifact@v2
with:
name: ${{ env.SERVER_ASSET }}.tar.gz
- name: Retrieve client assets
uses: actions/download-artifact@v2
with:
name: ${{ env.CLIENT_ASSET }}.tar.gz
- name: Upload server and client assets
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.SERVER_ASSET }}.tar.gz
${{ env.CLIENT_ASSET }}.tar.gz