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

Commit eb5714d

Browse files
authored
Merge pull request #1 from lib-ruby-parser/release-workflow
added release workflow
2 parents 4253ea6 + 8512145 commit eb5714d

File tree

5 files changed

+305
-2
lines changed

5 files changed

+305
-2
lines changed

.github/workflows/release.yml

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