-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (51 loc) · 1.55 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
name: release
on:
release:
types: [released]
jobs:
test-and-build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run format:check
- run: npm run tsc:check
- run: npm run test
- run: npm run build
publish:
runs-on: ubuntu-latest
needs: test-and-build
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm install
- run: npm run build
- name: Update version based on tag
run: |
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
echo "Updating package.json version to $VERSION"
npm version $VERSION --no-git-tag-version
- name: Commit version change
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add package.json
git commit -m "chore(release): update version to $VERSION"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}