mirror of
https://github.com/radareorg/github-actions.git
synced 2026-11-08 07:28:13 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c4ee73104 | ||
|
|
1f8ec6aa3c | ||
|
|
1a2aa12b7a |
No files matched your search
@@ -7,7 +7,7 @@ Composite GitHub Action to install radare2 in CI workflows. Supports Linux, macO
|
||||
Reference the action from your workflow:
|
||||
|
||||
```yaml
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
```
|
||||
|
||||
## Inputs
|
||||
@@ -31,14 +31,14 @@ Reference the action from your workflow:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
```
|
||||
|
||||
### Install a specific version
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
with:
|
||||
version: '6.1.2'
|
||||
```
|
||||
@@ -47,7 +47,7 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
with:
|
||||
from-git: true
|
||||
```
|
||||
@@ -56,7 +56,7 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
with:
|
||||
version: '6.1.2'
|
||||
from-git: true
|
||||
@@ -66,7 +66,7 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
with:
|
||||
from-git: true
|
||||
prefix: '/opt/radare2'
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
id: r2
|
||||
- name: Build with Make
|
||||
if: matrix.build_system == 'make'
|
||||
@@ -118,7 +118,7 @@ jobs:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: radareorg/github-actions@v1
|
||||
- uses: radareorg/github-actions@v2
|
||||
id: r2
|
||||
- run: echo "Installed r2 ${{ steps.r2.outputs.version }} at ${{ steps.r2.outputs.prefix }}"
|
||||
```
|
||||
|
||||
+53
-25
@@ -14,14 +14,14 @@ inputs:
|
||||
required: false
|
||||
default: 'false'
|
||||
prefix:
|
||||
description: 'Installation prefix'
|
||||
description: 'Installation prefix. Linux and macOS release packages install to /usr.'
|
||||
required: false
|
||||
default: '/usr'
|
||||
|
||||
outputs:
|
||||
version:
|
||||
description: 'Installed radare2 version'
|
||||
value: ${{ steps.resolve.outputs.r2v }}
|
||||
value: ${{ steps.verify.outputs.version }}
|
||||
prefix:
|
||||
description: 'Installation prefix'
|
||||
value: ${{ steps.prefix.outputs.prefix }}
|
||||
@@ -49,6 +49,18 @@ runs:
|
||||
fi
|
||||
echo "r2v=$R2V" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Validate release prefix
|
||||
if: inputs.from-git != 'true' && runner.os != 'Windows'
|
||||
shell: bash
|
||||
env:
|
||||
R2_PREFIX: ${{ inputs.prefix }}
|
||||
run: |
|
||||
PREFIX="${R2_PREFIX:-/usr}"
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
echo "::error::Custom prefixes are only supported for git builds on Unix; release packages install to /usr"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- BUILD FROM GIT (Unix) ---
|
||||
- name: Build from git (Unix)
|
||||
if: inputs.from-git == 'true' && runner.os != 'Windows'
|
||||
@@ -58,16 +70,21 @@ runs:
|
||||
R2_PREFIX: ${{ inputs.prefix }}
|
||||
run: |
|
||||
set -e
|
||||
CLONEARGS="--depth=1"
|
||||
BUILD_DIR="$(mktemp -d "${RUNNER_TEMP:-/tmp}/r2build.XXXXXX")"
|
||||
trap 'rm -rf "$BUILD_DIR"' EXIT
|
||||
|
||||
CLONEARGS=(--depth=1)
|
||||
if [ -n "$R2V" ]; then
|
||||
CLONEARGS="$CLONEARGS --branch $R2V"
|
||||
CLONEARGS+=(--branch "$R2V")
|
||||
fi
|
||||
git clone $CLONEARGS https://github.com/radareorg/radare2.git /tmp/_r2build
|
||||
cd /tmp/_r2build
|
||||
git clone "${CLONEARGS[@]}" https://github.com/radareorg/radare2.git "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
INSTALL_PREFIX="${R2_PREFIX:-/usr}"
|
||||
export CFLAGS="-O2 -Wno-unused-result"
|
||||
./sys/install.sh "$R2_PREFIX"
|
||||
cd /
|
||||
rm -rf /tmp/_r2build
|
||||
./sys/install.sh --install "--prefix=$INSTALL_PREFIX"
|
||||
if [ -d "$INSTALL_PREFIX/bin" ]; then
|
||||
echo "$INSTALL_PREFIX/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
|
||||
# --- BUILD FROM GIT (Windows) ---
|
||||
- name: Build from git (Windows)
|
||||
@@ -80,21 +97,26 @@ runs:
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$cloneArgs = @('clone', '--depth=1')
|
||||
if ($env:R2V) { $cloneArgs += @('--branch', $env:R2V) }
|
||||
$buildDir = Join-Path $env:RUNNER_TEMP '_r2build'
|
||||
& git @cloneArgs 'https://github.com/radareorg/radare2.git' $buildDir
|
||||
Set-Location $buildDir
|
||||
pip install meson ninja
|
||||
$prefix = $env:R2_PREFIX
|
||||
if (-not $prefix -or $prefix -eq '/usr') {
|
||||
$prefix = Join-Path $env:RUNNER_TEMP 'radare2'
|
||||
$buildDir = Join-Path $env:RUNNER_TEMP ([System.IO.Path]::GetRandomFileName())
|
||||
try {
|
||||
& git @cloneArgs 'https://github.com/radareorg/radare2.git' $buildDir
|
||||
Set-Location $buildDir
|
||||
pip install meson ninja
|
||||
$prefix = $env:R2_PREFIX
|
||||
if (-not $prefix -or $prefix -eq '/usr') {
|
||||
$prefix = Join-Path $env:RUNNER_TEMP 'radare2'
|
||||
}
|
||||
meson setup --buildtype=release --prefix="$prefix" build
|
||||
ninja -C build
|
||||
ninja -C build install
|
||||
$resolvedBin = (Resolve-Path "$prefix\bin").Path
|
||||
$resolvedBin | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
|
||||
} finally {
|
||||
Set-Location $env:RUNNER_TEMP
|
||||
if (Test-Path $buildDir) {
|
||||
Remove-Item -Path $buildDir -Recurse -Force
|
||||
}
|
||||
}
|
||||
meson setup --buildtype=release --prefix="$prefix" build
|
||||
ninja -C build
|
||||
ninja -C build install
|
||||
$resolvedBin = (Resolve-Path "$prefix\bin").Path
|
||||
$resolvedBin | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
|
||||
Set-Location $env:RUNNER_TEMP
|
||||
Remove-Item -Path $buildDir -Recurse -Force
|
||||
|
||||
# --- INSTALL FROM RELEASE (Linux) ---
|
||||
- name: Install from release (Linux)
|
||||
@@ -174,7 +196,7 @@ runs:
|
||||
env:
|
||||
R2_PREFIX: ${{ inputs.prefix }}
|
||||
run: |
|
||||
PREFIX="$R2_PREFIX"
|
||||
PREFIX="${R2_PREFIX:-/usr}"
|
||||
if [ "$RUNNER_OS" = "Windows" ] && [ "$PREFIX" = "/usr" ]; then
|
||||
PREFIX="$RUNNER_TEMP/radare2"
|
||||
fi
|
||||
@@ -182,5 +204,11 @@ runs:
|
||||
|
||||
# --- VERIFY ---
|
||||
- name: Verify installation
|
||||
id: verify
|
||||
shell: bash
|
||||
run: radare2 -v
|
||||
run: |
|
||||
set -e
|
||||
R2_VERSION_OUTPUT="$(radare2 -v)"
|
||||
printf '%s\n' "$R2_VERSION_OUTPUT"
|
||||
R2_VERSION="$(printf '%s\n' "$R2_VERSION_OUTPUT" | awk 'NR == 1 { print $2 }')"
|
||||
echo "version=$R2_VERSION" >> "$GITHUB_OUTPUT"
|
||||
Reference in new issue
Block a user