Files
2026-09-07 17:35:23 +05:00

262 lines
8.6 KiB
YAML

name: Build Probe
on:
push:
branches: [ master ]
tags: [ 'probe-v*.*.*' ]
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-probe
OPENWRT_ARM64_ARCHES: aarch64_generic aarch64_cortex-a53 aarch64_cortex-a72
jobs:
validate:
uses: ./.github/workflows/validate-release.yml
with:
component: probe
linux-amd64:
needs: validate
name: Linux amd64 binary and .deb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- name: Install musl toolchain
run: sudo apt-get update && sudo apt-get install --yes musl-tools
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build release binary
run: cargo build --release --package probe --bin cheburprobe --target x86_64-unknown-linux-musl
- name: Name Linux amd64 release asset
run: |
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "probe") | .version')
cp target/x86_64-unknown-linux-musl/release/cheburprobe \
"target/x86_64-unknown-linux-musl/release/cheburprobe-$version-linux-amd64"
- name: Build Debian package
run: cargo deb --package probe --target x86_64-unknown-linux-musl --no-strip --no-build -- --bin cheburprobe
- name: Upload Linux amd64 binary
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-amd64
path: target/x86_64-unknown-linux-musl/release/cheburprobe-*-linux-amd64
compression-level: 0
- name: Upload Linux amd64 Debian package
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-amd64-deb
path: target/x86_64-unknown-linux-musl/debian/*.deb
compression-level: 0
linux-arm64:
needs: validate
name: Linux arm64 binary, .deb, and OpenWrt packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build release binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: "aarch64-unknown-linux-musl"
args: "--release --package probe --bin cheburprobe"
strip: true
- name: Build Debian package
run: cargo deb --package probe --target aarch64-unknown-linux-musl --no-strip --no-build -- --bin cheburprobe
- name: Name Linux arm64 release asset
run: |
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "probe") | .version')
cp target/aarch64-unknown-linux-musl/release/cheburprobe \
"target/aarch64-unknown-linux-musl/release/cheburprobe-$version-linux-arm64"
- name: Build legacy OpenWrt opkg packages
run: |
chmod +x probe/openwrt/build-ipk.sh
for arch in $OPENWRT_ARM64_ARCHES; do
OPENWRT_ARCH="$arch" probe/openwrt/build-ipk.sh \
target/aarch64-unknown-linux-musl/release/cheburprobe \
target/aarch64-unknown-linux-musl/openwrt
done
- name: Build current OpenWrt APK packages
run: |
chmod +x probe/openwrt/build-apk.sh
for arch in $OPENWRT_ARM64_ARCHES; do
docker run --rm \
--env OPENWRT_ARCH="$arch" \
--env PACKAGE_FILE_ARCH_SUFFIX=1 \
--volume "$PWD:/work" \
--workdir /work \
alpine:edge \
probe/openwrt/build-apk.sh \
target/aarch64-unknown-linux-musl/release/cheburprobe \
target/aarch64-unknown-linux-musl/openwrt
done
- name: Upload Linux arm64 binary
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-arm64
path: target/aarch64-unknown-linux-musl/release/cheburprobe-*-linux-arm64
compression-level: 0
- name: Upload Linux arm64 Debian package
uses: actions/upload-artifact@v7
with:
name: cheburprobe-linux-arm64-deb
path: target/aarch64-unknown-linux-musl/debian/*.deb
compression-level: 0
- name: Upload OpenWrt arm64 and LuCI packages
uses: actions/upload-artifact@v7
with:
name: cheburprobe-openwrt-arm64-packages
path: |
target/aarch64-unknown-linux-musl/openwrt/*.apk
target/aarch64-unknown-linux-musl/openwrt/*.ipk
compression-level: 0
windows-amd64:
needs: validate
name: Windows amd64 binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --package probe --bin cheburprobe
- name: Name Windows release asset
shell: pwsh
run: |
$metadata = cargo metadata --no-deps --format-version 1 | ConvertFrom-Json
$version = ($metadata.packages | Where-Object name -eq 'probe').version
Copy-Item target/release/cheburprobe.exe "target/release/cheburprobe-$version-windows-x86_64.exe"
- name: Upload Windows amd64 binary
uses: actions/upload-artifact@v7
with:
name: cheburprobe-windows-amd64
path: target/release/cheburprobe-*-windows-x86_64.exe
compression-level: 0
docker:
needs: validate
name: Docker image amd64/arm64
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
id: setup-buildx
uses: docker/setup-buildx-action@v4
- name: Cache Rust Docker build mounts
id: rust-build-cache
uses: actions/cache@v4
with:
path: rust-build-cache
key: ${{ runner.os }}-probe-docker-rust-${{ hashFiles('**/Cargo.lock', 'probe/Dockerfile') }}
restore-keys: |
${{ runner.os }}-probe-docker-rust-
- name: Restore Rust Docker build cache
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.setup-buildx.outputs.name }}
cache-map: |
{
"rust-build-cache/probe-target": {
"target": "/build/target",
"id": "probe-target"
},
"rust-build-cache/cargo-registry": {
"target": "/usr/local/cargo/registry",
"id": "cargo-registry"
},
"rust-build-cache/cargo-git": {
"target": "/usr/local/cargo/git",
"id": "cargo-git"
}
}
skip-extraction: ${{ steps.rust-build-cache.outputs.cache-hit }}
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ needs.validate.outputs.version }},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.validate.outputs.version }},enable=${{ github.ref_type == 'tag' }}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./probe/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
needs: [linux-amd64, linux-arm64, windows-amd64, docker]
if: github.event_name == 'push' && github.ref_type == 'tag'
permissions:
contents: write
actions: read
uses: ./.github/workflows/release.yml
with:
component: probe
artifact-pattern: 'cheburprobe-*'