forked from siyuan-note/siyuan
-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (136 loc) · 5.81 KB
/
cd.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CD For SiYuan
on:
push:
tags:
- '*-dev*'
workflow_dispatch:
# ref https://docs.github.com/zh/actions/learn-github-actions/variables
env:
repo_name_android: "siyuan-android"
repo_name: "siyuan"
repo_owner: "siyuan-note"
package_json: "app/package.json"
jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_version: ${{ steps.release_info.outputs.release_version }}
version: ${{ steps.version.outputs.value }}
packageManager: ${{ steps.packageManager.outputs.value }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install PyGithub
- id: thisLatestRelease
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
excludes: prerelease, draft
- name: Extract version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq .version ${{ env.package_json }} -r'
- name: Extract electronVersion from package.json
uses: sergeysova/jq-action@v2
id: electronVersion
with:
cmd: "jq .devDependencies.electron ${{ env.package_json }} -r"
- name: Extract packageManager from package.json
uses: sergeysova/jq-action@v2
id: packageManager
with:
cmd: "jq .packageManager ${{ env.package_json }} -r"
- name: Gather Release Information
id: release_info
run: |
echo "release_title=$(git show --format=%s --no-patch | head -1)" >> $GITHUB_OUTPUT
echo "release_version=$(TZ=Asia/Shanghai date +'v%Y%m%d%H%M')" >> $GITHUB_OUTPUT
changelog_header=$(python scripts/parse-changelog-HEAD.py -t ${{ github.ref }} -b ${{ steps.thisLatestRelease.outputs.release }} -e ${{ steps.electronVersion.outputs.value }} ${{ env.repo_owner }}/${{ env.repo_name }})
changelog=$(python scripts/parse-changelog.py -t ${{ github.ref }} ${{ env.repo_owner }}/${{ env.repo_name }})
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "release_body<<$EOF" >> $GITHUB_ENV
echo "$changelog_header" >> $GITHUB_ENV
echo "$changelog" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
name: ${{ steps.release_info.outputs.release_version }}
tag: ${{ github.ref }}
body: ${{ env.release_body }}
draft: false
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: windows-latest
name: windows build win.exe
needs: create_release
steps:
- uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}
- name: Set up MingGW
uses: msys2/setup-msys2@v2
with:
install: p7zip mingw-w64-x86_64-lua
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/kernel/go.mod
- run: go version
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node pnpm
run: npm install -g ${{ needs.create_release.outputs.packageManager }}
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
- name: Install Node Dependencies
run: pnpm install --no-frozen-lockfile
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
- name: Building UI
run: pnpm run build
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
- name: Remove Build Directory
uses: JesseTG/[email protected]
with:
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/build
- name: Remove Kernel Directory for Linux
uses: JesseTG/[email protected]
with:
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel-linux
- name: Remove Kernel Directory for Windows
uses: JesseTG/[email protected]
with:
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel
- name: Remove Kernel Directory for macOS
uses: JesseTG/[email protected]
with:
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel-darwin
- name: Remove Kernel Directory for macOS ARM64
uses: JesseTG/[email protected]
with:
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel-darwin-arm64
- name: Building Electron App
run: pnpm run dist
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
- name: Upload Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: siyuan-${{ needs.create_release.outputs.release_version }}-win.exe
asset_path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/build/siyuan-${{ needs.create_release.outputs.version }}-win.exe
asset_content_type: application/octet-stream