-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (121 loc) · 4.47 KB
/
ci.yaml
File metadata and controls
121 lines (121 loc) · 4.47 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
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
name: CI
on:
workflow_dispatch: null
push:
tags:
- v*
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
arch:
- x64
node:
- 14.0.0
include:
- os: ubuntu-latest
platform: linux
publish: true
name: Build on node-v${{ matrix.node }}-${{ matrix.platform }}-${{ matrix.arch }}
outputs:
publish_build_os: ${{ steps.publish-var.outputs.build_os }}
publish_build_arch: ${{ steps.publish-var.outputs.build_arch }}
publish_build_name: ${{ steps.publish-var.outputs.build_name }}
publish_build_node: ${{ steps.publish-var.outputs.build_node }}
publish_pkg_scope: ${{ steps.publish-var.outputs.pkg_scope }}
publish_pkg_build_name: ${{ steps.publish-var.outputs.pkg_build_name }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: bahmutov/npm-install@v1
- id: build-var
run: |-
BUILD_NAME=node-v${{ matrix.node }}-${{ matrix.platform }}-${{ matrix.arch }}
echo "::set-output name=build_name::${BUILD_NAME}"
PKG_SCOPE=$(node -e "console.log(require('./package.json').name.split('/').shift().slice(1))")
PKG_NAME=$(node -e "console.log(require('./package.json').name.split('/').pop())")
PKG_VERSION=$(node -e "console.log(require('./package.json').version)")
echo "::set-output name=pkg_scope::${PKG_SCOPE}"
echo "::set-output name=pkg_name::${PKG_NAME}"
echo "::set-output name=pkg_version::${PKG_VERSION}"
echo "::set-output name=pkg_build_name::${PKG_SCOPE}-${PKG_NAME}-v${PKG_VERSION}-${BUILD_NAME}.tgz"
- id: publish-var
if: matrix.publish
run: |-
echo "::set-output name=pkg_scope::${{ steps.build-var.outputs.pkg_scope }}"
echo "::set-output name=pkg_build_name::${{ steps.build-var.outputs.pkg_build_name }}"
echo "::set-output name=build_os::${{ matrix.os }}"
echo "::set-output name=build_arch::${{ matrix.arch }}"
echo "::set-output name=build_node::${{ matrix.node }}"
echo "::set-output name=build_name::${{ steps.build-var.outputs.build_name }}"
- name: Test
run: npm run test --if-present
- name: Pack
run: |-
npm pack
mv *.tgz ${{ steps.build-var.outputs.pkg_build_name }}
- name: Upload
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build-var.outputs.build_name }}
path: "*.tgz"
if-no-files-found: error
retention-days: 7
publish-github-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs:
- build
name: Publish GitHub release
steps:
- name: Download
uses: actions/download-artifact@v2
- name: Create
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: "**/*.tgz"
publish-github-package:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ${{ needs.build.outputs.publish_build_os }}
needs:
- build
name: Publish GitHub package
steps:
- name: Download
uses: actions/download-artifact@v2
with:
name: ${{ needs.build.outputs.publish_build_name }}
- uses: actions/setup-node@v2
with:
scope: "@${{ needs.build.outputs.publish_pkg_scope }}"
node-version: ${{ needs.build.outputs.publish_build_node }}
registry-url: https://npm.pkg.github.com
- name: Publish
run: npm publish ${{ needs.build.outputs.publish_pkg_build_name }} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm-package:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ${{ needs.build.outputs.publish_build_os }}
needs:
- build
name: Publish NPM package
steps:
- name: Download
uses: actions/download-artifact@v2
with:
name: ${{ needs.build.outputs.publish_build_name }}
- uses: actions/setup-node@v2
with:
scope: "@${{ needs.build.outputs.publish_pkg_scope }}"
node-version: ${{ needs.build.outputs.publish_build_node }}
registry-url: https://registry.npmjs.org
- name: Publish
run: npm publish ${{ needs.build.outputs.publish_pkg_build_name }} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}