-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (75 loc) · 2.32 KB
/
publish.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
name: Publish
on:
push:
branches:
- master
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
should-release:
name: Should Release
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- name: Node
uses: actions/setup-node@v3
- name: Deps
run: npm i -g semver
- name: Run should-release
run: node ./scripts/should-release.js
- name: Current Version
id: current-version
run: echo 'CURRENT_VERSION='$(node -p -e "require('./package.json').version") >> $GITHUB_OUTPUT
- name: Check Skip Release
id: skip-release
run: echo 'SKIP='$(cat .skip-release) >> $GITHUB_OUTPUT
outputs:
SKIP: ${{ steps.skip-release.outputs.SKIP }}
CURRENT_VERSION: ${{ steps.current-version.outputs.CURRENT_VERSION }}
publish:
needs: [should-release]
if: needs.should-release.outputs.SKIP != 'true'
name: Publish
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- name: Node
uses: actions/setup-node@v3
- name: Cache Yarn
id: cache-nodemodules
uses: actions/cache@v3
with:
path: node_modules
key: packages-${{ hashFiles('yarn.lock') }}
restore-keys: |
packages-
- name: Yarn
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Setup NPM Registry
run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}' > ~/.npmrc && npm config get registry && npm whoami
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Publish
run: npm publish
- name: Check Skip Release
id: skip-release
run: echo 'SKIP='$(cat .skip-release) >> $GITHUB_OUTPUT
- name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ needs.should-release.outputs.CURRENT_VERSION }}",
sha: context.sha
})
outputs:
SKIP: ${{ steps.skip-release.outputs.SKIP }}