1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

Add GitHub workflows for CI/CD

- CI: it will check code consistency and run tests for all events (except for tags)
- CD: it will build all assets and create a draft
Close #122
This commit is contained in:
Xorg 2020-05-23 19:13:01 +02:00
parent 8f65066dcc
commit dfc8b2fdbd
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A
3 changed files with 196 additions and 0 deletions

76
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,76 @@
name: Release
on:
push:
tags:
- v*
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Get Git tag
run: echo ::set-env name=VERSION::${GITHUB_REF#refs/tags/}
- name: Create distribution source tarball
run: |
libtoolize
autoreconf --install
./configure
make dist
- name: Download macOS artifacts
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: unix.yml
commit: ${{ github.sha }}
name: macos
path: macos
- name: Download Windows (32-bit) artifacts
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: windows.yml
commit: ${{ github.sha }}
name: win32
path: win32
- name: Download Windows (64-bit) artifacts
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: windows.yml
commit: ${{ github.sha }}
name: win64
path: win64
- name: Compress artifacts
run: |
for dir in macos win32 win64; do
zip -r "libcpuid-$VERSION-$dir.zip" "$dir"
done
env:
VERSION: ${{ env.VERSION }}
- name: Create release
uses: ncipollo/release-action@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ env.VERSION }}
name: ${{ env.VERSION }}
draft: true
prerelease: false
body: |
This is an **official** release.
Brief info of changes between the releases can be found in the [ChangeLog](https://github.com/anrieff/libcpuid/blob/master/ChangeLog).
As a convenience, the following binaries are provided:
- A source tarball;
- Build for 64-bit macOS (built under macOS 10.15);
- Build for 32-bit Windows, using MSVC 16.5, in Debug, Release and Release DLL configurations;
- Build for 64-bit Windows, using MSVC 16.5, in Debug, Release and Release DLL configurations.
artifacts: "libcpuid-${{ env.VERSION }}.tar.gz,libcpuid-${{ env.VERSION }}-macos.zip,libcpuid-${{ env.VERSION }}-win32.zip,libcpuid-${{ env.VERSION }}-win64.zip"

49
.github/workflows/unix.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: Build (UNIX)
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
build_unix:
name: Build
runs-on: ${{ matrix.os.label }}
strategy:
matrix:
os:
- { label: macos-latest, name: macos }
- { label: ubuntu-latest, name: linux }
env:
OS_NAME: ${{ matrix.os.name }}
steps:
- uses: actions/checkout@v2
- name: Generate build system
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=""
- name: Build
run: cmake --build build
- name: Run tests
run: |
make -C build consistency
make -C build test-old
- name: Install
run: |
cmake --install build
install -v AUTHORS ChangeLog COPYING Readme.md "$DESTDIR"
echo -e "Operating system and compiler version:\n$(uname -a)\n$(cc --version)" > "$DESTDIR/Readme.$OS_NAME"
env:
DESTDIR: ${{ github.workspace }}/installdir
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os.name }}
path: installdir/*

71
.github/workflows/windows.yml vendored Normal file
View file

@ -0,0 +1,71 @@
name: Build (Windows)
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
build_win:
name: Build
runs-on: windows-latest
strategy:
matrix:
config: [Debug, Release, ReleaseDLL]
platform:
- { bitness: x32, ms: Win32, name: win32 }
- { bitness: x64, ms: x64, name: win64 }
env:
CONFIG: ${{ matrix.config }}
BITNESS: ${{ matrix.platform.bitness }}
PLATFORM: ${{ matrix.platform.ms }}
PTS: v142
steps:
- uses: actions/checkout@v2
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.0
- name: Build with MSBuild
run: |
MSBuild.exe libcpuid_vc10.sln `
/property:Platform=$Env:PLATFORM `
/property:Configuration=$Env:CONFIG `
/property:PlatformToolset=$Env:PTS `
/verbosity:normal
- name: Write Readme.win
uses: DamianReeves/write-file-action@master
with:
path: Readme.win
contents: |
The binaries here are compiled with Microsoft Visual C++. The following configurations are built:
Debug\ - no optimizations, using the static debug C runtime (/MTd)
Release\ - optimizations on, using the static C runtime (/MT)
ReleaseDLL\ - the library is compiled in a .dll (libcpuid.dll), which you'd need to ship alongside your executable. Static C runtime.
Operating system and compiler version:
write-mode: overwrite
- name: Prepate artifacts
run: |
mkdir -pv "$DESTDIR/"{bin,include,lib}
echo -e "$(cat Readme.win)\n$(wmic os get caption,version -value | sed '/^[[:space:]]*$/d')\n$(MSBuild.exe -version | sed '/^[[:space:]]*$/d')" > "$DESTDIR/Readme.win"
install -v AUTHORS ChangeLog COPYING Readme.md "$DESTDIR/"
install -v libcpuid/{libcpuid_constants.h,libcpuid.h,libcpuid_types.h} "$DESTDIR/include/"
cd "$GITHUB_WORKSPACE/cpuid_tool/$BITNESS" && find * -type f -name '*.exe' -exec install -Dv "{}" "$DESTDIR/bin/{}" \;
cd "$GITHUB_WORKSPACE/libcpuid/$BITNESS" && find * -type f \( -name '*.lib' -o -name '*.dll' -o -name '*.exp' \) -exec install -Dv "{}" "$DESTDIR/lib/{}" \;
shell: bash
env:
DESTDIR: ${{ github.workspace }}/installdir
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.platform.name }}
path: installdir/*