This repository has been archived by the owner on Mar 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 70
155 lines (130 loc) · 3.79 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
152
153
154
155
name: CI
on:
push:
branches:
# Match SemVer major release branches, e.g. "2.x" or ".x"
- '[0-9]+.x'
- 'main'
- 'next'
- 'alpha'
- 'beta'
- '!all-contributors/**'
pull_request:
types: [opened, synchronize, reopened]
env:
NODE_VERSION: '14.x'
jobs:
setup:
name: Setup
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE_VERSION }}'
- name: Cache node modules
id: cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts && npm run postinstall
eslint:
name: Eslint
runs-on: ubuntu-latest
needs: [setup]
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE_VERSION }}'
- name: Fetch all branches
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
- name: ESLint
run: npm run ci:lint -- $(git diff --diff-filter d --name-only origin/${{ github.base_ref }}...HEAD -- '*.js' '*.ts' '*.tsx')
typescript:
name: Typescript
runs-on: ubuntu-latest
needs: [setup]
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE_VERSION }}'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
- name: Typescript
run: npm run ci:tsc
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: [setup]
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE_VERSION }}'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
- name: Test
run: npm run test
release:
needs: [test]
if: github.event_name == 'push' && github.repository == 'smeijer/unimported'
runs-on: ubuntu-latest
environment: npm
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.0
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE_VERSION }}'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
- name: Build
run: npm run build
- name: Release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
{ name: 'alpha', prerelease: true },
{ name: 'beta', prerelease: true }
]
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}