Skip to content

Fix client rendering problem #840

Fix client rendering problem

Fix client rendering problem #840

Workflow file for this run

name: Build client
on:
push:
branches:
- '*'
paths:
- .github/actions/version/action.yml
- .github/workflows/build-client.yml
- client/**
- server/constants.json
tags:
- 'v*'
workflow_dispatch:
env:
CLIENT_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || 'preview' }}
NODE_VERSION: 20
concurrency:
group: client-build-${{ github.ref_type }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.title }}
strategy:
matrix:
include:
-
title: macOS
os: macos-13
arch: universal
platform: darwin
out_path: "*.dmg"
filename_suffix: macos.dmg
-
title: Windows
os: windows-2022
arch: x64
platform: win32
out_path: squirrel.windows/x64/*.exe
filename_suffix: windows.exe
-
title: Linux (amd64)
os: ubuntu-22.04
arch: x64
platform: linux
out_path: deb/x64/*.deb
filename_suffix: linux_amd64.deb
-
title: Linux (arm64)
os: ubuntu-22.04
arch: arm64
platform: linux
out_path: deb/arm64/*.deb
filename_suffix: linux_arm64.deb
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get version
id: version
uses: ./.github/actions/version
-
name: Set variables
shell: bash
run: |
echo "CLIENT_FILENAME=tomato-client-${{ env.CLIENT_VERSION }}-${{ matrix.filename_suffix }}" | tee -a "${GITHUB_ENV}"
if [ "${{ github.ref_type }}" != 'tag' -a "${{ github.ref_name}}" != main ]; then
echo "EXTRA_BUILD_INFO=Branch: ${{ github.ref_name}}" | tee -a "${GITHUB_ENV}"
fi
-
name: Setup Node v${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
-
# macOS: appears to fix https://github.com/electron/forge/issues/2807
name: Fix macOS build
uses: actions/setup-python@v5
if: matrix.platform == 'darwin'
with:
python-version: '3.11'
-
name: Build package
shell: bash
run: |
echo "Building Tomato for ${{ matrix.title }} (${{ steps.version.outputs.version }})"
cd client
echo "Settings package.json version to ${{ steps.version.outputs.version-short }}"
jq '.version = "${{ steps.version.outputs.version-short }}"' package.json > package.json.tmp
mv -v package.json.tmp package.json
if [ "${{ matrix.platform }}" = "win32" ]; then
npm config set script-shell $(which bash)
fi
npm clean-install
TOMATO_VERSION=${{ steps.version.outputs.version }} TOMATO_EXTRA_BUILD_INFO="${EXTRA_BUILD_INFO}" npm run build
npx electron-forge make --arch ${{ matrix.arch }} --platform ${{ matrix.platform }}
mkdir ../client-build-files
mv -v out/make/${{ matrix.out_path }} ../client-build-files/${{ env.CLIENT_FILENAME }}
if [ "${{ matrix.platform }}" = "linux" -a "${{ matrix.arch }}" = "x64" ]; then
mv -v out/make/AppImage/x64/*.AppImage ../client-build-files/${CLIENT_FILENAME%.*}.AppImage
fi
-
name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: client-build-files-${{ matrix.platform }}-${{ matrix.arch }}
path: client-build-files
compression-level: 0
retention-days: 2
tag:
runs-on: ubuntu-22.04
name: Tag release
if: github.ref_type == 'tag' || github.ref_name == 'main'
needs: build
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get version
id: version
uses: ./.github/actions/version
-
name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: client-build-files-*
path: client-build-files
merge-multiple: true
-
name: Remove old preview release
uses: dev-drprasad/[email protected]
if: github.ref_type != 'tag'
with:
delete_release: true
tag_name: preview-build
github_token: ${{ secrets.GITHUB_TOKEN }}
-
name: Wait for last preview deletion
shell: bash
if: github.ref_type != 'tag'
run: |
sleep 15s
-
name: Tag and upload preview release
uses: ncipollo/release-action@v1
if: github.ref_type != 'tag'
with:
artifacts: "./client-build-files/*"
name: 'Tomato Preview Build (${{ steps.version.outputs.version }})'
body: |
_**This development preview build may not be safe: use it at your own risk!**_
* Release version: `${{ steps.version.outputs.version }}`
* Protocol version: `${{ steps.version.outputs.protocol }}`
tag: 'preview-build'
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
-
name: Tag and upload release
uses: ncipollo/release-action@v1
if: github.ref_type == 'tag'
with:
artifacts: "./client-build-files/*"
name: 'Tomato Release ${{ steps.version.outputs.version }}'
body: |
Choose a client to download below. Server containers [can be found here](https://github.com/dtcooper/tomato/pkgs/container/tomato-server).
* Release version: `${{ steps.version.outputs.version }}`
* Protocol version: `${{ steps.version.outputs.protocol }}`
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
aur:
runs-on: ubuntu-22.04
name: Publish to AUR
if: github.ref_type == 'tag'
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get version
id: version
uses: ./.github/actions/version
-
name: Publish to Arch User Repository (AUR)
shell: bash
run: |
# Set up ssh key and git
mkdir -p ~/.ssh
chmod 0700 ~/.ssh
ssh-keyscan -t 'rsa,ecdsa,ed25519' aur.archlinux.org | tee -a ~/.ssh/known_hosts
echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 0600 ~/.ssh/id_ed25519
git config set --global user.name "${{ secrets.AUR_NAME }}"
git config set --global user.email "${{ secrets.AUR_EMAIL }}"
# Clone to AUR repo
git clone ssh://[email protected]/tomato-radio-automation.git aur
cd aur
# Update versions
sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
# Run in an arch docker container
docker run -i --rm -v "$PWD:/aur" archlinux:base-devel /bin/bash -e <<'EOF'
# Exit on failure
set -e
# Install deps
pacman -Sy --noconfirm --needed pacman-contrib rsync sudo
# Add user, copy over package build files
useradd builduser -m
echo 'builduser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
cd ~builduser
sudo -u builduser rsync -vr --exclude=.git /aur .
# Update checksums and .SRCINFO
cd aur
sudo -u builduser updpkgsums
sudo -u builduser makepkg --printsrcinfo > .SRCINFO
rm -fv *.tar.gz
# Copy back updated files
rsync -vr ~builduser/aur/ /aur
EOF
# Push changes to AUR
git add -A
git commit -m "Moved to version ${{ steps.version.outputs.version }}"
git push