-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (64 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
name: Publish npm package
on:
pull_request:
branches:
- master
types: [closed]
env:
# Check available versions below
# https://github.com/actions/node-versions/blob/main/versions-manifest.json
node-version: "20.x"
jobs:
publish:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
cache: "yarn"
node-version: ${{ env.node-version }}
registry-url: "https://registry.npmjs.org"
always-auth: true
- name: Cache node_modules
uses: actions/cache@v2
id: cache_node_modules
with:
# check diff of package.json and yarn.lock
key: ${{ runner.os }}-build-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
path: "**/node_modules"
- name: Install dependencies
if: steps.cache_node_modules.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build
run: yarn build
# - name: Bump version and push tag
# id: tag_version
# uses: mathieudutour/github-tag-action@v6.0
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if package version can be published
uses: technote-space/package-version-check-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGE_MANAGER: yarn
- name: Get new package version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
- name: Create tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.package-version.outputs.current-version }}
message: Released ${{ steps.package-version.outputs.current-version }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.package-version.outputs.current-version }}
name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
- name: Publish npm package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc && yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}