Skip to content

CI Updates

CI Updates #82

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
platform:
- name: Linux (amd64)
os: ubuntu-latest
- name: macOS (amd64, arm64)
os: macos-latest
cmake_options: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
- name: Windows (amd64)
os: windows-latest
name: "Build: ${{ matrix.platform.name }}"
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Build
id: build
run: |
mkdir build
cd build
BUILD_TYPE="${{env.BUILD_TYPE}}"
BUILD_TYPE="${BUILD_TYPE:-RelWithDebInfo}"
LIBGIT2_SRC="${GITHUB_WORKSPACE}/libgit2"
SHA=${SHA:-$(git --git-dir="${LIBGIT2_SRC}/.git" rev-parse --short=7 HEAD)}
LIBGIT2_BASENAME="git2-${SHA}"
case $(uname -s) in
Darwin)
PLATFORM="osx"
LIBGIT2_FILENAME="lib${LIBGIT2_BASENAME}.dylib"
;;
MINGW*)
PLATFORM="win-x64"
LIBGIT2_FILENAME="${BUILD_TYPE}/${LIBGIT2_BASENAME}.dll"
;;
Linux)
PLATFORM="linux-x64"
LIBGIT2_FILENAME="lib${LIBGIT2_BASENAME}.so"
;;
*)
echo "Unknown platform" 1>&2
false
;;
esac
cmake "${LIBGIT2_SRC}" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTS=OFF \
-DUSE_SSH=OFF \
-DUSE_BUNDLED_ZLIB=ON \
-DLIBGIT2_FILENAME="${LIBGIT2_BASENAME}" \
${{ matrix.platform.cmake_options }}
cmake --build . --config ${BUILD_TYPE}
echo "platform=${PLATFORM}" >> $GITHUB_OUTPUT
echo "path=build/${LIBGIT2_FILENAME}" >> $GITHUB_OUTPUT
shell: bash
- name: Upload Library
uses: actions/upload-artifact@v4
with:
name: ${{steps.build.outputs.platform}}
path: ${{steps.build.outputs.path}}
package:
needs: build
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
run: |
mkdir -p build/runtimes/linux-x64
mkdir -p build/runtimes/osx
mkdir -p build/runtimes/win-x64
choco install nuget.commandline
- name: Download linux-x64
uses: actions/download-artifact@v1
with:
name: 'linux-x64'
path: build/runtimes/linux-x64/native
- name: Download osx
uses: actions/download-artifact@v1
with:
name: 'osx'
path: build/runtimes/osx/native
- name: Download win-x64
uses: actions/download-artifact@v1
with:
name: 'win-x64'
path: build/runtimes/win-x64/native
- name: Calculate Version
id: version
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
SHA=$(git rev-parse --short HEAD)
VERSION="$(git describe --tags | \
sed -e "s/^v//" | \
sed -e "s/-g[0-9a-f]*$//" | \
sed -e "s/-[0-9]*$//")-pr${{ github.event.number }}-${SHA}"
else
VERSION=$(git describe --tags | \
sed -e "s/^v//" | \
sed -e "s/-g[0-9a-f]*$//" | \
sed -e "s/-\([0-9]*\)$/\.\1/")
fi
echo "Version ${VERSION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
shell: bash
- name: Build Package
id: build
run: |
cd build
mkdir images
cp -R ../images/* ./images/
. ..\generate_props.ps1
nuget pack -version ${{steps.version.outputs.version}} -basepath . ..\dogged.native.binaries.nuspec
Write-Host "package=dogged.native.binaries.${{steps.version.outputs.version}}.nupkg" >> $Env:GITHUB_OUTPUT
- name: Upload Package
uses: actions/upload-artifact@v4
with:
name: nuget
path: build/${{steps.build.outputs.package}}/Dogged.Native.Binaries.${{steps.version.outputs.version}}.nupkg