Skip to content

refactor(mpm): Use cross-rs for arm64 builds instead of QEMU #19

refactor(mpm): Use cross-rs for arm64 builds instead of QEMU

refactor(mpm): Use cross-rs for arm64 builds instead of QEMU #19

Workflow file for this run

name: Publish mpm binary
on:
push:
tags:
- 'mpm-v*'
paths:
- 'utils/mpm/**'
- 'utils/mows-common-rust/**'
- '.github/workflows/publish-mpm.yml'
pull_request:
paths:
- 'utils/mpm/**'
- 'utils/mows-common-rust/**'
- '.github/workflows/publish-mpm.yml'
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (do not publish release)'
required: false
default: 'false'
type: boolean
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
utils/mpm/target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('utils/mpm/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-test-
- name: Run unit tests
run: |
cd utils/mpm
cargo test --release
- name: Build release binary for e2e tests
run: |
cd utils/mpm
cargo build --release
- name: Run e2e tests
run: |
cd utils/mpm/tests
# Skip flaky tests that have CI-specific issues (Docker ports, network)
SKIP_TESTS="test-compose-up,test-self-update,test-compose-cd" ./run-all.sh
env:
MPM_BIN: ${{ github.workspace }}/utils/mpm/target/release/mpm
build:
needs: test
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
target: x86_64-unknown-linux-musl
os_name: linux
- arch: arm64
target: aarch64-unknown-linux-musl
os_name: linux
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
utils/mpm/target
key: ${{ runner.os }}-cargo-${{ matrix.arch }}-${{ hashFiles('utils/mpm/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.arch }}-
- name: Build static binary
env:
GIT_HASH: ${{ github.sha }}
GIT_DATE: ${{ github.event.head_commit.timestamp }}
CROSS_CONTAINER_IN_CONTAINER: "true"
run: |
cd utils/mpm
cross build --release --target ${{ matrix.target }}
mkdir -p dist
cp target/${{ matrix.target }}/release/mpm dist/
- name: Get version from tag
id: get_version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#mpm-v}"
else
VERSION="dev"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Rename binary with version and platform
run: |
cd utils/mpm/dist
mv mpm mpm-${{ steps.get_version.outputs.version }}-${{ matrix.os_name }}-${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: mpm-${{ matrix.os_name }}-${{ matrix.arch }}
path: utils/mpm/dist/mpm-*
release:
needs: build
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && github.event.inputs.dry_run != 'true'
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Get version from tag
id: get_version
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#mpm-v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Create checksums
run: |
cd artifacts
for f in mpm-*; do
sha256sum "$f" > "${f}-checksum-sha256.txt"
done
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: mpm v${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
files: |
artifacts/mpm-*
generate_release_notes: true