Skip to content

Commit 252acac

Browse files
authored
Trying out (#359)
* Trying out https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/ * Forgot submodules. * lets see if this works. * Bad syntax. * Trying out this way. * Trying out this way. * Trying out this way. * Fixing up things. * Fixing up syntax * Fixing up syntax * More work. * removing Ninja * explicit submodules. * Fixing up the dependencies. * Cleaning up the actions. * Fixing up the mac build. * more work on this. * trying with no warnings for winsows. * Updating CI System. * Fixing it up.
1 parent 6abb129 commit 252acac

File tree

2 files changed

+151
-25
lines changed

2 files changed

+151
-25
lines changed

.github/workflows/cmake.yml

Lines changed: 151 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,180 @@
1-
name: CMake
1+
# much of this inspired from: https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/
2+
# and also the excellent series from:
3+
# https://www.edwardthomson.com/blog/github_actions_advent_calendar.html
4+
name: CI action for CalChart
25

36
on:
47
push:
5-
branches: [ main ]
8+
branches:
9+
- main
610
pull_request:
7-
branches: [ main ]
11+
branches:
12+
- main
813

914
env:
1015
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
1116
BUILD_TYPE: Release
1217

1318
jobs:
1419
build:
15-
# The CMake configure and build commands are platform agnostic and should work equally
16-
# well on Windows or Mac. You can convert this to a matrix build if you need
17-
# cross-platform coverage.
18-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19-
runs-on: ubuntu-latest
20+
name: ${{ matrix.config.name }}
21+
runs-on: ${{ matrix.config.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
config:
26+
- {
27+
name: "Ubuntu Latest GCC",
28+
artifact: "CalChart.tar.xz",
29+
os: ubuntu-latest,
30+
build_type: "Release",
31+
cc: "gcc",
32+
cxx: "g++",
33+
}
34+
- {
35+
name: "macOS Latest Clang",
36+
artifact: "CalChart-3.6.2.dmg",
37+
os: macos-latest,
38+
build_type: "Release",
39+
cc: "clang",
40+
cxx: "clang++",
41+
}
42+
# CI for Windows doesn't seem functional. Need to investigate, (see https://github.com/calband/calchart/issues/363)
43+
#- {
44+
# name: "Windows Latest MSVC",
45+
# artifact: "Windows-MSVC.tar.xz",
46+
# os: windows-latest,
47+
# build_type: "Release",
48+
# cc: "cl",
49+
# cxx: "cl",
50+
# }
2051

2152
steps:
2253
- name: checkout
2354
uses: actions/checkout@v2
24-
with:
25-
submodules: 'true'
2655

27-
- name: Installing dependencies
56+
- name: Checkout submodules
57+
run: git submodule update --init --recursive
58+
59+
- name: Installing Dependencies (Windows)
60+
if: matrix.config.os == 'windows-latest'
61+
run: choco install winflexbison
62+
63+
- name: Installing Dependencies (Linux)
64+
if: matrix.config.os == 'ubuntu-latest'
2865
run: sudo apt-get update && sudo apt-get install build-essential libgtk-3-dev
2966

3067
- name: Configure CMake
3168
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
3269
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
3370
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
34-
71+
3572
- name: Build
3673
# Build your program with the given configuration
3774
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
3875

39-
- name: check for results
40-
run: ls -la ${{github.workspace}}/build
76+
- name: Run tests
77+
run: ctest --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
78+
79+
- name: Pack (macOS)
80+
if: matrix.config.os == 'macos-latest'
81+
run: pushd ${{github.workspace}}/build && cpack -G DragNDrop
82+
83+
- name: Pack (Windows)
84+
if: matrix.config.os == 'windows-latest'
85+
run: pushd ${{github.workspace}}/build && cpack
86+
87+
- name: Strip (Linux)
88+
if: matrix.config.os == 'ubuntu-latest'
89+
run: cmake --install build --prefix instdir --strip
90+
91+
- name: Pack (Linux)
92+
if: matrix.config.os == 'ubuntu-latest'
93+
working-directory: instdir
94+
run: cmake -E tar cJfv ${{github.workspace}}/build/CalChart.tar.xz .
95+
96+
- name: Upload
97+
uses: actions/upload-artifact@v1
98+
with:
99+
path: ${{github.workspace}}/build/${{ matrix.config.artifact }}
100+
name: ${{ matrix.config.artifact }}
101+
102+
release:
103+
if: contains(github.ref, 'tags/v')
104+
runs-on: ubuntu-latest
105+
needs: build
106+
107+
steps:
108+
- name: Create Release
109+
id: create_release
110+
uses: actions/[email protected]
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
tag_name: ${{ github.ref }}
115+
release_name: Release ${{ github.ref }}
116+
draft: false
117+
prerelease: false
118+
119+
- name: Store Release url
120+
run: |
121+
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
41122
42-
- name: Upload calchart
43-
uses: actions/upload-artifact@v2
123+
- uses: actions/upload-artifact@v1
44124
with:
45-
name: CalChart
46-
path: ${{github.workspace}}/build/CalChart
125+
path: ./upload_url
126+
name: upload_url
127+
128+
publish:
129+
if: contains(github.ref, 'tags/v')
130+
name: ${{ matrix.config.name }}
131+
runs-on: ${{ matrix.config.os }}
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
config:
136+
- {
137+
name: "Ubuntu Latest GCC",
138+
artifact: "CalChart.tar.xz",
139+
os: ubuntu-latest
140+
}
141+
- {
142+
name: "macOS Latest Clang",
143+
artifact: "CalChart-3.6.2.dmg",
144+
os: ubuntu-latest
145+
}
146+
# CI for Windows doesn't seem functional. Need to investigate, (see https://github.com/calband/calchart/issues/363)
147+
#- {
148+
# name: "Windows Latest MSVC",
149+
# artifact: "Windows-MSVC.tar.xz",
150+
# os: ubuntu-latest
151+
# }
152+
needs: release
47153

48-
154+
steps:
155+
- name: Download artifact
156+
uses: actions/download-artifact@v1
157+
with:
158+
name: ${{ matrix.config.artifact }}
159+
path: ./
160+
161+
- name: Download URL
162+
uses: actions/download-artifact@v1
163+
with:
164+
name: upload_url
165+
path: ./
166+
- id: set_upload_url
167+
run: |
168+
upload_url=`cat ./upload_url`
169+
echo ::set-output name=upload_url::$upload_url
170+
171+
- name: Upload to Release
172+
id: upload_to_release
173+
uses: actions/[email protected]
174+
env:
175+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176+
with:
177+
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
178+
asset_path: ./${{ matrix.config.artifact }}
179+
asset_name: ${{ matrix.config.artifact }}
180+
asset_content_type: application/x-gtar

CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ add_library (
123123

124124
target_compile_definitions (calchart_core PUBLIC YY_NO_UNISTD_H)
125125
if (MSVC)
126-
target_compile_options (calchart_core PRIVATE -Wall)
127126
else ()
128127
target_compile_options (calchart_core PRIVATE -Wall -Wextra)
129128
endif ()
@@ -140,7 +139,6 @@ target_include_directories (
140139
target_link_libraries(calchart_core PRIVATE nlohmann_json::nlohmann_json)
141140

142141
# calchart_cmd, Mac only
143-
if (APPLE)
144142
add_executable (
145143
calchart_cmd
146144
"${CMAKE_CURRENT_SOURCE_DIR}/calchart_cmd/main.cpp"
@@ -162,7 +160,6 @@ install (
162160
)
163161

164162
if (MSVC)
165-
target_compile_options (calchart_cmd PRIVATE -Wall)
166163
else ()
167164
target_compile_options (calchart_cmd PRIVATE -Wall -Wextra)
168165
endif ()
@@ -176,8 +173,6 @@ target_include_directories (
176173
"${PROJECT_BINARY_DIR}/version"
177174
)
178175

179-
endif()
180-
181176
# CalChart
182177
file (
183178
GLOB CalChartDocs
@@ -340,7 +335,6 @@ target_link_libraries (
340335
)
341336

342337
if (MSVC)
343-
target_compile_options (CalChart PRIVATE -Wall)
344338
else ()
345339
target_compile_options (CalChart PRIVATE -Wall -Wextra)
346340
endif ()

0 commit comments

Comments
 (0)