Skip to content

Fix ImageMagick configuration paths and version addendum formatting #340

Fix ImageMagick configuration paths and version addendum formatting

Fix ImageMagick configuration paths and version addendum formatting #340

Workflow file for this run

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@v4
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@v7
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@v7
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@v4
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@v2
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@v7
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@v7
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');