Skip to content

check arm

check arm #24

Workflow file for this run

name: Cedar-agent cross-build and Docker Build
on: push
# release:
# types: [published]
env:
# The project name specified in Cargo.toml
PROJECT_NAME: cedar-agent
jobs:
build-cross-package:
# Set the job to run on the platform specified by the matrix below
runs-on: ${{ matrix.runner }}
# Define the build matrix for cross-compilation
strategy:
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: linux-arm64
runner: ubuntu-latest
target: aarch64-unknown-linux-gnu
# ------- Lets keep this commented out for now for future optional use
# - name: win-amd64
# runner: windows-latest
# target: x86_64-pc-windows-msvc
# - name: macos-amd64
# runner: macos-latest
# target: x86_64-apple-darwin
# - name: macos-arm64
# runner: macos-latest
# target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- uses: actions-rs/toolchain@v1
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
with:
toolchain: stable
target: aarch64-unknown-linux-gnu
override: true
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Update Cargo.toml version
run: |
if [[ "${{ matrix.runner }}" == "macos-latest" ]]; then
sed -i '' '/\[package\]/,/^version = /s/^version = .*/version = "${{ github.event.release.tag_name }}"/' Cargo.toml
cat Cargo.toml
fi
if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then
#sed -i '/\[package\]/,/^version = /s/^version = .*/version = \"${{ github.event.release.tag_name }}\"/' Cargo.toml
sed -i '/\[package\]/,/^version = /s/^version = .*/version = \"1.1.1\"/' Cargo.toml
cat Cargo.toml
fi
- name: Prepare for ARM64
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build Binary
if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
run: cargo build --verbose --release --target ${{ matrix.target }} # --locked have been removed to avoid error
- name: Build ARM64
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --all --release --target=aarch64-unknown-linux-musl
- name: Dry run cargo publish
run: cargo publish --dry-run --allow-dirty --target ${{ matrix.target }}
# - uses: taiki-e/upload-rust-binary-action@v1
# with:
# bin: cedar-agent-${{ github.event.release.tag_name }}
# token: ${{ secrets.TOKEN_GITHUB }}
# - name: Publish package to crates.io
# run: cargo publish --token ${CRATES_TOKEN}
# env:
# CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# docker-build-push:
# runs-on: ubuntu-latest
# timeout-minutes: 70
# needs: build-cross-package
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to DockerHub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Build & Push cedar-agent
# uses: docker/build-push-action@v4
# with:
# file: Dockerfile
# platforms: linux/amd64,linux/arm64
# push: true
# cache-from: type=registry,ref=permitio/cedar-agent:latest
# cache-to: type=inline
# tags: |
# permitio/cedar-agent:latest
# permitio/cedar-agent:${{ github.event.release.tag_name }}