Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 87fe012

Browse files
authored
Merge c507b8a into 4253ea6
2 parents 4253ea6 + c507b8a commit 87fe012

File tree

5 files changed

+308
-2
lines changed

5 files changed

+308
-2
lines changed

.github/workflows/release.yml

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
name: release
2+
on:
3+
# push:
4+
# tags:
5+
# - 'v*'
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
BUILD_ENV: release
11+
12+
jobs:
13+
create-release:
14+
name: create-release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: get version number
18+
run: |
19+
# echo "GITHUB_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
20+
echo "GITHUB_TAG=0.0.1-pre" >> $GITHUB_ENV
21+
22+
- name: print version number
23+
run: |
24+
echo "tag = ${{ env.GITHUB_TAG }}"
25+
26+
- name: create release on github
27+
id: create_release
28+
uses: actions/create-release@v1
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
tag_name: v${{ env.GITHUB_TAG }}
33+
release_name: v${{ env.GITHUB_TAG }}
34+
35+
- name: generate env artifact
36+
run: |
37+
echo "RELEASE_UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" > artifact-env
38+
echo "GITHUB_TAG=$GITHUB_TAG" >> artifact-env
39+
40+
- name: save env artifact
41+
uses: actions/upload-artifact@v1
42+
with:
43+
name: artifact-env
44+
path: artifact-env
45+
46+
build-node-files:
47+
name: build-node-files
48+
needs: ['create-release']
49+
runs-on: ${{ matrix.build.os }}
50+
env:
51+
BUILD_ENV: release
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
build:
56+
- { os: ubuntu-20.04, output: linux-x86_64.node }
57+
- { os: macos-latest, output: darwin-x86_64.node }
58+
steps:
59+
- name: set NPM_CONFIG_PREFIX
60+
run: |
61+
echo "NPM_CONFIG_PREFIX=$HOME/.npm-global" >> $GITHUB_ENV
62+
63+
- name: checkout
64+
uses: actions/checkout@v2
65+
66+
- name: download env artifact
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: artifact-env
70+
path: artifact-env
71+
72+
- name: load env artifact
73+
run: cat artifact-env/artifact-env >> $GITHUB_ENV
74+
75+
- name: install node
76+
uses: actions/setup-node@v2
77+
with:
78+
node-version: 15
79+
registry-url: 'https://registry.npmjs.org'
80+
81+
- name: install rust
82+
uses: actions-rs/toolchain@v1
83+
with:
84+
profile: minimal
85+
toolchain: stable
86+
override: true
87+
88+
- name: configure NPM_CONFIG_PREFIX
89+
run: |
90+
npm config set prefix $NPM_CONFIG_PREFIX
91+
mkdir -p $NPM_CONFIG_PREFIX/bin
92+
mkdir -p $NPM_CONFIG_PREFIX/lib
93+
echo "$NPM_CONFIG_PREFIX/bin" >> $GITHUB_PATH
94+
95+
- name: install node-gyp
96+
run: |
97+
npm install -g node-gyp
98+
echo $PATH
99+
which node-gyp
100+
101+
- name: npm install
102+
run: npm install --ignore-scripts
103+
104+
- name: configure
105+
run: |
106+
make update-cpp-bindings
107+
make generate-bindings
108+
make configure
109+
110+
- name: build
111+
run: make build
112+
113+
- name: run tests
114+
run: make test
115+
116+
- name: upload assets
117+
uses: actions/[email protected]
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
with:
121+
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
122+
asset_path: build/Release/ruby_parser.node
123+
asset_name: ${{ matrix.build.output }}
124+
asset_content_type: application/octet-stream
125+
126+
- name: save .node file as artifact
127+
uses: actions/upload-artifact@v1
128+
with:
129+
name: ${{ matrix.build.output }}
130+
path: build/Release/ruby_parser.node
131+
132+
build-package:
133+
name: build-package
134+
needs: ['build-node-files']
135+
runs-on: ubuntu-20.04
136+
steps:
137+
- name: checkout
138+
uses: actions/checkout@v2
139+
140+
- name: install node
141+
uses: actions/setup-node@v2
142+
with:
143+
node-version: 15
144+
registry-url: 'https://registry.npmjs.org'
145+
146+
- name: download linux artifact
147+
uses: actions/download-artifact@v1
148+
with:
149+
name: linux-x86_64.node
150+
path: linux-x86_64.node
151+
152+
- name: download macos artifact
153+
uses: actions/download-artifact@v1
154+
with:
155+
name: darwin-x86_64.node
156+
path: darwin-x86_64.node
157+
158+
- name: download env artifact
159+
uses: actions/download-artifact@v1
160+
with:
161+
name: artifact-env
162+
path: artifact-env
163+
164+
- name: load env artifact
165+
run: cat artifact-env/artifact-env >> $GITHUB_ENV
166+
167+
- name: build package
168+
run: |
169+
ls -l linux-x86_64.node/
170+
ls -l darwin-x86_64.node/
171+
172+
cp linux-x86_64.node/ruby_parser.node pkg/linux-x86_64.node
173+
cp darwin-x86_64.node/ruby_parser.node pkg/darwin-x86_64.node
174+
cp LICENSE pkg/
175+
cd pkg
176+
177+
npm version "$GITHUB_TAG" --no-git-tag-version
178+
npm pack
179+
ls -l
180+
181+
- name: upload assets
182+
uses: actions/[email protected]
183+
env:
184+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185+
with:
186+
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
187+
asset_path: pkg/lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
188+
asset_name: lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
189+
asset_content_type: application/octet-stream
190+
191+
- name: save .tgz package as artifact
192+
uses: actions/upload-artifact@v1
193+
with:
194+
name: lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
195+
path: pkg/lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
196+
197+
test-package:
198+
name: test-package
199+
needs: ['build-package']
200+
runs-on: ${{ matrix.os }}
201+
strategy:
202+
fail-fast: false
203+
matrix:
204+
node: [ '10', '12', '14', '15' ]
205+
os: [ubuntu-20.04, macos-latest]
206+
steps:
207+
- name: checkout
208+
uses: actions/checkout@v2
209+
210+
- name: install node
211+
uses: actions/setup-node@v2
212+
with:
213+
node-version: ${{ matrix.node }}
214+
registry-url: 'https://registry.npmjs.org'
215+
216+
- name: download env artifact
217+
uses: actions/download-artifact@v1
218+
with:
219+
name: artifact-env
220+
path: artifact-env
221+
222+
- name: load env artifact
223+
run: cat artifact-env/artifact-env >> $GITHUB_ENV
224+
225+
- name: download .tgz artifact
226+
uses: actions/download-artifact@v1
227+
with:
228+
name: lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
229+
path: lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
230+
231+
- name: test
232+
run: |
233+
mkdir test
234+
cd test
235+
echo "{}" > package.json
236+
npm install ../lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz/lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
237+
238+
node -e "console.log(require.resolve('lib-ruby-parser'))"
239+
node -e "console.log(require('lib-ruby-parser').parse('2 + 2', {}))"
240+
241+
publish-package:
242+
name: publish-package
243+
needs: ['test-package']
244+
runs-on: ubuntu-20.04
245+
steps:
246+
- name: download env artifact
247+
uses: actions/download-artifact@v1
248+
with:
249+
name: artifact-env
250+
path: artifact-env
251+
252+
- name: load env artifact
253+
run: cat artifact-env/artifact-env >> $GITHUB_ENV
254+
255+
- name: download .tgz artifact
256+
uses: actions/download-artifact@v1
257+
with:
258+
name: lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
259+
path: lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
260+
261+
- name: install node
262+
uses: actions/setup-node@v2
263+
with:
264+
node-version: 15
265+
registry-url: 'https://registry.npmjs.org'
266+
267+
- name: publish
268+
run: npm publish $PWD/lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz/lib-ruby-parser-${{ env.GITHUB_TAG }}.tgz
269+
env:
270+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
2525
- name: checkout
2626
uses: actions/checkout@v2
27-
with:
28-
submodules: true
2927

3028
- name: install rust
3129
uses: actions-rs/toolchain@v1

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 lib-ruby-parser
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pkg/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
switch (process.platform) {
2+
case 'linux':
3+
module.exports = require('./linux-x86_64.node');
4+
break;
5+
case 'darwin':
6+
module.exports = require('./darwin-x86_64.node')
7+
break;
8+
default:
9+
throw new Error(`unsupported process.platform '${process.platform}' (only 'linux' and 'darwin' are supported)`);
10+
}

pkg/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "lib-ruby-parser",
3+
"version": "0.0.0",
4+
"description": "bindings to lib-ruby-parser",
5+
"repository": "github:lib-ruby-parser/node-bindings",
6+
"license": "MIT"
7+
}

0 commit comments

Comments
 (0)