Add ci file. #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. | |
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml | |
name: Build XC Reader for multi platforms. | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | |
fail-fast: false | |
# Set up a matrix to run the following 3 configurations: | |
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | |
# 2. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | |
# | |
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macos-latest ] | |
arch: [ x86_64, aarch64 ] | |
build_type: [ Release ] | |
c_compiler: [ clang, cl ] | |
include: | |
- os: windows-latest | |
c_compiler: cl | |
cpp_compiler: cl | |
- os: ubuntu-latest | |
c_compiler: clang | |
exclude: | |
- os: windows-latest | |
c_compiler: clang | |
- os: windows-latest | |
arch: aarch64 | |
- os: ubuntu-latest | |
c_compiler: cl | |
- os: macos-latest | |
c_compiler: cl | |
- os: macos-latest | |
arch: aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set reusable strings | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
echo >> $GITHUB_ENV | |
- name: Configure Compiler | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
sudo apt install gcc-aarch64-linux-gnu | |
echo -e \\nset\(CMAKE_C_FLAGS "--target=${{ matrix.arch }}-linux-gnu"\) \\n >> ${{ github.workspace }}/CMakeLists.txt | |
- name: Configure CMake | |
run: > | |
cmake -B ${{ steps.strings.outputs.build-output-dir }} | |
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
-S ${{ github.workspace }} | |
- name: Build Patcher. | |
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target xcreader | |
- name: Set Release Tag and Name | |
id: set_tag_name | |
run: | | |
current_time=$(date +"%y.%U.%H.%M") | |
echo "TAG_NAME=release-${current_time}" >> $GITHUB_ENV | |
echo "RELEASE_NAME=Release ${current_time}" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
if: ${{ matrix.arch == 'x86_64' && matrix.os == 'ubuntu-latest' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: ${{ env.RELEASE_NAME }} | |
draft: false | |
prerelease: false | |
- name: Upload Windows x64 Artifact | |
uses: actions/upload-release-asset@v1 | |
if: ${{ matrix.arch == 'x86_64' && matrix.os == 'windows-latest' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_name: XBLConfigReader-Windows-x64 | |
asset_path: | | |
${{ steps.strings.outputs.build-output-dir }}/**/xcreader.exe | |
asset_content_type: application/zip | |
- name: Upload Linux x64 Artifact | |
uses: actions/upload-release-asset@v1 | |
if: ${{ matrix.arch == 'x86_64' && matrix.os == 'ubuntu-latest' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_name: XBLConfigReader-Linux-x64 | |
asset_path: | | |
${{ steps.strings.outputs.build-output-dir }}/xcreader | |
asset_content_type: application/zip | |
- name: Upload MacOS x64 Artifact | |
uses: actions/upload-release-asset@v1 | |
if: ${{ matrix.arch == 'x86_64' && matrix.os == 'macos-latest' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_name: XBLConfigReader-MacOS-x64 | |
asset_path: | | |
${{ steps.strings.outputs.build-output-dir }}/xcreader | |
asset_content_type: application/zip | |
- name: Upload Linux arm64 Artifact | |
uses: actions/upload-release-asset@v1 | |
if: ${{ matrix.arch == 'aarch64' && matrix.os == 'ubuntu-latest' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_name: XBLConfigReader-Linux-arm64 | |
asset_path: | | |
${{ steps.strings.outputs.build-output-dir }}/xcreader | |
asset_content_type: application/zip |