Skip to content

Fix ImageMagick configuration paths and version addendum formatting #124

Fix ImageMagick configuration paths and version addendum formatting

Fix ImageMagick configuration paths and version addendum formatting #124

Workflow file for this run

name: Handle Release
on:
workflow_dispatch:
inputs:
abi:
description: "Select target ABI for the release build"
required: false
default: "all"
options:
- all
- arm64-v8a
- armeabi-v7a
- x86
- x86_64
release:
types: [created]
pull_request:
branches: [master]
types: [closed]
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
if: |
(github.event_name == 'pull_request' && github.event.pull_request.merged == true &&
(github.actor == 'blackhat2233' || github.actor == 'molotovcherry') && github.head_ref == 'imupdate') ||
github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- uses: nttld/setup-ndk@v1
with:
ndk-version: r27c
- name: Set ABI environment variable
run: |
echo "ABI=${{ matrix.abi }}" >> $env:GITHUB_ENV
- name: Configure ABI for Release Build
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
- name: Build and Archive Static Library
run: |
./build-release
mv jniLibs static_libs || true
- name: Build and Archive Shared Library
run: |
./.github-deps/change-to-shared-lib.ps1
./build-release
mv jniLibs shared_libs || true
- 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
Compress-Archive -CompressionLevel Optimal -Path all_libs -DestinationPath "imagemagick-7-android-${{ matrix.abi }}.zip"
- name: Get Latest Release Tag
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
id: tag
run: |
$dir = Get-ChildItem -Directory -Path "ImageMagick-*" | Select-Object -Last 1
$tag = ($dir | Split-Path -Leaf).Substring(12)
Write-Host "Setting new tag: $tag"
echo "TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Check if Release Tag Exists
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
id: check_release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Authenticate GitHub CLI
echo $env:GITHUB_TOKEN | gh auth login --with-token
# Check if the release exists with the given tag
$tag = "${{ env.TAG }}"
$release = $null
try {
$release = gh release view "$tag" --json id --jq .id 2>$null
} catch {
Write-Host "Failed to fetch release info, assuming release does not exist."
}
if ($release) {
Write-Host "Release tag $tag already exists."
echo "EXISTS=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
} else {
Write-Host "Release tag $tag does not exist."
echo "EXISTS=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
}
exit 0 # Ensure script exits successfully even if release does not exist
- name: Create New Release
if: env.EXISTS == 'false' && (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
uses: ncipollo/release-action@v1
with:
name: Android ImageMagick ${{ env.TAG }}
body: |
Library built using default config.
If you need a different config than default, please follow compilation instructions on the main page to manually build it (or, fork the project, change the config file, and use GitHub Actions to build it).
token: ${{ secrets.GITHUB_TOKEN }}
commit: ${{ github.sha }}
tag: ${{ env.TAG }}
# Added delay to allow the release to fully propagate before fetching info
- name: Wait for Release to Propagate
if: env.EXISTS == 'false' && (github.event_name == 'release' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
run: |
echo "Waiting for the release to fully propagate..."
sleep 30 # Wait for 30 seconds
- name: Get Latest Release Info
if: env.EXISTS == 'false' || env.EXISTS == 'true' && (github.event_name == 'release' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
id: latest_release
uses: kaliber5/action-get-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest: true
- name: Upload Artifacts to Newly Created Release
if: env.EXISTS == 'false' || env.EXISTS == 'true' && (github.event_name == 'release' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: 'imagemagick-7-android-${{ matrix.abi }}.zip'
release_id: ${{ steps.latest_release.outputs.id }}
overwrite: true
draft: false
tag_name: ${{ steps.latest_release.outputs.tag_name }}