[CI BUILD] logging #581
Workflow file for this run
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
--- | |
# yamllint disable rule:line-length | |
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Builds | |
on: # yamllint disable-line rule:truthy | |
pull_request: {} | |
push: | |
branches: | |
- "**" | |
tags: | |
- "v*" | |
schedule: | |
- cron: "34 19 * * sat" # Weekly, Saturday at 19:34 UTC | |
env: | |
UNITY_VERSION: "2022.3.34f1" | |
PHOTON_PAT: ${{ secrets.PHOTON_PAT }} # This needs to be here, since you can't use a ${{ secrets }} within an if: condition | |
jobs: | |
configuration: | |
if: | | |
(github.event_name == 'schedule') || | |
(github.event_name == 'pull_request') || | |
( | |
github.event_name == 'push' && | |
( | |
github.ref == 'refs/heads/main' || | |
contains(github.ref, 'refs/tags/v') || | |
contains(github.event.head_commit.message, '[CI BUILD]') | |
) | |
) | |
name: Configure Build Parameters | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version}} | |
androidVersionCode: ${{ steps.version.outputs.androidVersionCode }} | |
stamp: ${{ steps.version.outputs.stamp }} | |
prerelease: ${{ steps.version.outputs.prerelease }} | |
previousrelease: ${{ steps.rawchangelogdata.outputs.previousrelease }} | |
previousfullrelease: ${{ steps.rawchangelogdata.outputs.previousfullrelease }} | |
currentrelease: ${{ steps.rawchangelogdata.outputs.currentrelease }} | |
rawchangelog: ${{ steps.rawchangelogdata.outputs.rawchangelog}} | |
basename: ${{ steps.github.outputs.basename }} | |
description: ${{ steps.github.outputs.description}} | |
itchchannelname: ${{ steps.version.outputs.itchchannelname }} | |
fastlanelane: ${{ steps.version.outputs.fastlanelane}} | |
uid: ${{ steps.github.outputs.uid }} | |
gid: ${{ steps.github.outputs.gid }} | |
flavors: ${{ steps.flavors.outputs.flavors }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
lfs: true # We don't use LFS, but it adds no time, and leave it here in case we do at some point later | |
- name: Calculate version and stamp | |
id: version | |
run: | | |
# General note: for pull requests, we query github.event.pull_request.head.sha rather than the default sha, which is a merge commit of the target branch into the head. For pushes or tag commits, there's no additional commits made by the CI, so we can use the default, current, reference | |
# Get the first two numbers from the last tag, including a tag on the current commit (to handle the case of a formal build) | |
MAJOR_MINOR=$(git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*" ${{ github.event.pull_request.head.sha }}) | |
# How many commits have been made since the last tag of the form vX.Y. | |
# | |
# We used to use this version, however, it couldn't handle these two cases at the same time: | |
# (v2.1) | |
# | | |
# /-c2..c4..c5-\ | |
# / \ | |
# c...c0..c1....c3.........m6..c7....c10.c11.....m13...c14 <- [main] | |
# ^ \ / | |
# (v2.0) \-c8..c9..c12-/ | |
# If we use --first-parent, it wouldn't find a tag that was not a first parent, and so it'll think we're now in 2.0.8, though it skips the commits on the branches. If we did not use --first-parent, it gets the proper tag (v2.1), but counts each commit in the feature branch, and gives 2.1.10. While we almost always squash, if we ever do have an explicit merge commit, we don't want to count the commits on the feature branch. In this case, we actually want to get 2.1.7 (commits c3, m6, c7, c10, c11, m13, and c14). | |
######## OLD CODE ######## | |
# # If the value is not equal to zero, git describe will give us a version in the form vX.Y-Z-gAAAAAAA, where Z is the count. If the current commit has a vX.Y tag, it'll just return that, so the 'cut' does nothing. We test for this below | |
# PATCH_VERSION=$(git describe --tags --match "v[0-9]*.[0-9]*" --first-parent ${{ github.event.pull_request.head.sha }} | cut -d'-' -f2) | |
######## END OLD CODE ######## | |
# Instead, we'll find the last tag, wherever it is, and then count the --first-parent commits "since" then (i.e., not included; they might be historically behind it) | |
CLOSEST_TAG=$(git describe --tags --match "v[0-9]*.[0-9]*" --abbrev=0 HEAD) | |
PATCH_VERSION=$(git log ${CLOSEST_TAG}.. --oneline --first-parent | wc -l) | |
if [ $PATCH_VERSION == "0" ] | |
then | |
STAMP="" | |
echo "prerelease=false" >> $GITHUB_OUTPUT | |
echo "itchchannelname=release" >> $GITHUB_OUTPUT | |
echo "fastlanelane=beta" >> $GITHUB_OUTPUT | |
else | |
# This is the first 7 characters of the commit; we do it this way rather than via rev-parse to avoid an 'if' conditional depending on whether it's a PR or push. (unlike git describe, git rev-parse doesn't default to the current HEAD) | |
STAMP=$(git describe --tags --match "v[0-9]*.[0-9]*" ${{ github.event.pull_request.head.sha }} | cut -d'-' -f3) | |
echo "prerelease=true" >> $GITHUB_OUTPUT | |
echo "itchchannelname=beta" >> $GITHUB_OUTPUT | |
echo "fastlanelane=beta" >> $GITHUB_OUTPUT | |
fi | |
VERSION=$(echo "$MAJOR_MINOR.$PATCH_VERSION" | sed -e 's/^v//') | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "stamp=$STAMP" >> $GITHUB_OUTPUT | |
MAJOR=$(echo $VERSION | cut -d '.' -f 1) | |
MINOR=$(echo $VERSION | cut -d '.' -f 2) | |
ANDROID_VERSION_CODE=$((MAJOR * 1000000 + MINOR * 1000 + PATCH_VERSION)) | |
echo "androidVersionCode=$ANDROID_VERSION_CODE" >> $GITHUB_OUTPUT | |
echo "Version $VERSION stamp=$STAMP androidVersionCode=$ANDROID_VERSION_CODE" | |
- name: Calculate Release tags for Changelog and raw changelog | |
id: rawchangelogdata | |
env: | |
PRERELEASE: ${{ steps.version.outputs.prerelease }} | |
VERSION: ${{ steps.version.outputs.version }} | |
run: | | |
if [ "$PRERELEASE" == "true" ] | |
then | |
PREV=$(git describe --tags --abbrev=0 HEAD^) | |
else | |
PREV=$(git describe --tags --match "v[0-9]*.[0-9]*" --first-parent --abbrev=0 HEAD^) | |
fi | |
PREVFULL=$(git describe --tags --match "v[0-9]*.[0-9]*" --first-parent --abbrev=0 HEAD^) | |
CUR="$(git rev-parse HEAD)" | |
echo "previousrelease=$PREV" >> $GITHUB_OUTPUT | |
echo "previousfullrelease=$PREVFULL" >> $GITHUB_OUTPUT | |
echo "currentrelease=$CUR" >> $GITHUB_OUTPUT | |
LAST_TAG=$(git describe --tags --match 'v[0-9]*.[0-9]*' --abbrev=0 HEAD^) | |
RAW_CHANGELOG=$(echo "$(git log --first-parent ${LAST_TAG}.. --pretty=format:'%D-g%h: %s' | sed -e 's/tag: //' -e 's/HEAD -> main, //')" | sed -e "s/origin\/main/$VERSION/" | tac) | |
echo "rawchangelog=${RAW_CHANGELOG//$'\n'/'\n'}" >> $GITHUB_OUTPUT | |
- name: Echo Changelog (for debugging purposes) | |
env: | |
CHANGELOG: ${{ steps.rawchangelogdata.outputs.rawchangelog}} | |
run: | | |
echo "CHANGELOG=$CHANGELOG" | |
- name: Set custom app name and package name, if relevant | |
id: github | |
env: | |
PRERELEASE: ${{ steps.version.outputs.prerelease }} | |
run: | | |
# For a PR action (i.e., synchronize / open), the value of github.ref will be refs/pull/1234/merge | |
# For a push action, it will be either refs/heads/foo_branch_name OR refs/tags/v1234. | |
# We want to use the base name for pushes of tags or to main, the PR number for PRs, and the branch name for named branches. | |
if [[ "$PRERELEASE" == "false" || ${{ github.ref }} == refs/heads/main ]] | |
then | |
echo "basename=OpenBrush" >> $GITHUB_OUTPUT | |
echo "description=" >> $GITHUB_OUTPUT | |
else | |
if [[ ${{ github.ref }} == refs/pull/* ]] | |
then | |
DESCRIPTION="PR#$(echo ${{ github.ref }} | sed -e 's#refs/pull/##' -e 's#/merge##')" | |
elif [[ ${{ github.ref }} == refs/heads/* ]] | |
then | |
DESCRIPTION="$(echo ${{ github.ref }} | sed -e 's#refs/heads/##')" | |
else | |
DESCRIPTION="Unknown" | |
fi | |
echo "description=-btb-description ${DESCRIPTION}" >> $GITHUB_OUTPUT | |
IDENTIFIER=$(echo ${DESCRIPTION} | sed -e 's/[\/#_-]//g') | |
echo "basename=OpenBrush-${IDENTIFIER}" >> $GITHUB_OUTPUT | |
fi | |
echo "uid=$(id -u)" >> $GITHUB_OUTPUT | |
echo "gid=$(id -g)" >> $GITHUB_OUTPUT | |
- name: Determine whether to build Development builds or not | |
id: flavors | |
run: | | |
set -x | |
if [[ $(git log --format=%B ${{ github.event.pull_request.head.sha }} -1) == *'[CI BUILD DEV]'* ]] | |
then | |
echo 'flavors=[{"development": true, "title": "Development"}, {"development": false}]' >> $GITHUB_OUTPUT | |
else | |
echo 'flavors=[{"development": false}]' >> $GITHUB_OUTPUT | |
fi | |
build: | |
name: ${{ matrix.name }} ${{ matrix.flavors.title }} | |
needs: configuration | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
flavors: ${{ fromJson(needs.configuration.outputs.flavors) }} | |
name: [Windows OpenXR, Windows Pimax, Windows Rift, Linux, MacOS, Android OpenXR, Oculus Quest (1), Oculus Quest (2+), Android Pico, Android Pico (CN), iOS Zapbox] # These will all be overwritten, but because we have the flavors matrix as well, we can't just add configurations via include; they'll overwrite each other. This way ensures that we get each one | |
include: | |
- name: Windows OpenXR | |
targetPlatform: StandaloneWindows64 | |
vrsdk: OpenXR | |
cache: Windows | |
- name: Windows Pimax | |
targetPlatform: StandaloneWindows64 | |
vrsdk: OpenXR | |
cache: Windows | |
extra_defines: PIMAX_SUPPORTED | |
- name: Windows Rift | |
targetPlatform: StandaloneWindows64 | |
vrsdk: Oculus | |
cache: Windows | |
extra_defines: OCULUS_SUPPORTED | |
- name: Linux | |
targetPlatform: StandaloneLinux64 | |
vrsdk: Monoscopic # All builds include monoscopic, but this one has no additional XrSdk, so we'll keep the name monoscopic | |
cache: Linux | |
- name: MacOS | |
targetPlatform: StandaloneOSX | |
vrsdk: Monoscopic | |
cache: MacOS | |
packages_to_remove: com.meta.xr.sdk.core | |
- name: Android OpenXR | |
targetPlatform: Android | |
vrsdk: OpenXR | |
cache: Android_Vulkan | |
extraoptions: -btb-il2cpp | |
versionSuffix: 0 | |
- name: Oculus Quest (1) | |
targetPlatform: Android | |
vrsdk: OpenXR | |
cache: Android_Vulkan | |
extraoptions: -btb-il2cpp | |
versionSuffix: 0 | |
extra_defines: USE_QUEST_PACKAGE_NAME FORCE_QUEST_SUPPORT_DEVICE FORCE_FOCUSAWARE FORCE_HEADTRACKING | |
packages_to_remove: com.meta.xr.sdk.platform com.meta.xr.sdk.utilities | |
- name: Oculus Quest (2+) | |
targetPlatform: Android | |
vrsdk: Oculus | |
cache: Android_Vulkan | |
extraoptions: -btb-il2cpp | |
versionSuffix: 1 | |
extra_defines: OCULUS_SUPPORTED USE_QUEST_PACKAGE_NAME | |
- name: Android Pico | |
targetPlatform: Android | |
vrsdk: Pico | |
cache: Android_GLES | |
extraoptions: -btb-il2cpp | |
versionSuffix: 0 | |
extra_defines: PICO_SUPPORTED | |
- name: Android Pico (CN) | |
targetPlatform: Android | |
vrsdk: Pico | |
cache: Android_GLES | |
# Pico requested Chinese build that doesn't have google/sketchfab login. | |
extraoptions: -btb-il2cpp -btb-disableAccountLogins | |
versionSuffix: 1 | |
extra_defines: PICO_SUPPORTED | |
- name: iOS Zapbox | |
targetPlatform: iOS | |
vrsdk: Zapbox | |
cache: iOS | |
extraoptions: -btb-il2cpp | |
extra_defines: ZAPBOX_SUPPORTED | |
packages_to_remove: com.unity.formats.usd | |
steps: | |
- name: Set masking | |
run: echo "::add-mask::DoNotStealThis1" | |
- name: Free extra space | |
# As of 02/08/2024, this increases free space from 21GB to 47GB | |
run: | | |
echo "Initial free space" | |
df -h / | |
echo "Removing all pre-loaded docker images" | |
docker rmi $(docker image ls -aq) # Removes ~3GB | |
df -h / | |
echo "Listing 100 largest packages" | |
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rn | head -n 100 | |
echo "Removing unneeded large packages" | |
sudo apt update | |
sudo apt remove -y '^ghc-.*' '^dotnet-.*' azure-cli powershell google-chrome-stable firefox microsoft-edge-stable 'mongodb-*' 'mysql-*' 'mariadb-*' 'temurin-*' 'openjdk-*' default-jre-headless mono-devel libgl1-mesa-dri # Removes ~6GB | |
sudo apt autoremove -y | |
sudo apt clean | |
df -h / | |
echo "Removing Android" | |
sudo rm -rf /usr/local/lib/android # Removes ~9GB | |
df -h / | |
echo "Removing remaining large directories" | |
rm -rf /usr/share/dotnet/ # Removes ~1GB | |
rm -rf "$AGENT_TOOLSDIRECTORY" # Removes ~7GB | |
echo "Disk space after cleanup" | |
df -h / | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
lfs: true # We don't use LFS, but it adds no time, and leave it here in case we do at some point later | |
- name: Install Pimax unity package | |
if: startsWith(matrix.name, 'Windows Pimax') | |
run: | | |
# version 0.6.3 | |
# Same as above, but adapted to work for Pimax instead. | |
wget -q https://dl.appstore.pimax.com/sdk/Pimax_Platform_Unity_SDK_v0.6.3.zip -O package.zip | |
unzip package.zip | |
mkdir tmp | |
tar -C tmp -xzf PimaxPlatform_v0.6.3.unitypackage | |
find tmp -type f | xargs chmod a-x | |
for pn in tmp/*/pathname; do | |
id=${pn%/*} | |
id=${id#*/} | |
p=$(head -1 $pn) | |
d=${p%/*} | |
mkdir -p "tmp/$d" | |
[ -f "tmp/$id/asset" ] && cp -v "tmp/$id/asset" "tmp/$p" | |
cp "tmp/$id/asset.meta" "tmp/${p}.meta" | |
done | |
cp -R tmp/Assets/Pimax Assets/ | |
rm -rf tmp package.zip PimaxPlatform_v0.6.3.unitypackage Tools | |
- name: Install Pico unity package | |
if: matrix.vrsdk == 'Pico' | |
run: | | |
# version 2.1.1 | |
mkdir Packages/com.unity.xr.picoxr | |
wget -q https://sdk.picovr.com/developer-platform/sdk/PICO%20Unity%20Integration%20SDK%20v211.zip -O package.zip | |
unzip package.zip -d Packages/com.unity.xr.picoxr | |
# Pico has a GUID conflict because they copied code from Oculus. Delete the offending .meta file from our mutable Pico SDK. | |
rm Packages/com.unity.xr.picoxr/Platform/Scripts/Models/Common.cs.meta | |
- name: Install TextMesh Pro package | |
run: | | |
# version 3.0.6; must be updated if the version changes | |
# This replaces the GUI's "Window -> TextMesh Pro -> Import TMP Essential Resources". I don't know why Unity makes this sort of thing so hard! | |
mkdir tmp.plugin | |
wget -q https://download.packages.unity.com/com.unity.textmeshpro/-/com.unity.textmeshpro-3.0.6.tgz -O tmp.plugin/plugin.tgz | |
tar -C tmp.plugin -xzf tmp.plugin/plugin.tgz | |
mkdir tmp.package | |
tar -C tmp.package -xzf 'tmp.plugin/package/Package Resources/TMP Essential Resources.unitypackage' | |
for pn in tmp.package/*/pathname; do | |
id=${pn%/*} | |
id=${id#*/} | |
p=$(head -1 $pn) | |
d=${p%/*} | |
mkdir -p "tmp.package/$d" | |
[ -f "tmp.package/$id/asset" ] && cp -v "tmp.package/$id/asset" "tmp.package/$p" | |
cp "tmp.package/$id/asset.meta" "tmp.package/${p}.meta" | |
done | |
mkdir -p 'Assets/TextMesh Pro' | |
cp -R 'tmp.package/Assets/TextMesh Pro' Assets/ | |
rm -rf tmp.plugin tmp.package | |
- name: Checkout private photon repository if available | |
if: ${{ env.PHOTON_PAT }} | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ env.PHOTON_PAT }} | |
repository: icosa-mirror/photon-fusion | |
path: photon-fusion-mirror/ | |
- name: Copy photon files | |
if: ${{ env.PHOTON_PAT }} | |
run: | | |
rsync -a --ignore-existing photon-fusion-mirror/ ./ | |
echo "For debugging: these are the files in Assets/Photon:" | |
find Assets/Photon | |
- name: Restore Library/ | |
id: cache_library | |
uses: actions/cache/restore@v4 | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10 | |
with: | |
path: Library | |
# Some platforms share a cache; it's not a 1:1 mapping of either targetPlatform or vrsdk, so we have a distinct variable for which cache to use | |
key: Library_${{ matrix.cache }}_${{ env.UNITY_VERSION }} | |
- name: Restore Library/PackageCache | |
id: cache_packagecache | |
uses: actions/cache/restore@v4 | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10 | |
with: | |
path: Library/PackageCache | |
key: Library_PackageCache_${{ env.UNITY_VERSION }}_${{ hashFiles('Packages/packages-lock.json') }} | |
restore-keys: | | |
Library_PackageCache_${{ env.UNITY_VERSION }} | |
Library_PackageCache | |
- name: Remove problematic packages | |
if: ${{ matrix.packages_to_remove }} | |
run: | | |
cp Packages/manifest.json{,.bak} | |
cp Packages/packages-lock.json{,.bak} | |
for PACKAGE in ${{ matrix.packages_to_remove }}; do | |
cat Packages/manifest.json | jq 'del( .dependencies ["'${PACKAGE}'"] )' > Packages/manifest.json.new | |
mv Packages/manifest.json.new Packages/manifest.json | |
cat Packages/packages-lock.json | jq 'del( .dependencies ["'${PACKAGE}'"] )' > Packages/packages-lock.json.new | |
mv Packages/packages-lock.json.new Packages/packages-lock.json | |
done | |
diff -u Packages/manifest.json.bak Packages/manifest.json || true | |
diff -u Packages/packages-lock.json.bak Packages/packages-lock.json || true | |
- name: Set output filename | |
env: | |
BASENAME: ${{ needs.configuration.outputs.basename }} | |
run: | | |
if [[ "${{ matrix.targetPlatform}}" == "StandaloneWindows64" ]]; then | |
echo "filename=$BASENAME.exe" >> $GITHUB_ENV | |
elif [[ "${{ matrix.targetPlatform}}" == "StandaloneLinux64" ]]; then | |
echo "filename=$BASENAME" >> $GITHUB_ENV | |
elif [[ "${{ matrix.targetPlatform}}" == "iOS" ]]; then | |
echo "filename=$BASENAME" >> $GITHUB_ENV | |
elif [[ "${{ matrix.targetPlatform}}" == "StandaloneOSX" ]]; then | |
echo "filename=$BASENAME.app" >> $GITHUB_ENV | |
elif [[ "${{ matrix.targetPlatform}}" == "Android" ]]; then | |
echo "filename=com.Icosa.$BASENAME.apk" >> $GITHUB_ENV | |
fi | |
- name: Set build stamp | |
if: ${{ needs.configuration.outputs.stamp }} | |
# We checkout the merge commit, but for the purpose of the tag, use the version from the PR, not the merge commit, which is rather hard to find later. We skip the version tag, since this comes from the code and can't be easily overwritten | |
run: | | |
echo "stamp=-btb-stamp ${{needs.configuration.outputs.stamp}}" >> $GITHUB_ENV | |
- name: Enable Development Mode | |
if: ${{ matrix.flavors.development == true }} | |
run: | | |
echo "btbbopts=-btb-bopt Development" >> $GITHUB_ENV | |
- name: Update version | |
env: | |
VERSION: ${{ needs.configuration.outputs.version}} | |
run: | | |
sed -e "s/m_VersionNumber:.*$/m_VersionNumber: $VERSION/" -i Assets/Scenes/Main.unity | |
sed -e "s/bundleVersion:.*$/bundleVersion: $VERSION/" -i ProjectSettings/ProjectSettings.asset | |
- name: Add secure secrets file | |
env: | |
SECRETS_ASSET: ${{ secrets.SECRETS_ASSET }} | |
SECRETS_ASSET_META: ${{ secrets.SECRETS_ASSET_META }} | |
if: | | |
env.SECRETS_ASSET != null && | |
env.SECRETS_ASSET_META != null | |
run: | | |
echo "$SECRETS_ASSET" > Assets/Secrets.asset | |
echo "$SECRETS_ASSET_META" > Assets/Secrets.asset.meta | |
md5sum Assets/Secrets.asset | |
head Assets/Secrets.asset | |
tail Assets/Secrets.asset | |
xxd Assets/Secrets.asset | |
SECRETS_ASSET_META_GUID=$(grep "guid:" Assets/Secrets.asset.meta | cut -d" " -f2) | |
sed -e "s/Secrets:.*$/Secrets: {fileID: 11400000, guid: $SECRETS_ASSET_META_GUID, type: 2}/" -i Assets/Scenes/Main.unity | |