-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 2.9 KB
/
ci.yaml
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
# This is a Github Workflow that runs tests on any push or pull request.
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
name: CI
on: [push, pull_request]
jobs:
init:
name: init
runs-on: ubuntu-22.04
outputs:
skip: ${{ steps.ci-skip-step.outputs.ci-skip }}
skip-not: ${{ steps.ci-skip-step.outputs.ci-skip-not }}
steps:
- uses: actions/checkout@v3
- id: ci-skip-step
uses: mstachniuk/ci-skip@v1
test_push:
name: Test on push
needs: init
if: ${{ needs.init.outputs.skip == 'false' && github.event_name == 'push' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install deps
run: npm i
- name: Run tests
run: npm run test
test_pr:
if: ${{ needs.init.outputs.skip == 'false' && github.event_name == 'pull_request' }}
needs: init
name: Test PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
strategy:
matrix:
os: [ ubuntu-20.04 ]
node-version: [ 16, 18 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install deps
run: npm i
- if: matrix.os == 'windows-2019'
run: npm i -g npm
- name: Run tests
timeout-minutes: 2
run: npm test
release:
name: Release
# https://github.community/t/trigger-job-on-tag-push-only/18076
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: test_push
runs-on: ubuntu-22.04
permissions:
checks: read
statuses: write
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install deps
run: npm i
- name: Create .npmrc
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> .npmrc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_COMMITTER_EMAIL: '[email protected]'
GIT_COMMITTER_NAME: 'qiwibot'
run: npm_config_yes=true npx zx-semrel
# run: |
# npm link
# zx-extra https://raw.githubusercontent.com/semrel-extra/zx-semrel/0df9ee72ccaddae156e821a340806d49307b963c/release.mjs