-
Notifications
You must be signed in to change notification settings - Fork 1.8k
151 lines (124 loc) Β· 4.74 KB
/
pr-build-artifacts.yml
File metadata and controls
151 lines (124 loc) Β· 4.74 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
name: Build PR Artifacts
on:
pull_request:
types: [opened, synchronize, reopened]
permissions: {}
env:
NODE_VERSION: "24.x"
jobs:
check-permissions:
permissions:
contents: read
if: github.event.pull_request.draft == false
name: Check if user has write access
runs-on: ubuntu-latest
outputs:
has-write-access: ${{ steps.check.outputs.require-result }}
steps:
- name: Check user permission
id: check
uses: actions-cool/check-user-permission@7b90a27f92f3961b368376107661682c441f6103
with:
require: write
username: ${{ github.event.pull_request.user.login }}
build:
name: Build ${{ matrix.os }}
needs: check-permissions
if: needs.check-permissions.outputs.has-write-access == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
version: 10
run_install: false
- name: Setup NodeJS
if: startsWith(matrix.os, 'macOS') != true
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Setup NodeJS for macOS
if: startsWith(matrix.os, 'macOS')
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build on macOS
if: startsWith(matrix.os, 'macOS')
run: |
pnpm dist:mac
pnpm dist:mac:arm64
- name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo snap install snapcraft --classic
sudo apt update
sudo apt install -y flatpak flatpak-builder
sudo flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y flathub org.freedesktop.Platform/x86_64/24.08
sudo flatpak install -y flathub org.freedesktop.Sdk/x86_64/24.08
sudo flatpak install -y flathub org.electronjs.Electron2.BaseApp/x86_64/24.08
- name: Build on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
pnpm dist:linux
pnpm dist:linux:deb-arm64
pnpm dist:linux:rpm-arm64
- name: Build on Windows
if: startsWith(matrix.os, 'windows')
run: |
pnpm dist:win
- name: Upload artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: build-artifacts-${{ matrix.os }}
path: pack/
retention-days: 7
if-no-files-found: error
comment:
name: Comment on PR
needs: [check-permissions, build]
if: always() && needs.check-permissions.outputs.has-write-access == 'true'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Create comment
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
with:
script: |
const runId = context.runId;
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
const buildResult = '${{ needs.build.result }}';
let comment;
if (buildResult === 'success') {
comment = `## π Build Artifacts Ready!
The builds have completed successfully. You can download the artifacts from the workflow run:
**[π¦ Download Artifacts](${runUrl})**
### Available builds:
- **Windows**: \`build-artifacts-windows-latest\`
- **macOS**: \`build-artifacts-macos-latest\`
- **Linux**: \`build-artifacts-ubuntu-latest\`
*Note: Artifacts are available for 7 days.*`;
} else if (buildResult === 'failure') {
comment = `## β Build Failed
Unfortunately, one or more builds failed. Please check the workflow run for details:
**[View Workflow Run](${runUrl})**`;
} else {
comment = `## β οΈ Build Status: ${buildResult}
The build process completed with status: **${buildResult}**
**[View Workflow Run](${runUrl})**`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});