-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (99 loc) · 3.06 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
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
115
116
117
118
119
name: Publish
on:
push:
branches:
- main
env:
NODE_VERSION: 20
PNPM_VERSION: latest
jobs:
test-and-upload-coverage:
name: Test and Upload Coverage to Codecov
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: ${{ env.PNPM_VERSION }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run Unit Tests
run: pnpm test -- --run
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: moontaiworks/package-template
files: ./coverage/cobertura-coverage.xml
verbose: true
build-and-publish:
needs: test-and-upload-coverage
name: Build and Publish Package
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: ${{ env.PNPM_VERSION }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: pnpm install
- name: Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Versioning and tagging
id: version
run: sh scripts/version.sh
- name: Build
run: pnpm build
- name: Show version
env:
version: ${{ steps.version.outputs.version }}
major: ${{ steps.version.outputs.major }}
commit: ${{ steps.version.outputs.commit }}
message: ${{ steps.version.outputs.message }}
changelog: ${{ steps.version.outputs.changelog }}
run: |
echo "$version ($major)"
echo "commit: $commit"
echo "message: $message"
echo "changelog: $changelog"
- name: Push changes back to repository
run: git push --follow-tags
- name: Deploy docs to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./docs
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
tag: "v${{ steps.version.outputs.version }}"
name: "v${{ steps.version.outputs.version }}"
body: |
${{ steps.version.outputs.changelog }}
- name: Publish the release to NPM
run: pnpm publish --provenance --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}