Skip to content

Commit e491da3

Browse files
committed
feat: add github action for auto build, deploy and release
1 parent 9221341 commit e491da3

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build, Deploy and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Build project
34+
run: npm run build
35+
36+
- name: Upload Artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: live2d-widget-dist
40+
path: dist/
41+
42+
# 1. Deploy demo to GitHub Pages
43+
- name: Deploy Demo
44+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
45+
uses: peaceiris/actions-gh-pages@v3
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
publish_dir: ./
49+
# Peaceiris action handles adding the built 'dist' even if it's ignored in .gitignore
50+
# because we are publishing the directory after the build step.
51+
52+
# 2. Create Release and Upload Assets (on tag)
53+
- name: Archive dist for release
54+
if: startsWith(github.ref, 'refs/tags/v')
55+
run: |
56+
zip -r live2d-widget-dist.zip dist/
57+
58+
- name: Create Release
59+
if: startsWith(github.ref, 'refs/tags/v')
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
files: live2d-widget-dist.zip
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)