-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (66 loc) · 2.17 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
name: 发布仓库包
on:
push:
branches:
- master # 只在推送到 master 分支时触发
permissions:
contents: write
packages: write
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x' # 你可以根据需要更改 Node.js 版本
- name: Install dependencies
run: npm install
- name: TSC Check
run: npm run type-check
- name: Test
run: npm run test:cover
publish:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x' # 你可以根据需要更改 Node.js 版本
registry-url: 'https://npm.pkg.github.com'
- name: Install dependencies
run: npm install
- name: Make get-version.sh executable
run: chmod +x ./get-version.sh
- name: Make publish.sh executable
run: chmod +x ./publish.sh
- name: Make npmrc-set-up.sh executable
run: chmod +x ./npmrc-set-up.sh
- name: Set up npmrc
run: ./npmrc-set-up.sh -t ${{ secrets.GITHUB_TOKEN }} -p weibo-api -o hk-artificial-intelligence-association
- name: Get package version
id: get_version
run: ./get-version.sh
- name: TSC Check
run: npm run type-check
- name: Build delopy
run: npm run build
- name: Check if version is already published
id: check_version
run: |
if npm view @hk-artificial-intelligence-association/weibo-api@${{ steps.get_version.outputs.version }} version; then
echo "Version ${{ steps.get_version.outputs.version }} is already published."
echo "::set-output name=should_publish::false"
else
echo "Version ${{ steps.get_version.outputs.version }} is not published."
echo "::set-output name=should_publish::true"
fi
- name: Publish to npm
if: steps.check_version.outputs.should_publish == 'true'
run: ./publish.sh -t ${{ secrets.GITHUB_TOKEN}}