forked from LedgerHQ/ledger-live
-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (165 loc) · 6.11 KB
/
build-desktop-external-reusable.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: "@Desktop • Build App (external)"
on:
workflow_call:
inputs:
ref:
type: string
description: |
If you run this manually, and want to run on a PR, the correct ref should be refs/pull/{PR_NUMBER}/merge to
have the "normal" scenario involving checking out a merge commit between your branch and the base branch.
If you want to run only on a branch or specific commit, you can use either the sha or the branch name instead (prefer the first verion for PRs).
required: true
repository:
description: The repository to checkout the code from
type: string
required: true
jobs:
build-desktop-app:
strategy:
matrix:
config:
[
{ name: "linux", os: "ubuntu-22.04", image: "linux-x86_64.AppImage" },
{ name: "win", os: "windows-2022", dotnet: true, image: "win-x64.exe" },
{ name: "mac", os: "macos-14", image: "mac.dmg" },
]
runs-on: ${{ matrix.config.os }}
name: "Build LLD (external) | ${{ matrix.config.name }}"
outputs:
linux: ${{ steps.save-result.outputs.linux }}
windows: ${{ steps.save-result.outputs.win }}
mac: ${{ steps.save-result.outputs.mac }}
env:
NODE_OPTIONS: "--max-old-space-size=7168"
steps:
- name: Format os name
id: os
uses: actions/github-script@v7
with:
result-encoding: string
script: |
if ("${{ matrix.config.name }}" === "linux") {
return "linux"
} else if ("${{ matrix.config.name }}" === "mac") {
return "mac"
} else if ("${{ matrix.config.name }}" === "win") {
return "win"
}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup git user
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-git-user@develop
- uses: actions/setup-python@v4
with:
python-version: "3.13.0"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true
- name: Setup the caches
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-caches@develop
id: setup-caches
with:
install-proto: true
- name: Build desktop
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-build-desktop@develop
id: build-desktop
with:
os: ${{ steps.os.outputs.result }}
- name: Build the app
id: build-app
run: pnpm build:lld
- name: Save result
id: save-result
shell: bash
if: ${{ !cancelled() }}
run: |
echo "${{matrix.config.name}}=${{steps.build-app.outcome}}" >> $GITHUB_OUTPUT
- name: Upload app
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build-desktop.outputs.version }}-${{ matrix.config.image }}
path: ${{ github.workspace }}/apps/ledger-live-desktop/dist/${{ steps.build-desktop.outputs.name }}-${{ steps.build-desktop.outputs.version }}-${{ matrix.config.image }}
report:
needs: build-desktop-app
runs-on: ubuntu-22.04
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/github-script@v7
name: Get statuses of runs
id: status
with:
script: |
const fs = require("fs");
const [ owner, repo ] = "${{ github.repository }}".split("/");
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRunAttempt, {
owner,
repo,
run_id: "${{ github.run_id }}",
attempt_number: "${{ github.run_attempt }}",
});
const findJobUrl = os =>
jobs.find(job => job.name == `Build LLD (external) | ${os}`)?.html_url;
const keys = {
mac: {
symbol: "🍏",
name: "macOS",
jobUrl: findJobUrl("mac")
},
windows: {
symbol: "🪟",
name: "Windows",
jobUrl: findJobUrl("win")
},
linux: {
symbol: "🐧",
name: "Linux",
jobUrl: findJobUrl("linux")
},
};
const report = {
mac: {
pass: ${{ needs.build-desktop-app.outputs.mac == 'success' }},
status: "${{ needs.build-desktop-app.outputs.mac }}",
},
linux: {
pass: ${{ needs.build-desktop-app.outputs.linux == 'success' }},
status: "${{ needs.build-desktop-app.outputs.linux }}",
},
windows: {
pass: ${{ needs.build-desktop-app.outputs.windows == 'success' }},
status: "${{ needs.build-desktop-app.outputs.windows }}",
},
};
let summary = ``;
summary += `|`
const reportKeys = Object.keys(report);
reportKeys.forEach((k) => {
summary += ` [${keys[k].symbol} ${keys[k].name}](${keys[k].jobUrl}) |`;
});
summary += `
|`;
for (let i = 0; i < reportKeys.length; i++) {
summary += ` :--: |`;
}
summary += `
|`;
Object.entries(report).forEach(([os, values]) => {
summary += ` ${values.pass ? "✅" : "❌"} (${values.status}) |`;
});
summary += `
[⚙️ Summary](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }})
`;
const data = {
summary,
}
fs.writeFileSync("summary.json", JSON.stringify(data), "utf-8");
- uses: actions/upload-artifact@v4
name: Upload output
with:
path: ${{ github.workspace }}/summary.json
name: summary.json