build #2090
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
tags: | |
- "v*" | |
branches: | |
- "**" | |
paths: | |
- ".github/workflows/build.yml" | |
- "3rdparty/**" | |
- "cmake/**" | |
- "include/**" | |
- "source/**" | |
- "CMakeLists.txt" | |
pull_request: | |
branches: | |
- "**" | |
paths: | |
- ".github/workflows/build.yml" | |
- "3rdparty/**" | |
- "cmake/**" | |
- "include/**" | |
- "source/**" | |
- "CMakeLists.txt" | |
workflow_dispatch: | |
jobs: | |
meta: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: set_tag | |
run: | | |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }} | |
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true) | |
if [[ $tag != v* ]]; then | |
tag=$(curl -sX GET "https://api.github.com/repos/MaaXYZ/MaaFramework/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]') | |
if [[ $tag != v* ]]; then | |
tag="v0.0.0" | |
fi | |
tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)") | |
fi | |
if ! $($is_release) ; then | |
prefix=${tag%-*-*} | |
suffix=${tag#$prefix-} | |
tag="$prefix-ci.$suffix" | |
fi | |
echo tag=$tag | tee -a $GITHUB_OUTPUT | |
echo is_release=$is_release | tee -a $GITHUB_OUTPUT | |
outputs: | |
tag: ${{ steps.set_tag.outputs.tag }} | |
is_release: ${{ steps.set_tag.outputs.is_release }} | |
ubuntu: | |
needs: meta | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [aarch64, x86_64] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install deps | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y cmake ninja-build | |
- name: Install compiler | |
if: ${{ matrix.arch == 'x86_64' }} | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update -y | |
sudo apt-get install -y gcc-13 g++-13 | |
- name: Install cross compile toolchains | |
if: ${{ matrix.arch == 'aarch64' }} | |
run: | | |
echo "deb http://cz.archive.ubuntu.com/ubuntu mantic main" | sudo tee /etc/apt/sources.list.d/temporary-repository.list | |
sudo apt-get update -y | |
sudo apt-get install -y gcc-13-aarch64-linux-gnu g++-13-aarch64-linux-gnu | |
sudo rm /etc/apt/sources.list.d/temporary-repository.list | |
sudo apt-get update -y | |
- name: Bootstrap MaaDeps | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
python3 tools/maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux | |
- name: Build MAA | |
env: | |
CC: ${{ matrix.arch == 'x86_64' && 'gcc-13' || 'aarch64-linux-gnu-gcc-13' }} | |
CXX: ${{ matrix.arch == 'x86_64' && 'g++-13' || 'aarch64-linux-gnu-g++-13' }} | |
run: | | |
cmake --preset 'NinjaMulti' \ | |
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \ | |
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' | |
cmake --build build --preset 'NinjaMulti - Release' -j 16 | |
- name: Install | |
shell: bash | |
if: always() | |
run: | | |
cmake --install build --prefix install | |
cp -r docs install | |
cp README*.md install | |
cp -r sample install | |
cp -r LICENSE.md install | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: MAA-linux-${{ matrix.arch }} | |
path: "install" |