44 push :
55 branches :
66 - master
7+ tags :
8+ - v*
79 pull_request :
810 branches :
911 - master
1012
1113jobs :
12- test :
13- name : Native
14+ build-test :
1415 runs-on : ${{ matrix.os }}
1516 strategy :
17+ fail-fast : false
1618 matrix :
17- os : [ubuntu-latest, macos-latest]
18- node-version : [12.x]
19+ os : [ubuntu-latest, macos-latest, windows-latest]
1920 steps :
20- - uses : actions/checkout@v1
21-
22- - name : Use Node.js ${{ matrix.node-version }}
23- uses : actions/setup-node@v1
21+ - uses : actions/checkout@v2
22+ - uses : actions/setup-node@v1
2423 with :
25- node-version : ${{ matrix.node-version }}
26-
27- - name : Cache esy dependencies
28- uses : actions/cache@v1
29- id : cache
30- with :
31- path : _export
32- key : ${{ runner.OS }}-build-${{ hashFiles('esy.lock/index.json') }}
33- restore-keys : |
34- ${{ runner.OS }}-build-${{ env.cache-name }}-
35- ${{ runner.OS }}-build-
36- ${{ runner.OS }}-
37-
24+ node-version : 12
3825 - name : Install esy
39- run :
npm install -g [email protected] .6 26+ run :
npm install -g [email protected] .7 4027
41- - name : Import dependencies
42- if : steps.cache.outputs.cache-hit == 'true'
43- run : esy import-build _export/*
28+ - name : Try to restore install cache
29+ uses : actions/cache@v2
30+ with :
31+ path : ~/.esy/source
32+ key : source-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
4433
4534 - name : Install dependencies
4635 run : esy install
4736
48- - name : Build
37+ - name : Print esy cache
38+ id : print_esy_cache
39+ run : node .github/workflows/print-esy-cache.js
40+
41+ - name : Try to restore dependencies cache
42+ id : deps-cache
43+ uses : actions/cache@v2
44+ with :
45+ path : ${{ steps.print_esy_cache.outputs.esy_cache }}
46+ key : build-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
47+ restore-keys : build-${{ matrix.os }}-
48+
49+ - name : Build dependencies
50+ if : steps.deps-cache.outputs.cache-hit != 'true'
51+ run : esy build-dependencies
52+
53+ - name : Build project
4954 run : esy build
5055
51- - name : Run tests
56+ - name : Run Native tests
5257 run : esy test
5358
54- - name : Export dependencies
55- run : esy export-dependencies
59+ - name : Create npm package
60+ run : esy npm-release
61+ - uses : actions/upload-artifact@v2
62+ with :
63+ name : ${{ matrix.os }}
64+ path : _release/
65+
66+ # Cleanup build cache if dependencies have changed
67+ - name : Clean build cache
68+ if : steps.deps-cache.outputs.cache-hit != 'true'
69+ run : esy cleanup .
70+
71+ prepare-publish :
72+ name : Prepare publish to npm
73+ needs : build-test
74+ runs-on : ubuntu-latest
75+ steps :
76+ - uses : actions/setup-node@v1
77+ with :
78+ node-version : 12
79+ - uses : actions/checkout@v2
80+
81+ # Download platform artifacts
82+ - name : Download Linux release
83+ uses : actions/download-artifact@v2
84+ with :
85+ name : ubuntu-latest
86+ path : ubuntu-latest
87+ - name : Download Windows release
88+ uses : actions/download-artifact@v2
89+ with :
90+ name : windows-latest
91+ path : windows-latest
92+ - name : Download macOS release
93+ uses : actions/download-artifact@v2
94+ with :
95+ name : macos-latest
96+ path : macos-latest
97+ # Move artifacts in place
98+ - name : Move artifacts
99+ run : |
100+ mkdir -p _release/platform-linux
101+ mkdir -p _release/platform-windows-x64
102+ mkdir -p _release/platform-darwin
103+ cp -a ubuntu-latest/. _release/platform-linux
104+ cp -a windows-latest/. _release/platform-windows-x64
105+ cp -a macos-latest/. _release/platform-darwin
106+ - name : Prepare package
107+ run : node .github/workflows/release.js
108+ # Create a npm package that can easily be published and tested
109+ - name : npm pack
110+ run : npm pack .
111+ working-directory : _release
112+ - name : move package
113+ run : mv _release/*.tgz react-rules-of-hooks-ppx.tgz
114+ # Upload artifacts
115+ - uses : actions/upload-artifact@v2
116+ with :
117+ name : release
118+ path : _release/
119+ - uses : actions/upload-artifact@v2
120+ with :
121+ name : release-tarball
122+ path : react-rules-of-hooks-ppx.tgz
123+
124+ publish :
125+ needs : prepare-publish
126+ name : (only on release) Publish
127+ runs-on : ubuntu-latest
128+ steps :
129+ - uses : actions/checkout@v2
130+
131+ - name : Use Node.js 12.x
132+ uses : actions/setup-node@v1
133+ with :
134+ node-version : 12.x
135+
136+ - name : Print short SHA
137+ id : sha
138+ run : echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
139+
140+ - name : Download release
141+ uses : actions/download-artifact@v2
142+ with :
143+ name : release
144+ path : release
145+
146+ - name : Zip release folder
147+ run : zip -r release.zip release
148+
149+ - name : Create GitHub release
150+ id : create_release
151+ uses : actions/create-release@v1
152+ env :
153+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
154+ with :
155+ tag_name : ${{ github.ref }}
156+ release_name : Release ${{ github.ref }}
157+ draft : false
158+ prerelease : false
159+
160+ - name : Upload ubuntu-latest to Github release
161+ uses : actions/upload-release-asset@v1
162+ env :
163+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
164+ with :
165+ upload_url : ${{ steps.create_release.outputs.upload_url }}
166+ asset_path : release.zip
167+ asset_name : release.zip
168+ asset_content_type : application/gzip
169+
170+ - name : Release nightly NPM package
171+ if : github.event_name == 'pull_request'
172+ run : |
173+ npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
174+ npm version prerelease --preid nightly.${{ steps.sha.outputs.sha_short }} -no-git-tag-version
175+ npm publish --access public --tag nightly
176+ working-directory : ./_release
177+ env :
178+ NODE_AUTH_TOKEN : ${{ secrets.NODE_AUTH_TOKEN }}
179+
180+ - name : Release NPM package
181+ if : " startsWith(github.ref, 'refs/tags/v')"
182+ run : |
183+ npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
184+ npm publish --access public
185+ working-directory : ./_release
186+ env :
187+ NODE_AUTH_TOKEN : ${{ secrets.NODE_AUTH_TOKEN }}
0 commit comments