Skip to content

Publish ninja-build static binary for Linux (2/n) #6

Publish ninja-build static binary for Linux (2/n)

Publish ninja-build static binary for Linux (2/n) #6

##########################################################################
# File: dkcoder\.github\workflows\ninja-build-static.yml #
# #
# Copyright 2024 Diskuv, Inc. #
# #
# Licensed under the Open Software License version 3.0 #
# (the "License"); you may not use this file except in compliance #
# with the License. You may obtain a copy of the License at #
# #
# https://opensource.org/license/osl-3-0-php/ #
# #
##########################################################################
name: Publish ninja-build as a static binary
on:
push:
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# We aren't use cross-compilation. Instead we have multiple platforms
# with QEMU emulation providing a native environment. An alternative
# is to use CMake to build Ninja with a cross-compiler.
- name: Build linux/amd64 and export to filesystem
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
file: ci/ninja-build-static/Dockerfile
outputs: type=local,dest=out-amd64
- name: Build linux/arm64 and export to filesystem
uses: docker/build-push-action@v6
with:
platforms: linux/arm64
file: ci/ninja-build-static/Dockerfile
outputs: type=local,dest=out-arm64
- name: Build linux/386 and export to filesystem
uses: docker/build-push-action@v6
with:
platforms: linux/386
file: ci/ninja-build-static/Dockerfile
outputs: type=local,dest=out-386
- name: Test 386 binary outside container
run: out-386/usr/local/src/ninja-build/ninja --version
- name: Test amd64 binary outside container
run: out-amd64/usr/local/src/ninja-build/ninja --version
- name: Display arm64 binary format
# Can't run arm64 on Intel machines without an emulator
run: file out-arm64/usr/local/src/ninja-build/ninja
- name: Rename to ABI
run: |
mv out-amd64/usr/local/src/ninja-build/ninja ninja-linux_x86_64
mv out-386/usr/local/src/ninja-build/ninja ninja-linux_x86
mv out-arm64/usr/local/src/ninja-build/ninja ninja-linux_arm64
- name: Upload ninja binaries for troubleshooting
uses: actions/upload-artifact@v4
with:
retention-days: 30
name: ninja-binary
path: |
ninja-linux_x86_64
ninja-linux_x86
ninja-linux_arm64
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
ninja-linux_x86_64
ninja-linux_x86
ninja-linux_arm64