-
Notifications
You must be signed in to change notification settings - Fork 10
142 lines (140 loc) · 5.01 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: GitHub CI
on:
workflow_call:
outputs:
do-release:
value: ${{ jobs.semver.outputs.do-build == 'true' && jobs.semver.outputs.do-release == 'true' }}
ver-cur:
value: ${{ jobs.semver.outputs.ver-cur }}
workflow_dispatch:
push:
paths-ignore:
- '.github/*'
- '.github/*TEMPLATE/**'
branches:
- '**'
pull_request:
paths-ignore:
- '*.md'
- '.github/*'
- '.github/*TEMPLATE/**'
env:
is_pr: ${{ startsWith(github.ref, 'refs/pull/') }}
repo_default: 'Cxbx-Reloaded/XbSymbolDatabase'
jobs:
semver:
name: Generate Semver
runs-on: ubuntu-latest
outputs:
ver-prev: ${{ steps.semver-output.outputs.version_previous }}
ver-cur: ${{ steps.semver-output.outputs.version_current }}
# Hack method to generate true or false for jobs.
# Since job's "if" doesn't support env context.
do-build: ${{ steps.build-cond.outputs.do-build }}
do-release: ${{ github.repository == env.repo_default }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: RadWolfie/Semantic-Version-Action@main
id: semver-output
with:
repository: ${{ env.repo_default }}
version_major_init: 3
version_minor_init: 0
- name: Run Build Conditional
id: build-cond
run: |
if [ "true" == "${{ (github.event_name != 'schedule' && github.event_name != 'workflow_dispatch') || steps.semver-output.outputs.version_previous != steps.semver-output.outputs.version_current }}" ]
then
echo "do-build=true" >> $GITHUB_OUTPUT
else
echo "do-build=false" >> $GITHUB_OUTPUT
fi
- name: Generate Changelog
if: steps.build-cond.outputs.do-build == 'true'
run: |
if [ "true" == "${{ env.is_pr }}" ]
then
git log --pretty=format:"%h: %s%n%w(0,11)%-b%n" ${{ steps.semver-output.outputs.version_previous }}..HEAD > changelog
else
git log --first-parent --pretty=format:"%h: %s%n%w(0,11)%-b%n" ${{ steps.semver-output.outputs.version_previous }}..HEAD > changelog
fi
# NOTE: Require to reduce workload from CI service from fetch whole git content.
- name: Upload Changelog
if: steps.build-cond.outputs.do-build == 'true'
uses: actions/upload-artifact@v3
with:
name: changelog
path: changelog
build:
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: ${{ matrix.os }}
needs: semver
if: needs.semver.outputs.do-build == 'true'
strategy:
fail-fast: false
matrix:
cmake-generator:
# x86 arch
- -A Win32 # Visual Studio (latest IDE)
# x64 arch
- -A x64 # Visual Studio (latest IDE)
- -G "Unix Makefiles"
- -G Xcode
configuration: [Debug, Release]
include:
- cmake-generator: -A Win32
platform: Windows
os: windows-latest
arch: x86
cmake-build-param: -j $env:NUMBER_OF_PROCESSORS
folder: win
- cmake-generator: -A x64
platform: Windows
os: windows-latest
arch: x64
cmake-build-param: -j $env:NUMBER_OF_PROCESSORS
folder: win
- cmake-generator: -G "Unix Makefiles"
platform: Linux
os: ubuntu-latest
arch: x64
cmake-build-param: -j $(nproc --all)
folder: linux
- cmake-generator: -G Xcode
platform: macOS
os: macos-latest
arch: x64
cmake-build-param: -j $(sysctl -n hw.ncpu)
folder: macos
steps:
- uses: actions/checkout@v3
- name: Generate CMake Files
# NOTES:
# -Werror=dev is used to validate CMakeLists.txt for any faults.
run: cmake -B build -Werror=dev ${{ matrix.cmake-generator }}
- name: Build
run: cmake --build build --config ${{ matrix.configuration }} ${{ matrix.cmake-build-param }}
- name: CTests
run: ctest --test-dir build --build-config ${{ matrix.configuration }} --verbose
- name: Copy Files
if: matrix.configuration == 'Release'
run: cmake --install build --config ${{ matrix.configuration }} --prefix upload/${{ matrix.folder }}_${{ matrix.arch }}
- name: Upload Build Artifact
if: matrix.configuration == 'Release'
uses: actions/upload-artifact@v3
with:
name: XbSymbolDatabase
# roughly translate to upload/<platform_arch>/<bin | lib | include>/<anything in here and after>
path: upload/*/*/*
if-no-files-found: error
- name: Upload Misc Artifact
if: matrix.cmake-generator == '-G "Unix Makefiles"' && matrix.configuration == 'Release'
uses: actions/upload-artifact@v3
with:
name: XbSymbolDatabase
path: |
README.md
LICENSE
if-no-files-found: error