125 lines
3.7 KiB
YAML
125 lines
3.7 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact: mcl
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
artifact: mcl
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
artifact: mcl.exe
|
|
- os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
artifact: mcl
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact: mcl
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ matrix.target }}
|
|
|
|
- name: install cross-compilation deps (aarch64-linux)
|
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
sudo dpkg --add-architecture arm64
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libssl-dev:arm64
|
|
|
|
- name: install OpenSSL (linux x86_64)
|
|
if: matrix.target == 'x86_64-unknown-linux-gnu'
|
|
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
|
|
|
|
- name: build
|
|
env:
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
|
AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR: /usr/lib/aarch64-linux-gnu
|
|
AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR: /usr/include/aarch64-linux-gnu
|
|
PKG_CONFIG_ALLOW_CROSS: 1
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: package (unix)
|
|
if: runner.os != 'Windows'
|
|
run: |
|
|
cd target/${{ matrix.target }}/release
|
|
tar czf ../../../mcl-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
|
|
|
|
- name: package (windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
cd target/${{ matrix.target }}/release
|
|
Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath ../../../mcl-${{ matrix.target }}.zip
|
|
|
|
- name: upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: mcl-${{ matrix.target }}
|
|
path: mcl-${{ matrix.target }}.*
|
|
|
|
release:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: get version
|
|
id: version
|
|
run: |
|
|
version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
echo "tag=v$version" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: check if release exists
|
|
id: check
|
|
run: |
|
|
if gh release view "${{ steps.version.outputs.tag }}" > /dev/null 2>&1; then
|
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: download artifacts
|
|
if: steps.check.outputs.exists == 'false'
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: create release
|
|
if: steps.check.outputs.exists == 'false'
|
|
run: |
|
|
gh release create "${{ steps.version.outputs.tag }}" \
|
|
--title "${{ steps.version.outputs.tag }}" \
|
|
--generate-notes \
|
|
artifacts/mcl-*/*
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|