|
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 |
2 | 5 |
|
3 | 6 | on: |
4 | 7 | push: |
5 | | - branches: [ main ] |
| 8 | + branches: |
| 9 | + - main |
6 | 10 | pull_request: |
7 | | - branches: [ main ] |
| 11 | + branches: |
| 12 | + - main |
8 | 13 |
|
9 | 14 | env: |
10 | 15 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
11 | 16 | BUILD_TYPE: Release |
12 | 17 |
|
13 | 18 | jobs: |
14 | 19 | 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 | + # } |
20 | 51 |
|
21 | 52 | steps: |
22 | 53 | - name: checkout |
23 | 54 | uses: actions/checkout@v2 |
24 | | - with: |
25 | | - submodules: 'true' |
26 | 55 |
|
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' |
28 | 65 | run: sudo apt-get update && sudo apt-get install build-essential libgtk-3-dev |
29 | 66 |
|
30 | 67 | - name: Configure CMake |
31 | 68 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. |
32 | 69 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type |
33 | 70 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} |
34 | | - |
| 71 | + |
35 | 72 | - name: Build |
36 | 73 | # Build your program with the given configuration |
37 | 74 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} |
38 | 75 |
|
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 | + |
| 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 |
41 | 122 |
|
42 | | - - name: Upload calchart |
43 | | - uses: actions/upload-artifact@v2 |
| 123 | + - uses: actions/upload-artifact@v1 |
44 | 124 | 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 |
47 | 153 |
|
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 | + |
| 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 |
0 commit comments