Skip to content

Commit f64563d

Browse files
committed
chore: add github action for release
1 parent 304a238 commit f64563d

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release - cli
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
lint-all:
9+
if: startsWith(github.head_ref, 'release/')
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Use Node.js 16.x
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 16.x
17+
cache: npm
18+
- run: node ./bin/npm-cli.js run resetdeps
19+
- run: node ./bin/npm-cli.js run lint-all
20+
21+
prepublish:
22+
if: startsWith(github.head_ref, 'release/')
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Use Node.js 16.x
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 16.x
30+
cache: npm
31+
- run: node ./bin/npm-cli.js run resetdeps
32+
- run: make prepublish
33+
34+
test-all:
35+
if: startsWith(github.head_ref, 'release/')
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
node-version:
40+
- 12.13.0
41+
- 12.x
42+
- 14.15.0
43+
- 14.x
44+
- 16.0.0
45+
- 16.x
46+
platform:
47+
- os: ubuntu-latest
48+
shell: bash
49+
- os: macos-latest
50+
shell: bash
51+
- os: windows-latest
52+
shell: cmd
53+
runs-on: ${{ matrix.platform.os }}
54+
defaults:
55+
run:
56+
shell: ${{ matrix.platform.shell }}
57+
steps:
58+
- uses: actions/checkout@v3
59+
- name: Use Node.js ${{ matrix.node-version }}
60+
uses: actions/setup-node@v3
61+
with:
62+
node-version: ${{ matrix.node-version }}
63+
cache: npm
64+
- run: node ./bin/npm-cli.js run resetdeps
65+
- run: node ./bin/npm-cli.js link -f --ignore-scripts
66+
- run: node ./bin/npm-cli.js run test-all --ignore-scripts
67+
- name: git status
68+
if: matrix.platform.os != 'windows-latest'
69+
run: node scripts/git-dirty.js

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ link: uninstall
101101

102102
prune: deps
103103
node bin/npm-cli.js prune --production --no-save --no-audit
104-
@[[ "$(shell git status -s)" != "" ]] && echo "ERR: found unpruned files" && exit 1 || echo "git status is clean"
104+
node scripts/git-dirty.js
105105

106-
publish: gitclean ls-ok link test smoke-tests docs prune
107-
@git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true
106+
prepublish: gitclean ls-ok link test smoke-tests docs prune
107+
108+
publish: prepublish
108109
git push origin $(BRANCH) &&\
109110
git push origin --tags &&\
110111
node bin/npm-cli.js publish --tag=$(PUBLISHTAG)

scripts/git-dirty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
const { spawnSync } = require('child_process')
3-
const changes = spawnSync('git', ['status', '--porcelain', '-uno'])
3+
const changes = spawnSync('git', ['status', '--porcelain', '-uall'])
44
const stdout = changes.stdout.toString('utf8')
55
const stderr = changes.stderr.toString('utf8')
66
const { status, signal } = changes

0 commit comments

Comments
 (0)