Build viewer #58
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: Build viewer | |
on: | |
push: | |
branches: | |
- "Firestorm*.*.*" | |
- "*alpha" | |
tags: | |
- "preview" | |
schedule: | |
- cron: '00 03 * * *' # Run every day at 3am UTC | |
env: | |
AUTOBUILD_VARIABLES_FILE: ${{github.workspace}}/build-variables/variables | |
EXTRA_ARGS: -DUSE_FMODSTUDIO=ON -DUSE_KDU=ON --crashreporting | |
build_secrets_checkout: ${{github.workspace}}/signing | |
XZ_DEFAULTS: -T0 | |
jobs: | |
build_matrix: | |
strategy: | |
matrix: | |
os: [macos-11,ubuntu-20.04,windows-2022] | |
grid: [sl,os] | |
addrsize: [64,32] | |
exclude: | |
- os: ubuntu-20.04 | |
addrsize: 32 | |
- os: macos-11 | |
addrsize: 32 | |
- grid: sl | |
addrsize: 32 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
if: runner.os != 'Windows' | |
id: py311 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- run: pip3 install -r requirements.txt | |
- name: Check python version | |
run: python -V | |
- name: Free Disk Space (Ubuntu) | |
if: runner.os == 'Linux' | |
uses: jlumbroso/free-disk-space@main | |
with: | |
swap-storage: false | |
- name: Set gcc version on Linux | |
if: runner.os == 'Linux' | |
run: | | |
echo "CC=gcc-10" >> $GITHUB_ENV | |
echo "CXX=g++-10" >> $GITHUB_ENV | |
- name: Install Bash 4 and GNU sed on Mac | |
if: runner.os == 'macOS' | |
run: | | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
brew update | |
brew install bash | |
brew install gnu-sed | |
echo "/usr/local/bin" >> $GITHUB_PATH | |
echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH | |
- name: Setup rclone and download the folder | |
uses: beqjanus/setup-rclone@main | |
with: | |
rclone_config: ${{ secrets.RCLONE_CONFIG }} | |
- name: Set OS/SL flags | |
run: echo "FS_GRID=-DOPENSIM:BOOL=$([ "${{ matrix.grid }}" == "os" ] && echo "ON" || echo "OFF") -DHAVOK_TPV:BOOL=$([ "${{ matrix.grid }}" == "sl" ] && echo "ON" || echo "OFF")" >> $GITHUB_ENV | |
shell: bash | |
- name: find channel from Branch name | |
run: | | |
if [[ "${{ github.ref_name }}" == Firestorm* ]]; then | |
FS_RELEASE_TYPE=Release | |
elif [[ "${{ github.ref_name }}" == *review* ]]; then | |
FS_RELEASE_TYPE=Beta | |
elif [[ "${{ github.ref_name }}" == *alpha* ]]; then | |
FS_RELEASE_TYPE=Alpha | |
elif [[ "${{ github.event_name }}" == 'schedule' ]]; then | |
FS_RELEASE_TYPE=Nightly | |
else | |
FS_RELEASE_TYPE=Unknown | |
fi | |
if [[ "${{ matrix.addrsize }}" == "64" ]]; then | |
FS_RELEASE_CHAN="${FS_RELEASE_TYPE}x64" | |
else | |
FS_RELEASE_CHAN=${FS_RELEASE_TYPE} | |
fi | |
echo "FS_RELEASE_TYPE=${FS_RELEASE_TYPE}" >> $GITHUB_ENV | |
echo "FS_RELEASE_CHAN=${FS_RELEASE_CHAN}" >> $GITHUB_ENV | |
echo "Building for channel ${FS_RELEASE_CHAN}" | |
shell: bash | |
- name: Get the code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Checkout build vars (after the main code) | |
uses: actions/checkout@v3 | |
with: | |
repository: FirestormViewer/fs-build-variables | |
path: build-variables | |
- name: Define platform variable(s) | |
run: | | |
declare -A os_map | |
os_map=( ["Windows"]="windows" ["Linux"]="linux" ["macOS"]="darwin" ) | |
platform="${os_map[${{ runner.os}}]}" | |
echo "fallback_platform=${platform}" >> $GITHUB_ENV | |
if [ ${{ matrix.addrsize }} -ne 32 ]; | |
then | |
platform+=${{ matrix.addrsize }} | |
fi | |
echo "platform=${platform}" >> $GITHUB_ENV | |
shell: bash | |
- name: rclone the private 3p packages for this platform (both 64 & 32) | |
run: 'rclone copy fs_bundles: --filter "- Alpha/*" --filter "+ *${{ env.fallback_platform }}*bz2" .' | |
- name: rclone any extra private 3p packages for Alpha (allows library updates not in the main repo) | |
if: env.FS_BUILD_TYPE == 'Alpha' | |
run: 'rclone copy fs_bundles:Alpha --include "*${{ env.fallback_platform }}*bz2" .' | |
- name: set VSVER for Windows builds | |
if: runner.os == 'Windows' | |
run: echo "AUTOBUILD_VSVER=170" >> $GITHUB_ENV | |
shell: bash | |
- name: Install certificate | |
if: runner.os == 'macOS' | |
env: | |
FS_CERT: ${{ secrets.FS_CERT }} | |
FS_CERT_PASS: ${{ secrets.FS_CERT_PASS }} | |
FS_KEYCHAIN_PASS: ${{ secrets.FS_KEYCHAIN_PASS }} | |
NOTARIZE_CREDS: ${{ secrets.NOTARIZE_CREDS }} | |
run: | | |
mkdir -p ${build_secrets_checkout}/code-signing-osx | |
echo -n "$FS_CERT" | base64 --decode --output ${build_secrets_checkout}/code-signing-osx/fs-cert.p12 | |
echo -n "$FS_CERT_PASS" >${build_secrets_checkout}/code-signing-osx/password.txt | |
echo -n "$NOTARIZE_CREDS" | base64 --decode --output ${build_secrets_checkout}/code-signing-osx/notarize_creds.sh | |
security create-keychain -p "$FS_KEYCHAIN_PASS" ~/Library/Keychains/viewer.keychain | |
security set-keychain-settings -lut 21600 ~/Library/Keychains/viewer.keychain | |
security unlock-keychain -p "$FS_KEYCHAIN_PASS" ~/Library/Keychains/viewer.keychain | |
security import ${build_secrets_checkout}/code-signing-osx/fs-cert.p12 -P "$FS_CERT_PASS" -A -t cert -f pkcs12 -k ~/Library/Keychains/viewer.keychain | |
security set-key-partition-list -S apple-tool:,apple:, -s -k "$FS_KEYCHAIN_PASS" -t private ~/Library/Keychains/viewer.keychain | |
security list-keychain -d user -s ~/Library/Keychains/viewer.keychain | |
- name: Install required Ubuntu packages and release some space. | |
if: runner.os == 'Linux' | |
run: | | |
dependencies=("python3-setuptools" "mesa-common-dev" "libgl1-mesa-dev" "libxinerama-dev" "libxrandr-dev" "libpulse-dev" "libglu1-mesa-dev" "libfreetype6-dev" "libfontconfig1") | |
sudo apt-get update | |
sudo apt-get install -y "${dependencies[@]}" | |
sudo apt-get autoremove --purge | |
sudo apt-get clean | |
- name: test macOS bundles are present | |
if: runner.os == 'MacOS' | |
run: | | |
dirlisting="$(ls -l ${{ github.workspace }}${path_sep}${pattern})" | |
echo "${dirlisting}" | |
shell: bash | |
- name: edit installables | |
run: | | |
path_sep="/" | |
if [[ "${{ runner.os }}" == "Windows" ]]; then | |
path_sep="\\" | |
fi | |
function find_most_recent_bundle() { | |
local pattern="$1-.*$2[-_]+.*" | |
local most_recent_file=$(ls -t "${{ github.workspace }}" | egrep "$pattern" | head -1) | |
if [ -z "$most_recent_file" ]; then | |
echo "" | |
else | |
echo "$most_recent_file" | |
fi | |
} | |
packages=("fmodstudio" "llphysicsextensions_tpv" "kdu") | |
for package in "${packages[@]}"; do | |
package_file=$(find_most_recent_bundle $package ${{ env.platform }}) | |
full_package_path="${{ github.workspace }}${path_sep}${package_file}" | |
if [ -n "$package_file" ]; then | |
echo "Installing ${package_file}" | |
autobuild installables remove ${package} | |
autobuild installables add ${package} platform=${{ env.platform }} url="file:///${full_package_path}" | |
else | |
echo "No bundle found for ${package} on ${{ env.platform }}" | |
package_file=$(find_most_recent_bundle $package ${{ env.fallback_platform }}) | |
full_package_path="${{ github.workspace }}${path_sep}${package_file}" | |
if [ -n "$package_file" ]; then | |
echo "Installing ${package_file}" | |
autobuild installables remove ${package} | |
autobuild installables add ${package} platform=${{ env.fallback_platform }} url="file:///${full_package_path}" | |
else | |
echo "No bundle found for ${package} on ${{ env.fallback_platform }}. Package will not be available for build." | |
fi | |
fi | |
done | |
shell: bash | |
- name: make Nightly builds expire after 14 days | |
if: env.FS_BUILD_TYPE == 'Nightly' | |
run: | | |
echo "EXTRA_ARGS=${{ env.EXTRA_ARGS}} --testbuild=14" >> $GITHUB_ENV | |
- name: make Alpha builds expire after 28 days | |
if: env.FS_BUILD_TYPE == 'Alpha' | |
run: | | |
echo "EXTRA_ARGS=${{ env.EXTRA_ARGS}} --testbuild=28" >> $GITHUB_ENV | |
- name: Clean up packages to give more space | |
run: rm *${{ env.fallback_platform }}*bz2 | |
shell: bash | |
- name: Configure | |
run: autobuild configure -c ReleaseFS -A${{matrix.addrsize}} -- --package --chan ${{env.FS_RELEASE_CHAN}} ${{env.EXTRA_ARGS}} ${{env.FS_GRID}} | |
shell: bash | |
- name: build | |
run: autobuild build -c ReleaseFS -A${{matrix.addrsize}} --no-configure | |
shell: bash | |
- name: Publish artifacts | |
if: runner.os == 'Windows' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.FS_RELEASE_TYPE }}-${{ matrix.os }}-${{ matrix.addrsize }}-${{ matrix.grid }}-artifacts.zip | |
path: | | |
build-*/newview/Release/*Setup.exe | |
build-*/newview/Release/*.xz | |
- name: publish Linux artifacts | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.FS_RELEASE_TYPE }}-${{ matrix.os }}-${{matrix.addrsize}}-${{matrix.grid}}-artifacts.zip | |
path: | | |
build-linux-*/newview/*.xz | |
build-linux-*/newview/*.bz2 | |
- name: publish MacOS artifacts | |
if: runner.os == 'macOS' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.FS_RELEASE_TYPE }}-${{ matrix.os }}-${{matrix.addrsize}}-${{matrix.grid}}-artifacts.zip | |
path: | | |
build-darwin-*/newview/*.dmg | |
build-darwin-*/newview/*.bz2 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build_matrix | |
if: always() | |
steps: | |
- name: Checkout files | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: fsutils/download_list.py | |
branch: ${{ github.head_ref || github.ref_name || 'master' }} | |
- name: Install discord-webhook library | |
run: pip install discord-webhook | |
- name: find channel and webhook from Branch name | |
run: | | |
if [[ "${{ github.ref_name }}" == Firestorm* ]]; then | |
FS_RELEASE_FOLDER=release | |
FS_BUILD_WEBHOOK_URL=${{ secrets.RELEASE_WEBHOOK_URL }} | |
elif [[ "${{ github.ref_name }}" == *review* ]]; then | |
FS_RELEASE_FOLDER=preview | |
FS_BUILD_WEBHOOK_URL=${{ secrets.BETA_WEBHOOK_URL }} | |
elif [[ "${{ github.ref_name }}" == *alpha* ]]; then | |
FS_RELEASE_FOLDER=preview | |
FS_BUILD_WEBHOOK_URL=${{ secrets.BETA_WEBHOOK_URL }} | |
elif [[ "${{ github.event_name }}" == 'schedule' ]]; then | |
FS_RELEASE_FOLDER=nightly | |
FS_BUILD_WEBHOOK_URL=${{ secrets.NIGHTLY_WEBHOOK_URL }} | |
else | |
FS_RELEASE_TYPE=Unknown | |
fi | |
echo "FS_RELEASE_FOLDER=${FS_RELEASE_FOLDER}" >> $GITHUB_ENV | |
echo "FS_BUILD_WEBHOOK_URL=${FS_BUILD_WEBHOOK_URL}" >> $GITHUB_ENV | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
id: download | |
with: | |
path: to_deploy | |
- name: List artifacts download | |
run: ls -R | |
working-directory: ${{steps.download.outputs.download-path}} | |
- name: Reorganise artifacts ready for server upload. | |
run: python ./fsutils/download_list.py -u ${{steps.download.outputs.download-path}} -w ${{ env.FS_BUILD_WEBHOOK_URL }} | |
- name: Setup rclone and download the folder | |
uses: beqjanus/setup-rclone@main | |
with: | |
rclone_config: ${{ secrets.RCLONE_CONFIG }} | |
- name: Copy files to remote host | |
run: rclone copy ${{steps.download.outputs.download-path}}/${{ env.FS_RELEASE_FOLDER }} fs_deploy:${{ env.FS_RELEASE_FOLDER }} | |