-
Notifications
You must be signed in to change notification settings - Fork 2
209 lines (170 loc) · 6.04 KB
/
rescript-sx.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
# based of https://github.com/davesnx/styled-ppx/blob/main/.github/workflows/ci.yml
name: rescript-sx CI
on:
push:
branches:
- main
jobs:
build_macos:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x]
os: [macos-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Load global cache (~/.esy/source)
uses: actions/cache@v2
with:
path: ~/.esy/source
key: source-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
- name: Install esy
run: npm install -g [email protected]
- name: Install dependencies
run: esy install
- name: Print esy cache
id: print_esy_cache
run: node .github/ci-scripts/print-esy-cache.js
- name: Load dependencies cache
id: deps-cache
uses: actions/cache@v2
with:
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
key: build-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
restore-keys: build-${{ matrix.os }}-
- name: Import dependencies
run: esy import-build
- name: Build dependencies
run: esy build-dependencies
- name: Build
run: esy build
- name: Export dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: esy export-dependencies
- name: Upload artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}
path: _build/install/default/bin/sx_ppx
# Cleanup build cache in case dependencies have changed
- name: Cleanup
run: esy cleanup .
build_linux_static:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
container:
image: alexfedoseev/alpine-node-yarn-esy:0.0.4
steps:
- uses: actions/checkout@v2
# TODO: fix this by adding it to the image instead
- name: add build deps
run: apk add tar
- name: Load global cache (~/.esy/source)
uses: actions/cache@v2
with:
path: ~/.esy/source
key: source-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
- name: Install esy
run: npm install -g --unsafe-perm [email protected]
- name: Install dependencies
run: esy install
- name: Print esy cache
id: print_esy_cache
run: node .github/ci-scripts/print-esy-cache.js
- name: Load dependencies cache
id: deps-cache
uses: actions/cache@v2
with:
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
key: build-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
restore-keys: build-${{ matrix.os }}-
- name: Import dependencies
run: esy import-build
- name: Build dependencies
run: esy build-dependencies
# build static binary for linux
- name: Build
run: esy build-static
- name: Export dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: esy export-dependencies
- name: Strip debug symbols for Linux
run: strip --strip-all _build/install/default/bin/sx_ppx
- name: Upload artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}
path: _build/install/default/bin/sx_ppx
# Cleanup build cache in case dependencies have changed
- name: Cleanup
run: esy cleanup .
publish:
name: Publish
needs:
- build_macos
- build_linux_static
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- name: Make NPM release skeleton
run: node .github/ci-scripts/make-skeleton.js
- name: Print short SHA
id: sha
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Download linux artifacts
uses: actions/download-artifact@master
with:
name: ubuntu-latest
path: _release/platform-linux-x64
- name: Download macOS artifacts
uses: actions/download-artifact@master
with:
name: macos-latest
path: _release/platform-darwin-x64
- name: Release NPM package
if: ${{ success() && github.event_name != 'pull_request' }}
working-directory: ./_release
run: |
npm config set scope "@hyper-systems"
REMOTE=$(npm view @hyper-systems/rescript-sx version || echo "0")
CURRENT=$(jq -r '.version' package.json)
echo "Remote version: ${REMOTE}"
echo "Local version: ${CURRENT}"
if [ "$REMOTE" != "$CURRENT" ]
then
npm publish --access public
else
echo "New verison and remote version are equal, nothing to publish"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release nightly NPM package
id: nightly
working-directory: ./_release
run: |
npm config set scope "@hyper-systems"
npm version prerelease --preid ${{ steps.sha.outputs.sha_short }} -no-git-tag-version
REMOTE=$(npm view @hyper-systems/rescript-sx version --tag nightly || echo "0")
CURRENT=$(jq -r '.version' package.json)
echo "Remote version: ${REMOTE}"
echo "Local version: ${CURRENT}"
if [ "$REMOTE" != "$CURRENT" ]
then
npm publish --access public --tag nightly
echo "::set-output name=version::$(npm view @hyper-systems/rescript-sx@nightly version)"
else
echo "New verison and remote version are equal, nothing to publish"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}