-
Notifications
You must be signed in to change notification settings - Fork 16
94 lines (77 loc) · 2.99 KB
/
Copy pathersuo_test_node.js.yml
File metadata and controls
94 lines (77 loc) · 2.99 KB
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
- 'occlient_release_*'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
steps:
- name: Checking out for ${{ github.ref }}
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npx version-from-git --no-git-tag-version
if: ${{ startsWith(github.ref, 'refs/heads/') }}
- run: npm ci
- run: npm run build --if-present
env:
NODE_ENV: production
- run: node_modules/.bin/jest
- run: npm pack
- uses: actions/upload-artifact@v2
if: ${{ matrix.node-version == '14.x' }}
with:
name: npm-tarball
path: '*.tgz'
publish:
needs: build
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/download-artifact@v2
with:
name: npm-tarball
- name: Read package.json
id: read-package-json
run: |
echo "::set-output name=name::$(tar xOf *.tgz package/package.json | jq -r '.name')"
echo "::set-output name=version::$(tar xOf *.tgz package/package.json | jq -r '.version')"
echo "::set-output name=tarball::$(ls *.tgz)"
echo "::set-output name=date::$(date +%Y-%m-%d)"
- name: Run npm publish ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }}
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish *.tgz --tag main --access public
npm dist-tag add ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }} latest
- uses: actions/create-release@v1
id: create-release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: '[${{ steps.read-package-json.outputs.version }}] - ${{ steps.read-package-json.outputs.date }}'
draft: true
- uses: actions/upload-release-asset@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./${{ steps.read-package-json.outputs.tarball }}
asset_name: ${{ steps.read-package-json.outputs.tarball }}
asset_content_type: application/octet-stream