-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (83 loc) · 2.28 KB
/
build_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
name: Build and Publish
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: "0 16 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
need_publish: ${{ steps.diff.outputs.is_diff || '0' }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: pnpm
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Cache Dist
uses: actions/cache@v4
with:
path: ./dist
key: ${{ runner.os }}-artalk-community-dist-cache
- name: Build
run: pnpm build
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-dist
path: |
dist
if-no-files-found: error
retention-days: 1
- if: ${{ github.repository == 'ArtalkJS/Community' && github.ref == 'refs/heads/master' }}
name: Diff dist
id: diff
run: pnpm diff:dist
publish:
if: ${{ needs.build.outputs.need_publish == '1' }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-dist
path: dist
- name: Tagging
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
gh release delete latest --yes || true
git push origin :refs/tags/latest || true
git tag -f latest
git push -f origin latest
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: latest
files: |
dist/**
fail_on_unmatched_files: true
draft: false
- name: Trigger Netlify Rebuild
run: |
curl -X POST -d {} "${{ secrets.DOCS_NETLIFY_BUILD_WEBHOOK_URL }}"