mirror of
https://github.com/ArthurSonzogni/Diagon.git
synced 2026-08-29 16:40:45 +08:00
Automate production of packages.
This commit is contained in:
@@ -1,92 +1,219 @@
|
||||
name: Build and run tests
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
create:
|
||||
tags:
|
||||
-v*
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.config.name }}
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
test:
|
||||
name: "Tests"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
#- name: "Windows Latest - MSVC"
|
||||
#os: windows-latest
|
||||
#cc: "cl"
|
||||
#cxx: "cl"
|
||||
- name: "Ubuntu Latest - GCC"
|
||||
include:
|
||||
- name: "Linux GCC"
|
||||
os: ubuntu-latest
|
||||
cc: "gcc"
|
||||
cxx: "g++"
|
||||
cmake: "cmake"
|
||||
cc: gcc
|
||||
cxx: g++
|
||||
test: true
|
||||
cmake: cmake
|
||||
|
||||
- name: "Ubuntu Latest - Clang"
|
||||
- name: "Linux Clang"
|
||||
os: ubuntu-latest
|
||||
cc: "clang"
|
||||
cxx: "clang++"
|
||||
cmake: "cmake"
|
||||
cc: clang
|
||||
cxx: clang++
|
||||
test: true
|
||||
cmake: cmake
|
||||
|
||||
- name: "Ubuntu Latest - Emscripten"
|
||||
- name: "Linux emscripten"
|
||||
os: ubuntu-latest
|
||||
cc: "emcc"
|
||||
cc: emcc
|
||||
cxx: "em++"
|
||||
test: false
|
||||
cmake: "emcmake cmake"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Set Windows ENV
|
||||
if: runner.os == 'Windows'
|
||||
#- name: "MacOS clang"
|
||||
#os: macos-latest
|
||||
#cc: clang
|
||||
#cxx: clang++
|
||||
#test: true
|
||||
#cmake: cmake
|
||||
|
||||
#- name: "Windows MSVC"
|
||||
#os: windows-latest
|
||||
#cc: cl
|
||||
#cxx: cl
|
||||
#test: false
|
||||
#cmake: cmake
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: "Enable MSVC command prompt"
|
||||
if: matrix.os == 'windows-latest'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Install boost for windows
|
||||
- name: "Install cmake"
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: "Install Linux Dependencies"
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt install libboost-graph-dev uuid-dev
|
||||
|
||||
- name: "Install boost for windows"
|
||||
if: runner.os == 'Windows'
|
||||
uses: MarkusJx/install-boost@v1.0.1
|
||||
with:
|
||||
boost_version: 1.73.0
|
||||
|
||||
- name: Setup Emscripten
|
||||
if: ${{ matrix.config.cc == 'emcc' }}
|
||||
- name: "Install boost for macOS"
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install boost
|
||||
|
||||
- name: "Setup Emscripten"
|
||||
if: ${{ matrix.cc == 'emcc' }}
|
||||
uses: mymindstorm/setup-emsdk@v7
|
||||
|
||||
- name: Install Linux Dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt install libboost-graph-dev
|
||||
|
||||
- name: Build
|
||||
- name: "Build debug mode"
|
||||
run: >
|
||||
mkdir build;
|
||||
cd build;
|
||||
${{ matrix.config.cmake }}
|
||||
..
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_C_COMPILER=${{ matrix.config.cc }}
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }};
|
||||
${{ matrix.cmake }} ..
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
-DCMAKE_C_COMPILER=${{ matrix.cc }}
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }};
|
||||
cmake --build . --config Release
|
||||
|
||||
- name: Tests
|
||||
if: ${{ matrix.config.cc != 'emcc' }}
|
||||
- name: "Run tests"
|
||||
if: matrix.test
|
||||
run: >
|
||||
cd build;
|
||||
./input_output_test
|
||||
|
||||
- name: Make webAssembly distribution
|
||||
if: ${{ matrix.config.cc == 'emcc' }}
|
||||
# Create a release on new v* tags
|
||||
release:
|
||||
needs: test
|
||||
if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }}
|
||||
name: "Create release"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
steps:
|
||||
- name: "Create release"
|
||||
uses: softprops/action-gh-release@v1
|
||||
id: create_release
|
||||
with:
|
||||
draft: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Build artifact for the release
|
||||
package:
|
||||
name: "Build packages"
|
||||
needs: release
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: "Linux Clang"
|
||||
os: ubuntu-latest
|
||||
cc: clang
|
||||
cxx: clang++
|
||||
cmake: cmake
|
||||
asset_path: build/diagon*Linux*
|
||||
|
||||
- name: "Linux emscripten"
|
||||
os: ubuntu-latest
|
||||
cc: emcc
|
||||
cxx: em++
|
||||
cmake: "emcmake cmake"
|
||||
asset_path: build/diagon-Web.zip
|
||||
|
||||
#- name: "MacOS clang"
|
||||
#os: macos-latest
|
||||
#cc: clang
|
||||
#cxx: clang++
|
||||
#test: true
|
||||
#cmake: cmake
|
||||
#asset_path: build/diagon*Darwin*
|
||||
|
||||
#- name: "Windows MSVC"
|
||||
#os: windows-latest
|
||||
#cc: cl
|
||||
#cxx: cl
|
||||
#test: false
|
||||
#cmake: cmake
|
||||
#asset_path: build/diagon*Win64*
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: "Enable MSVC command prompt"
|
||||
if: matrix.os == 'windows-latest'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: "Install cmake"
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: "Install Linux Dependencies"
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt install libboost-graph-dev uuid-dev zip
|
||||
|
||||
- name: "Install boost for windows"
|
||||
if: runner.os == 'Windows'
|
||||
uses: MarkusJx/install-boost@v1.0.1
|
||||
with:
|
||||
boost_version: 1.73.0
|
||||
|
||||
- name: "Setup Emscripten"
|
||||
if: ${{ matrix.cc == 'emcc' }}
|
||||
uses: mymindstorm/setup-emsdk@v7
|
||||
|
||||
- name: "Build release mode"
|
||||
run: >
|
||||
mkdir build;
|
||||
cd build;
|
||||
${{ matrix.cmake }} ..
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_C_COMPILER=${{ matrix.cc }}
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }};
|
||||
cmake --build . --config Release;
|
||||
make package;
|
||||
|
||||
- name: "Upload native binaries"
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
if: ${{ matrix.cc != 'emcc'}}
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ${{ matrix.asset_path }}
|
||||
overwrite: true
|
||||
|
||||
- name: "Make webAssembly distribution"
|
||||
if: ${{ matrix.cc == 'emcc' }}
|
||||
run: >
|
||||
cd build;
|
||||
mkdir -p distribution;
|
||||
cp diagon.js distribution;
|
||||
cp diagon.wasm distribution;
|
||||
cp index.html distribution;
|
||||
cp style.css distribution;
|
||||
cp run_diagon.sh distribution;
|
||||
chmod a+x ./distribution/run_diagon.sh
|
||||
mkdir -p diagon-Web;
|
||||
cp diagon.js diagon-Web;
|
||||
cp diagon.wasm diagon-Web;
|
||||
cp index.html diagon-Web;
|
||||
cp style.css diagon-Web;
|
||||
cp run_diagon.sh diagon-Web;
|
||||
chmod a+x ./diagon-Web/run_diagon.sh;
|
||||
zip -r diagon-Web.zip diagon-Web;
|
||||
|
||||
- name: Upload WebAssembly distribution
|
||||
if: ${{ matrix.config.cc == 'emcc' }}
|
||||
uses: actions/upload-artifact@v2
|
||||
- name: "Upload WebAssembly distribution"
|
||||
if: ${{ matrix.cc == 'emcc' }}
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
name: distribution
|
||||
path: build/distribution
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ${{ matrix.asset_path }}
|
||||
overwrite: true
|
||||
|
||||
Reference in New Issue
Block a user