-
Notifications
You must be signed in to change notification settings - Fork 65
153 lines (134 loc) · 5.44 KB
/
build.yml
File metadata and controls
153 lines (134 loc) · 5.44 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
name: local Build
on:
workflow_dispatch:
inputs:
abi:
description: "Select target ABI for the build"
required: false
default: "all"
options:
- all
- arm64-v8a
- armeabi-v7a
- x86
- x86_64
pull_request:
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
abi: ${{ (github.event.inputs.abi == 'all' || github.event.inputs.abi == '' || github.event.inputs.abi == null) && fromJson('["arm64-v8a", "armeabi-v7a", "x86", "x86_64"]') || fromJson(format('["{0}"]', github.event.inputs.abi)) }}
fail-fast: false
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: nttld/setup-ndk@v1
with:
ndk-version: r27c
- name: Set ABI environment variable
run: |
echo "ABI=${{ matrix.abi }}" >> $env:GITHUB_ENV
- name: Configure Build ABI
run: |
Write-Host "Setting ABI to $env:ABI"
$file = "Application.mk"
$line = "APP_ABI := $env:ABI"
# Read the file and replace or add the line
$content = Get-Content $file
$content = $content -replace "APP_ABI :=.*", $line
if ($content -eq (Get-Content $file)) {
$content += $line
}
# Write the modified content back to the file
$content | Set-Content $file
# This must be run as cmd /c to redirect output properly
# because powershell considers stderr an error and doesn't
# log it into the output properly
- name: Build Static Library
id: build-static
continue-on-error: true
run: |
# Build the static library using build-release
cmd /c "build-release 2> errors-static-${{ matrix.abi }}.txt"
# Move static library files to the appropriate directory
mv jniLibs static_libs
- name: Build Shared Library
id: build-shared
continue-on-error: true
run: |
# Change to shared library mode before building
./.github-deps/change-to-shared-lib.ps1
# Build the shared library using build-release
cmd /c "build-release 2> errors-shared-${{ matrix.abi }}.txt"
# Move static library files to the appropriate directory
mv jniLibs shared_libs
- name: Set error-log to var (Static Build)
uses: actions/github-script@v9
id: error-log-static
if: steps.build-static.outcome != 'success'
with:
script: |
const fs = require('fs');
return fs.readFileSync('errors-static-${{ matrix.abi }}.txt', 'utf8').toString();
result-encoding: string
- name: Set error-log to var (Shared Build)
uses: actions/github-script@v9
id: error-log-shared
if: steps.build-shared.outcome != 'success'
with:
script: |
const fs = require('fs');
return fs.readFileSync('errors-shared-${{ matrix.abi }}.txt', 'utf8').toString();
result-encoding: string
- name: Collect and Organize Binaries
if: github.event.inputs.abi == 'all' || github.event.inputs.abi != 'all'
run: |
New-Item -ItemType Directory -Path all_libs/static -Force
New-Item -ItemType Directory -Path all_libs/shared -Force
Move-Item -Path static_libs/*/* -Destination all_libs/static/ -Force -ErrorAction SilentlyContinue
Move-Item -Path shared_libs/*/* -Destination all_libs/shared/ -Force -ErrorAction SilentlyContinue
- name: Upload Artifacts
uses: actions/upload-artifact@v7
if: steps.build-static.outcome == 'success' || steps.build-shared.outcome == 'success'
with:
name: imagemagick-7-android-${{ matrix.abi }}
path: all_libs
- uses: mshick/add-pr-comment@v3
name: Add error log to PR
if: github.event_name == 'pull_request' && (steps.build-static.outcome != 'success' || steps.build-shared.outcome != 'success')
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
message: |
The build just failed compilation :weary:
Here is the error log from the build :confused: Please check it and fix any problems in your code :open_mouth:
<details>
<summary>Expand Stderr Log (Static)</summary>
${{ steps.error-log-static.outputs.result }}
</details>
<details>
<summary>Expand Stderr Log (Shared)</summary>
${{ steps.error-log-shared.outputs.result }}
</details>
- name: Static build errors
if: steps.build-static.outcome != 'success'
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
if (fs.existsSync('errors-static-${{ matrix.abi }}.txt')) {
console.log(fs.readFileSync('errors-static-${{ matrix.abi }}.txt', 'utf8').toString());
}
core.setFailed('Build failed');
- name: Shared build errors
if: steps.build-shared.outcome != 'success'
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
if (fs.existsSync('errors-shared-${{ matrix.abi }}.txt')) {
console.log(fs.readFileSync('errors-${{ matrix.abi }}.txt', 'utf8').toString());
}
core.setFailed('Build failed');