-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (143 loc) · 4.35 KB
/
ci.yml
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: ci
on:
push:
branches:
- main
tags:
- 'v*' # Tags matching v*, e.g. v1.0, v0.3.1
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Archive build # https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files
run: tar -czvf lib.tar.gz ./lib
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: build
path: ./lib.tar.gz
retention-days: 1
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [16.x, 14.x, 12.x]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
lint:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm install
- name: Lint
run: npm run lint
release:
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: ['build', 'test', 'lint']
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # Git history won't be fetched without this option
- name: Generate release notes # To change the release notes format, edit RELEASE.md.hbs
id: notes
run: |
npx auto-changelog@2.x.x --template RELEASE.md.hbs --output RELEASE.md --commit-limit false
NOTES=$(cat RELEASE.md)
NOTES="${NOTES//'%'/'%25'}"
NOTES="${NOTES//$'\n'/'%0A'}"
echo "::set-output name=notes::$NOTES"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.notes.outputs.notes }}
draft: false
prerelease: false
# Comment out one of the following jobs to publish to only registry
publish-npm:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: ['build', 'test', 'lint']
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Download build
uses: actions/download-artifact@v2
with:
name: build
- name: Unarchive build
run: tar -xzf ./lib.tar.gz
- name: Publish
run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Create a repository secret named NPM_TOKEN containing an npm access token
publish-gpr:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: ['build', 'test', 'lint']
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
always-auth: true
- name: Install dependencies
run: npm install --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_TOKEN }}
- name: Download build
uses: actions/download-artifact@v2
with:
name: build
- name: Unarchive build
run: tar -xzf ./lib.tar.gz
- name: Publish
run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by GitHub, and requires no setup