-
-
Notifications
You must be signed in to change notification settings - Fork 33
218 lines (181 loc) · 6.73 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
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
210
211
212
213
214
215
216
217
218
name: Ppx CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
OPAM_VERSION: 2.3.0
DUNE_PROFILE: release
permissions:
contents: write
pull-requests: write
defaults:
run:
shell: bash -xeuo pipefail {0}
jobs:
build:
name: Build
strategy:
matrix:
os: [ubuntu-20.04, macos-latest] # Missing windows-latest
ocaml-compiler:
- 5.2.0
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
- name: Load opam cache
id: opam-cache
uses: actions/cache/restore@v4
with:
path: |
${{ runner.tool_cache }}/opam
~/.opam
_opam
.opam-path
key: opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/[email protected]
if: steps.opam-cache.outputs.cache-hit != 'true'
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: false
opam-disable-sandboxing: true
- name: Get OPAM executable path
if: steps.opam-cache.outputs.cache-hit != 'true'
uses: actions/github-script@v7
with:
script: |
const opam_path = await io.which('opam', true);
console.log('opam executable found: %s', opam_path);
const Fs = require('fs/promises');
await Fs.writeFile('.opam-path', opam_path, 'utf-8');
console.log('stored path to .opam-path');
- name: Use cached OPAM environment
# if: steps.opam-cache.outputs.cache-hit == 'true'
shell: bash
run: |
# https://github.com/ocaml/setup-ocaml/blob/b2105f9/packages/setup-ocaml/src/installer.ts#L33
echo "OPAMVERBOSE=$RUNNER_DEBUG" >> "$GITHUB_ENV"
echo "OPAMCOLOR=always" >> "$GITHUB_ENV"
echo "OPAMCONFIRMLEVEL=unsafe-yes" >> "$GITHUB_ENV"
echo "OPAMERRLOGLEN=0" >> "$GITHUB_ENV"
echo "OPAMPRECISETRACKING=1" >> "$GITHUB_ENV"
echo "OPAMYES=1" >> "$GITHUB_ENV"
echo "OPAMROOT=$HOME/.opam" >> "$GITHUB_ENV"
OPAM_PATH="$(cat .opam-path)"
chmod +x "$OPAM_PATH"
dirname "$OPAM_PATH" >> "$GITHUB_PATH"
- name: Install dependencies
run: make install
- name: Build
run: make build
- name: Test
run: make test
- name: Release static
run: make release-static
- name: Upload artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
path: _build/default/packages/bin/bin.exe
- name: Upload runtime artifacts for @davesnx/styled-ppx/runtime
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3
with:
name: runtime-rescript
path: _build/default/packages/runtime/rescript
- name: Save opam cache
uses: actions/cache/save@v4
if: steps.opam-cache.outputs.cache-hit != 'true'
with:
path: |
${{ runner.tool_cache }}/opam
~/.opam
_opam
.opam-path
key: opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
- name: Save npm cache
uses: actions/cache/save@v4
with:
path: node_modules
key: npm-${{ matrix.os }}-${{ hashFiles('package.json') }}
- name: Grant permission to run ppx
run: chmod +x _build/default/packages/bin/bin.exe
- name: Run E2E tests
run: make test-e2e
publish:
name: Publish
needs: build
if: github.repository_owner == 'davesnx'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- name: Make NPM release skeleton
run: node scripts/release-make-skeleton.js
- name: Print short SHA
id: sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Download linux artifacts
uses: actions/download-artifact@v3
with:
name: ubuntu-20.04
path: _release/platform-linux-x64
- name: Download macOS artifacts
uses: actions/download-artifact@v3
with:
name: macos-latest
path: _release/platform-darwin-x64
# - name: Download windows artifacts
# uses: actions/download-artifact@v3
# with:
# name: windows-latest
# path: _release/platform-windows-x64
- name: Download runtime-rescript artifacts
uses: actions/download-artifact@v3
with:
name: runtime-rescript
path: _release/rescript
- name: Release nightly (@davesnx/styled-ppx) package
if: ${{ success() && github.event_name == 'pull_request' && github.event.pull_request.user.login == 'davesnx' }}
id: nightly
working-directory: ./_release
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: |
ls -lhsa
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@davesnx"
npm version prerelease --preid ${{ steps.sha.outputs.sha_short }} -no-git-tag-version
npm publish --access public --tag nightly
echo "version=$(npm view @davesnx/styled-ppx@nightly version)" >> $GITHUB_OUTPUT
- name: Release (@davesnx/styled-ppx) package
if: ${{ success() && github.event_name != 'pull_request' }}
working-directory: ./_release
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@davesnx"
REMOTE=$(npm view @davesnx/styled-ppx version)
CURRENT=$(jq -r '.version' package.json)
if [ "$REMOTE" != "$CURRENT" ]
then
npm publish --access public
else
echo "New verison and remote version are equal, nothing to publish"
fi
- uses: mshick/add-pr-comment@v2
if: ${{ steps.nightly.outputs.version }}
with:
message: |
New **nightly** version has been published to the NPM registry: [@davesnx/styled-ppx@${{ steps.nightly.outputs.version }}](https://www.npmjs.com/package/@davesnx/styled-ppx/v/${{ steps.nightly.outputs.version }}).
Install it with `npm install @davesnx/styled-ppx@nightly` or `npm install @davesnx/styled-ppx@${{ steps.nightly.outputs.version }}`.
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false