Support two macOS GitHub Actions runner images #179
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: 'Emscripten' | |
env: | |
LIBRARIES_BRANCH: libraries-OS-COMPILER | |
NCINE_SOURCE_BRANCH: master | |
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: | |
Emscripten: | |
strategy: | |
fail-fast: false | |
matrix: | |
BuildType: [Debug, Release, BinDist] | |
runs-on: 'ubuntu-22.04' | |
steps: | |
- name: 'Checkout Code' | |
uses: actions/checkout@v4 | |
- name: 'Install Emscripten SDK' | |
run: | | |
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 | |
cd .. | |
git clone https://github.com/emscripten-core/emsdk.git | |
cd emsdk | |
./emsdk install latest | |
./emsdk activate latest | |
- name: 'Unshallow Git Repository for Versioning' | |
if: matrix.BuildType == 'BinDist' | |
run: | | |
git fetch --unshallow || true | |
- name: 'Download nCine-libraries and project data' | |
run: | | |
export OS=emscripten | |
export CC=emcc | |
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-emscripten .. | |
cd .. | |
rm -rf nCine-libraries-artifacts | |
git clone https://github.com/$GITHUB_REPOSITORY-data.git | |
# Temporary hack to restore the `data` subdirectory | |
cd ncJump-data | |
mkdir data | |
mv *.png *.json *.ini img data/ | |
- name: 'Download nCine source and data' | |
run: | | |
export BRANCH_NAME=$(git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD) | |
export NCINE_SOURCE_BRANCH=`echo $NCINE_SOURCE_BRANCH | sed 's/BRANCH_NAME/'"$BRANCH_NAME"'/'` | |
cd .. | |
git clone https://github.com/nCine/nCine-data.git | |
git clone https://github.com/nCine/nCine.git --branch $NCINE_SOURCE_BRANCH | |
- name: 'CMake Configuration and Make of nCine with docking ImGui' | |
run: | | |
source ../emsdk/emsdk_env.sh | |
cd ../nCine | |
if [[ "${{ matrix.BuildType }}" == "BinDist" ]]; then | |
export NCINE_BUILD_TYPE=Release | |
else | |
export NCINE_BUILD_TYPE=${{ matrix.BuildType }} | |
fi | |
export CMAKE_ARGS="-B ../nCine-build-$NCINE_BUILD_TYPE -D CMAKE_BUILD_TYPE=$NCINE_BUILD_TYPE -D NCINE_DYNAMIC_LIBRARY=OFF -D NCINE_PREFERRED_BACKEND=SDL2 -D IMGUI_VERSION_TAG=docking -D NCINE_BUILD_TESTS=OFF" | |
emcmake cmake $CMAKE_ARGS | |
cd .. | |
make -j2 -C nCine-build-$NCINE_BUILD_TYPE | |
- name: 'CMake Configuration' | |
run: | | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
source ../emsdk/emsdk_env.sh | |
if [[ "${{ matrix.BuildType }}" == "BinDist" ]]; then | |
emcmake cmake -B ../$PROJECT_NAME-build-${{ matrix.BuildType }} -D NCPROJECT_OPTIONS_PRESETS=${{ matrix.BuildType }} -D nCine_DIR=$(pwd)/../nCine-build-Release | |
else | |
emcmake cmake -B ../$PROJECT_NAME-build-${{ matrix.BuildType }} -D CMAKE_BUILD_TYPE=${{ matrix.BuildType }} -D nCine_DIR=$(pwd)/../nCine-build-${{ matrix.BuildType }} | |
fi | |
- name: 'Make' | |
run: | | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
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 "actions@github.com" | |
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=emscripten | |
export CC=emcc | |
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://$PUBLIC_REPO_TOKEN@github.com/$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 }}/*.tar.gz . | |
git add *.tar.gz | |
git commit --amend -m "$DEPLOY_MESSAGE" || git commit -m "$DEPLOY_MESSAGE" | |
git push --force || git push --set-upstream origin $DEPLOY_BRANCH | |
- name: 'Deploy' | |
if: matrix.BuildType == 'BinDist' && github.ref == 'refs/heads/main' | |
env: | |
PUBLIC_REPO_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }} | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name "GitHub Actions" | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
export DEPLOY_MESSAGE=`sed 's/PROJECT_NAME/'"$PROJECT_NAME"'/' <<< "$DEPLOY_MESSAGE"` | |
export DEPLOY_BRANCH=pages | |
export COMMIT_DATE=`git log -1 --format=%ad --date=short` | |
export ARR_DATE=(${COMMIT_DATE//-/ }) | |
export MAJOR=${ARR_DATE[0]} | |
export MINOR=${ARR_DATE[1]} | |
export REV_COUNT=`git rev-list --count HEAD` | |
export SHORT_HASH=`git rev-parse --short HEAD` | |
export PATCH=r${REV_COUNT}-${SHORT_HASH} | |
export PACKAGE_VERSION=${MAJOR}.${MINOR}.${PATCH} | |
export TAR_NAME=${PROJECT_NAME}-${PACKAGE_VERSION}-Emscripten | |
echo ${TAR_NAME} | |
cd .. | |
echo Moving.. | |
mv $PROJECT_NAME-artifacts/${TAR_NAME}.tar.gz . | |
echo Extracting.. | |
tar -zxvf ${TAR_NAME}.tar.gz | |
cd $PROJECT_NAME-artifacts | |
git checkout $DEPLOY_BRANCH || git checkout --orphan $DEPLOY_BRANCH | |
git reset | |
git clean -f | |
git rm * || true | |
echo Committing.. | |
mv ../${TAR_NAME}/bin/* . | |
mv ncjump.html index.html | |
git add . | |
git commit --amend -m "$DEPLOY_MESSAGE" || git commit -m "$DEPLOY_MESSAGE" | |
echo Pushing.. | |
git push --force || git push --set-upstream origin $DEPLOY_BRANCH |