Repository navigation
159 lines (141 loc) 路 5.02 KB
/
Copy pathbuild.yml
File metadata and controls
159 lines (141 loc) 路 5.02 KB
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
name: PR Build
on:
pull_request:
types: [opened, synchronize, reopened]
# packages/muya (TS v2) does not affect the electron desktop build.
# Skip the multi-platform installer build on muya-only PRs.
paths-ignore:
- 'packages/muya/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run-on-pr-head:
permissions:
pull-requests: read
actions: read
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: linux
os: ubuntu-latest
platform: linux
- name: windows-x64
os: windows-latest
platform: windows
arch: x64
- name: windows-arm64
os: windows-11-arm
platform: windows
arch: arm64
- name: macos-x64
os: macos-15-intel
platform: macos
arch: x64
- name: macos-arm64
os: macos-15
platform: macos
arch: arm64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Linux Build Dependencies
if: matrix.platform == 'linux'
run: sudo apt-get update && sudo apt-get install -y icnsutils graphicsmagick xz-utils libx11-dev libxkbfile-dev gnome-keyring libsecret-1-dev libfontconfig-dev rpm
- uses: ./.github/actions/setup
# Must be set before postinstall runs electron-rebuild
- name: Set C++20 for MacOS
if: matrix.platform == 'macos'
run: |
echo "CXXFLAGS=-std=gnu++20 -stdlib=libc++" >> $GITHUB_ENV
# Run the full postinstall: Electron binary download, patch-package,
# electron-rebuild, and minify-locales.
- name: Run postinstall
run: pnpm tsx scripts/postinstall.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm_config_user_agent: 'pnpm'
USE_ELECTRON_CLANG: ${{ matrix.platform == 'linux' && '0' || '' }}
- name: build-linux
if: matrix.platform == 'linux'
run: pnpm run build:linux
- name: build-mac
if: matrix.platform == 'macos'
run: pnpm run build:mac:${{ matrix.arch }}
- name: build-win
if: matrix.platform == 'windows'
run: pnpm run build:win:${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: marktext-${{ matrix.name }}
retention-days: 30
path: |
dist/*.exe
dist/*.zip
dist/*.dmg
dist/*.AppImage
dist/*.snap
dist/*.deb
dist/*.rpm
dist/*.tar.gz
if-no-files-found: error
comment-on-pr:
name: Comment artifact links on PR
needs: run-on-pr-head
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
pull-requests: write
actions: read
steps:
- name: Build comment body from artifacts
id: build
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const run_id = context.runId;
const pr_number = context.payload.pull_request.number;
const { data } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id,
per_page: 100
});
if (!data.artifacts.length) {
core.setOutput('body', 'No artifacts were uploaded.');
} else {
const rows = data.artifacts.map(a => {
const artifactPage = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${run_id}/artifacts/${a.id}`;
const sizeMB = (a.size_in_bytes / 1024 / 1024).toFixed(1);
return `| ${a.name} | ${sizeMB} MB | [Download](${artifactPage}) |`;
}).join('\n');
const body = [
`Build artifacts for PR #${pr_number}:`,
'',
`Run: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${run_id}`,
'',
'| Artifact | Size | Link |',
'|---|---:|---|',
rows
].join('\n');
core.setOutput('body', body);
}
- name: Find existing artifact comment
id: find-comment
uses: peter-evans/find-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-includes: 'Build artifacts for PR'
- name: Post or update PR comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: ${{ steps.build.outputs.body }}
edit-mode: replace