-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (93 loc) · 3.05 KB
/
release.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
name: Release
on:
pull_request:
branches:
- main
types: [closed]
env:
CI: true
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
jobs:
publish:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
steps:
- name: Pull Request Merged
if: github.event.pull_request.merged == false
run: |
echo 'The pull request has not been merged'
exit 1
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set git config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Setup .npmrc
shell: bash
run: |
npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Ensure access
shell: bash
run: npm whoami --registry https://registry.npmjs.org/
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Set public access
shell: bash
run: npm config set access public
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v4
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests with coverage
run: npm run coverage
- name: Upload coverage
uses: coverallsapp/github-action@v2
- name: Build the project
run: npm run build
- name: Get Prev Version
shell: bash -ex {0}
run: |
PREV_VERSION=$(node -p 'require("./lerna.json").version')
echo "::set-env name=PREV_VERSION::${PREV_VERSION}"
- name: Bump versions and publish packages
run: |
npx lerna version --yes --conventional-commits --message 'chore(release): publish'
npx lerna publish from-package --yes
- name: Get Current Version
shell: bash -ex {0}
run: |
CURRENT_VERSION=$(node -p 'require("./lerna.json").version')
echo "::set-env name=CURRENT_VERSION::${CURRENT_VERSION}"
- name: Create comment
uses: actions/github-script@v7
if: env.PREV_VERSION != env.CURRENT_VERSION
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'NPM package v${{ env.CURRENT_VERSION }} has been published 🎉'
})