Skip to content

Configure dependabot (#23) #82

Configure dependabot (#23)

Configure dependabot (#23) #82

Workflow file for this run

---
# Lucena Build Abstraction Library
# “main.yml”
# Copyright © 2024 Lucena
# All Rights Reserved
#
# This file is distributed under the University of Illinois Open Source
# License. See license/License.txt for details.
#
# Configure GitHub actions for continuous integration.
#
# Based on examples presented by Cristian Adam at <https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/>.
# Uses CMake as a multiplatform scripting language to simplify management.
name: Build Matrix
on: [push]
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- # Currently macOS 14.6.1 and Xcode 15.3
name: "macOS-14/Xcode/libc++"
artifact: "macOS-AppleClang-libcpp.tar.xz"
os: macos-14
build_type: "Release"
cc: "clang"
cxx: "clang++"
- # Currently Ubuntu 24.04 LTS and gcc 14.0.1
name: "Ubuntu-24.04/gcc/libstdc++"
artifact: "linux64-gcc-libstdcpp.tar.xz"
os: ubuntu-24.04
build_type: "Release"
cc: "gcc"
cxx: "g++"
- # Currently Windows Server 2022 and MSVS 17.11
name: "Windows-2022/MSVS/Microsoft"
artifact: "win64-msvc-microsoft.tar.xz"
os: windows-2022
build_type: "Release"
cc: "cl"
cxx: "cl"
# It appears we need to invoke this directly.
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
steps:
- uses: actions/checkout@v4
- name: Configure
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
shell: cmake -P {0}
run: |
# Manually set up the shell environment for MSVS since we’re not coming
# in through the Developer Command Prompt.
if ("${{ runner.os }}" STREQUAL "Windows"
AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND
"${{ matrix.config.environment_script }}" && set
OUTPUT_FILE
environment_script_output.txt
RESULT_VARIABLE
result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Converting Windows env failed: ${result}")
endif()
file(
STRINGS
environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(
ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
execute_process(
COMMAND
cmake
-S .
-B build
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
RESULT_VARIABLE
result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "CMake configure failed: ${result}")
endif()
- name: Build
shell: cmake -P {0}
run: |
# Manually set up the shell environment for MSVS since we’re not coming
# in through the Developer Command Prompt.
if ("${{ runner.os }}" STREQUAL "Windows"
AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
file(
STRINGS
environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
execute_process(
COMMAND
cmake --build build
RESULT_VARIABLE
result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Converting Windows env failed: ${result}")
endif()
- name: Test
shell: cmake -P {0}
run: |
include(ProcessorCount)
ProcessorCount(N)
execute_process(
COMMAND
ctest -j ${N}
WORKING_DIRECTORY
build
RESULT_VARIABLE
result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Running tests failed: ${result}")
endif()
- name: Install Strip
run: cmake --install build --prefix instdir --strip
- name: Pack
working-directory: instdir
run: cmake -E tar cJfv ../${{ matrix.config.artifact }} .
- name: Upload
uses: actions/upload-artifact@v4
with:
path: ./${{ matrix.config.artifact }}
name: ${{ matrix.config.artifact }}
release:
if: contains(github.ref, 'tags/v')
name: Release
runs-on: ubuntu-24.04
needs: build
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false
- name: Store Release url
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- uses: actions/upload-artifact@v4
with:
path: ./upload_url
name: upload_url
publish:
if: contains(github.ref, 'tags/v')
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "macOS-14/Xcode/libc++"
artifact: "macOS-AppleClang-libcpp.tar.xz"
os: macos-14
- name: "Ubuntu-24.04/gcc/libstdc++"
artifact: "linux64-gcc-libstdcpp.tar.xz"
os: ubuntu-24.04
- name: "Windows-latest/MSVS/Microsoft"
artifact: "win64-msvc-microsoft.tar.xz"
os: windows-latest
needs: release
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.config.artifact }}
path: ./
merge-multiple: true
- name: Download URL
uses: actions/download-artifact@v4
with:
name: upload_url
path: ./
merge-multiple: true
- id: set_upload_url
run: |
upload_url=`cat ./upload_url`
echo ::set-output name=upload_url::$upload_url
- name: Upload to Release
id: upload_to_release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ./${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact }}
asset_content_type: application/x-gtar
...