Move to -DCMAKE and fix CC #58
Workflow file for this run
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: | |
paths: | |
- 'rapidyenc/**' | |
- '.github/workflows/build.yml' | |
jobs: | |
build_macos: | |
name: Build macOS | |
runs-on: macos-13 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build | |
run: | | |
export ZERO_AR_DATE=1 | |
cmake -S rapidyenc -B rapidyenc/build \ | |
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ | |
-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ | |
-DCMAKE_C_COMPILER=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \ | |
-DCMAKE_CXX_COMPILER=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ \ | |
-DCMAKE_AR=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar | |
cmake --build rapidyenc/build --target rapidyenc_static -j$(sysctl -n hw.ncpu) | |
cp rapidyenc/build/rapidyenc_static/librapidyenc.a librapidyenc_darwin.a | |
- name: Upload static library | |
uses: actions/upload-artifact@v3 | |
with: | |
name: static | |
path: librapidyenc_darwin.a | |
build_windows: | |
name: Build Windows x64 | |
runs-on: windows-latest | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
update: true | |
pacboy: >- | |
gcc:p | |
cmake:p | |
ninja:p | |
- name: Build | |
run: | | |
cmake -S rapidyenc -B rapidyenc/build -G Ninja | |
cmake --build rapidyenc/build --config Release --target rapidyenc_static | |
cp rapidyenc/build/rapidyenc_static/librapidyenc.a librapidyenc_windows_amd64.a | |
- name: Upload shared library | |
uses: actions/upload-artifact@v3 | |
with: | |
name: static | |
path: librapidyenc_windows_amd64.a | |
build_linux: | |
name: Build ${{ matrix.platform }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- platform: linux/amd64 | |
library: librapidyenc_linux_amd64.a | |
- platform: linux/arm64 | |
library: librapidyenc_linux_arm64.a | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
if: matrix.platform == 'linux/arm64' | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build cross-compilation environment | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
tags: builder/${{ matrix.platform }}:latest | |
platforms: ${{ matrix.platform }} | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: false | |
- name: Build with Docker | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: builder/${{ matrix.platform }}:latest | |
options: | | |
--platform ${{ matrix.platform }} | |
--volume ${{ github.workspace }}:/workspace | |
--workdir /workspace | |
run: | | |
cmake -S rapidyenc -B rapidyenc/build \ | |
-D CMAKE_BUILD_TYPE=Release | |
cmake --build rapidyenc/build --target rapidyenc_static -j$(sysctl -n hw.ncpu) | |
cp rapidyenc/build/rapidyenc_static/librapidyenc.a ${{ matrix.library }} | |
- name: Upload static library | |
uses: actions/upload-artifact@v3 | |
with: | |
name: static | |
path: ${{ matrix.library }} | |
test: | |
name: Test ${{ matrix.os }} go/${{ matrix.go }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
go: [1.21] | |
runs-on: ${{ matrix.os }} | |
needs: [build_linux, build_macos, build_windows] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go ${{ matrix.go }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: static | |
path: lib | |
- name: Run tests | |
run: go test -v | |
publish: | |
name: Publish rapidyenc build | |
runs-on: ubuntu-latest | |
needs: [test] | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: static | |
path: lib | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
file_pattern: 'lib/*.a' | |
commit_message: Built rapidyenc |