mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
158 lines
4.5 KiB
YAML
158 lines
4.5 KiB
YAML
name: C/C++ CI
|
|
on: [push, pull_request]
|
|
jobs:
|
|
format:
|
|
name: Check C/C++ formatting
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install clang-format
|
|
run: |
|
|
sudo apt-get update --fix-missing
|
|
sudo apt-get install -y clang-format
|
|
|
|
- name: Check formatting of changed files
|
|
run: |
|
|
node scripts/clang-format-changed.js origin/${{ github.base_ref || 'develop' }}
|
|
|
|
build:
|
|
env:
|
|
TARGET_MAJOR: 3
|
|
TARGET_VERSION: 3.0.0
|
|
TARGET_KIND: static
|
|
timeout-minutes: 10
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ['ubuntu-latest', 'windows-latest']
|
|
runs-on: ${{ matrix.os }}
|
|
name: "Builds binaries on ${{ matrix.os }}"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: xmake-io/github-action-setup-xmake@v1
|
|
with:
|
|
xmake-version: branch@dev
|
|
|
|
- name: Cache xmake packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.xmake/packages
|
|
~/.xmake/repositories
|
|
~/AppData/Local/.xmake/packages
|
|
~/AppData/Local/.xmake/repositories
|
|
key: ${{ runner.os }}-xmake-${{ runner.os == 'Linux' && 'coverage' || 'release' }}-${{ hashFiles('xmake-requires.lock', 'examples/xmake-requires.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-xmake-${{ runner.os == 'Linux' && 'coverage' || 'release' }}-
|
|
${{ runner.os }}-xmake-
|
|
|
|
- name: Install tools
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update --fix-missing
|
|
sudo apt-get install debhelper lcov valgrind xvfb -yy
|
|
sudo apt-get install libfreetype6-dev libpng-dev libyaml-dev libomp-dev libx11-dev ninja-build fontconfig libfontconfig1-dev libjpeg-dev
|
|
|
|
- name: Configure
|
|
if: runner.os == 'Windows'
|
|
run: xmake config -y -v -k ${{ env.TARGET_KIND }} -m release --ci-env=y
|
|
|
|
- name: Configure for coverage mode
|
|
if: runner.os == 'Linux'
|
|
run: xmake config -y -v -k ${{ env.TARGET_KIND }} -m coverage --ci-env=y --memcheck=y
|
|
|
|
- name: Build
|
|
run: xmake
|
|
|
|
- name: Run all tests
|
|
if: runner.os == 'Windows'
|
|
run: xmake test
|
|
|
|
- name: Run all tests with memcheck
|
|
if: runner.os == 'Linux'
|
|
run: xvfb-run -a xmake test
|
|
|
|
- name: Upload reports to Codecov
|
|
if: runner.os == 'Linux'
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: false
|
|
|
|
- name: Build for release
|
|
run: |
|
|
xmake config -y -v -k ${{ env.TARGET_KIND }} -m release
|
|
xmake
|
|
|
|
- name: Package
|
|
run: |
|
|
xmake package
|
|
xmake install -o dist/lcui-package
|
|
|
|
- name: Build examples
|
|
run: |
|
|
cd examples
|
|
xmake config -P . -y
|
|
xmake build -P .
|
|
xmake install -P . -o ../dist/lcui-examples
|
|
mv ../dist/lcui-examples/bin/* ../dist/lcui-examples/
|
|
rm -r ../dist/lcui-examples/bin
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: lcui${{ env.TARGET_MAJOR }}-${{ env.TARGET_VERSION }}-${{ env.TARGET_KIND }} (${{ runner.os }})
|
|
path: |
|
|
dist/lcui-package
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: lcui${{ env.TARGET_MAJOR }}-examples (${{ runner.os }})
|
|
path: |
|
|
dist/lcui-examples
|
|
|
|
release:
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
env:
|
|
ARTIFACT_DIR: ./release
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ${{ env.ARTIFACT_DIR }}
|
|
|
|
- name: Set release version
|
|
run: python ./.github/scripts/get_release_version.py
|
|
|
|
- name: Create release notes
|
|
run: python ./.github/scripts/get_release_notes.py
|
|
|
|
- name: Read package.json
|
|
id: release_notes
|
|
uses: juliangruber/read-file-action@v1
|
|
with:
|
|
path: RELEASE_NOTES.md
|
|
trim: false
|
|
|
|
- name: Create release
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
body: ${{ steps.release_notes.outputs.content }}
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
release_name: LCUI ${{ env.REL_VERSION }}
|
|
tag: ${{ github.ref }}
|
|
file: ${{ env.ARTIFACT_DIR }}/*
|
|
overwrite: true
|
|
file_glob: true
|