Changes to the GitHub Actions workflow files #27
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
name: 'Linux' | |
env: | |
LIBRARIES_BRANCH: libraries-OS-COMPILER | |
NCINE_BRANCH: nCine-BRANCH_NAME-OS-COMPILER | |
NCINE_SOURCE_BRANCH: BRANCH_NAME | |
DEPLOY_MESSAGE: | |
"Push artifact from GitHub Actions build ${{ github.run_number }} with id ${{ github.run_id }} | |
- PROJECT_NAME artifact from branch 'BRANCH_NAME' with commit id ${{ github.sha }}" | |
DEPLOY_BRANCH: PROJECT_NAME-BRANCH_NAME-OS-COMPILER | |
on: [push, workflow_dispatch] | |
jobs: | |
Linux: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- BuildType: Debug | |
CC: gcc | |
CXX: g++ | |
- BuildType: Release | |
CC: gcc | |
CXX: g++ | |
- BuildType: BinDist | |
CC: gcc | |
CXX: g++ | |
- BuildType: Debug | |
CC: clang | |
CXX: clang++ | |
- BuildType: Release | |
CC: clang | |
CXX: clang++ | |
- BuildType: BinDist | |
CC: clang | |
CXX: clang++ | |
runs-on: 'ubuntu-20.04' | |
steps: | |
- name: 'Checkout Code' | |
uses: actions/checkout@v4 | |
- name: 'Unshallow Git Repository for Versioning' | |
if: matrix.BuildType == 'BinDist' | |
run: | | |
git fetch --unshallow || true | |
- name: 'Download nCine-libraries, nCine Artifacts, and project data' | |
run: | | |
export OS=linux | |
export CC=${{ matrix.CC }} | |
export BRANCH_NAME=$(git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD) | |
export LIBRARIES_BRANCH=`echo $LIBRARIES_BRANCH | sed 's/OS/'"$OS"'/'` | |
export LIBRARIES_BRANCH=`echo $LIBRARIES_BRANCH | sed 's/COMPILER/'"$CC"'/'` | |
cd .. | |
git clone https://github.com/nCine/nCine-libraries-artifacts.git | |
cd nCine-libraries-artifacts | |
git checkout $LIBRARIES_BRANCH | |
LIBRARIES_FILE=$(ls -t | head -n 1) && tar xpzf $LIBRARIES_FILE | |
mv nCine-external .. | |
cd .. | |
rm -rf nCine-libraries-artifacts | |
export NCINE_SOURCE_BRANCH=`echo $NCINE_SOURCE_BRANCH | sed 's/BRANCH_NAME/'"$BRANCH_NAME"'/'` | |
export NCINE_BRANCH=`echo $NCINE_BRANCH | sed 's/BRANCH_NAME/'"$NCINE_SOURCE_BRANCH"'/'` | |
export NCINE_BRANCH=`echo $NCINE_BRANCH | sed 's/OS/'"$OS"'/'` | |
export NCINE_BRANCH=`echo $NCINE_BRANCH | sed 's/COMPILER/'"$CC"'/'` | |
git clone https://github.com/nCine/nCine-artifacts.git | |
cd nCine-artifacts | |
git checkout $NCINE_BRANCH | |
NCINE_FILE=$(ls -t nCine-* | head -n 1) | |
tar xpzf $NCINE_FILE | |
mv "${NCINE_FILE/.tar.gz/}" ../nCine | |
cd .. | |
rm -rf nCine-artifacts | |
git clone https://github.com/$GITHUB_REPOSITORY-data.git | |
- name: 'CMake Configuration' | |
run: | | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
export CC= ${{ matrix.CC }} | |
export CXX=${{ matrix.CXX }} | |
export NCINE_DIRECTORY=$(pwd)/../nCine/lib/cmake/nCine | |
if [[ "${{ matrix.BuildType }}" == "BinDist" ]]; then | |
cmake -B ../$PROJECT_NAME-build-${{ matrix.BuildType }} -D NCPROJECT_OPTIONS_PRESETS=${{ matrix.BuildType }} -D CMAKE_INSTALL_PREFIX="" -D nCine_DIR=$NCINE_DIRECTORY | |
else | |
cmake -B ../$PROJECT_NAME-build-${{ matrix.BuildType }} -D CMAKE_BUILD_TYPE=${{ matrix.BuildType }} -D nCine_DIR=$NCINE_DIRECTORY | |
fi | |
- name: 'Make' | |
run: | | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/../nCine-external/lib | |
make -j2 -C ../$PROJECT_NAME-build-${{ matrix.BuildType }} | |
- name: 'Package' | |
if: matrix.BuildType == 'BinDist' | |
run: | | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
make package -C ../$PROJECT_NAME-build-${{ matrix.BuildType }} | |
- name: 'Push Artifacts' | |
if: matrix.BuildType == 'BinDist' | |
env: | |
PUBLIC_REPO_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
export BRANCH_NAME=$(git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD) | |
export DEPLOY_MESSAGE=`sed 's/PROJECT_NAME/'"$PROJECT_NAME"'/' <<< "$DEPLOY_MESSAGE"` | |
export DEPLOY_MESSAGE=`sed 's/BRANCH_NAME/'"$BRANCH_NAME"'/' <<< "$DEPLOY_MESSAGE"` | |
export OS=linux | |
export CC=${{ matrix.CC }} | |
export PROJECT_EXT=tar.gz | |
cd .. | |
export DEPLOY_BRANCH=`echo $DEPLOY_BRANCH | sed 's/PROJECT_NAME/'"$PROJECT_NAME"'/'` | |
export DEPLOY_BRANCH=`echo $DEPLOY_BRANCH | sed 's/BRANCH_NAME/'"$BRANCH_NAME"'/'` | |
export DEPLOY_BRANCH=`echo $DEPLOY_BRANCH | sed 's/OS/'"$OS"'/'` | |
export DEPLOY_BRANCH=`echo $DEPLOY_BRANCH | sed 's/COMPILER/'"$CC"'/'` | |
git clone https://[email protected]/$GITHUB_REPOSITORY-artifacts.git >/dev/null 2>&1 | |
cd $PROJECT_NAME-artifacts | |
git checkout $DEPLOY_BRANCH || git checkout --orphan $DEPLOY_BRANCH | |
git reset | |
git clean -f | |
git rm * || true | |
mv -f ../$PROJECT_NAME-build-${{ matrix.BuildType }}/*.$PROJECT_EXT . | |
git add *.$PROJECT_EXT | |
git commit --amend -m "$DEPLOY_MESSAGE" || git commit -m "$DEPLOY_MESSAGE" | |
git push --force || git push --set-upstream origin $DEPLOY_BRANCH |