-
Notifications
You must be signed in to change notification settings - Fork 3
142 lines (134 loc) · 4.18 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
name: 🎉 Release
on:
push:
branches: [main]
tags:
- '*'
permissions:
contents: write
env:
tag: ${{ github.event.head_commit.id }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Current User
run: whoami
- name: Checkout
uses: actions/checkout@v4
- name: Prepare
run: |
npm -v
npm i -g pnpm
- name: Install
run: pnpm i --prod
- name: Build
run: |
npm run build
npm run build:demo # 构建 webapp
cd dist-demo && zip -r ../webapp.zip . # 将 webapp 打包
- name: Upload Dist Artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
retention-days: 1
- name: Upload WebApp Artifact
uses: actions/upload-artifact@v4
with:
name: webapp
path: webapp.zip
retention-days: 1
tag:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Tag
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
npm version patch -m "👷 CI: Upgrade to v%s"
git push origin main --tags
- name: Read Version
run: |
version=$(node -p "require('./package.json').version")
echo $version
echo "${version}" >> version.txt
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: version
path: version.txt
retention-days: 1
rebase_dev:
needs:
- tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Rebase dev on main
run: |
git fetch origin dev:refs/remotes/origin/dev
git checkout -b dev origin/dev
git rebase origin/main
- name: Push the rebased dev branch
run: git push origin dev:dev --force
release:
runs-on: ubuntu-latest
needs: [tag]
steps:
- uses: actions/checkout@v4
- name: Download Version Artifact
uses: actions/download-artifact@v4
with:
name: version
path: temp
- name: Download WebApp Artifact
uses: actions/download-artifact@v4
with:
name: webapp
path: .
- name: Read Version
run: |
version=$(cat temp/version.txt)
echo $version
echo "tag=v$version" >> $GITHUB_ENV
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.tag }}
files: |
webapp.zip
./**/*.dmg
./**/*.zip
./**/*.exe
./**/*.pkg
./**/*.deb
./**/*.ipa
./**/*.AppImage
./**/*.snap
clear:
needs:
- release
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Clean Artifact
uses: geekyeggo/delete-artifact@v4
with:
token: ${{ github.token }}
name: |
dist
version
webapp