Mattk70 is building chirpity #727
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: Test Chirpity Compilation | |
run-name: ${{ github.actor }} is building chirpity | |
on: [push, workflow_dispatch] | |
jobs: | |
Build-Chirpity: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
steps: | |
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | |
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | |
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.0.x | |
- run: echo "🍏 Node setup status is ${{ job.status }}." | |
# Step to set up Python 3.11 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
npm install | |
echo "Install's status is ${{ job.status }}." | |
- name: Set platform-specific ffmpeg path | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
PLATFORM="win32-x64" | |
BINARY="ffmpeg.exe" | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
PLATFORM="darwin-arm64" | |
BINARY="ffmpeg" | |
chmod +x ./build/$PLATFORM/ffmpeg | |
echo "Made ffmpeg binary executable for $PLATFORM." | |
elif [[ "$RUNNER_OS" == "Linux" ]]; then | |
PLATFORM="linux-x64" | |
BINARY="ffmpeg" | |
chmod +x ./build/$PLATFORM/ffmpeg | |
echo "Made ffmpeg binary executable for $PLATFORM." | |
fi | |
echo "Platform is $PLATFORM, Binary is $BINARY" | |
# Persist environment variables to the GitHub Actions environment | |
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV | |
echo "BINARY=$BINARY" >> $GITHUB_ENV | |
- name: Overwrite FFmpeg binary | |
run: | | |
echo "copying ./build/$PLATFORM/$BINARY to ./node_modules/@ffmpeg-installer/$PLATFORM/$BINARY" | |
cp ./build/$PLATFORM/$BINARY ./node_modules/@ffmpeg-installer/$PLATFORM/$BINARY | |
shell: bash | |
- name: Modify fluent-ffmpeg processor.js | |
run: | | |
sed -i -e '/^\s*setTimeout(function() {/,/}, 20);/c\ | |
setTimeout(function() {\ | |
if (ffmpegProc.exitCode === null){\ | |
emitEnd(new Error('\''Output stream closed'\''));\ | |
ffmpegProc.kill();\ | |
}\ | |
}, 5000);' ./node_modules/fluent-ffmpeg/lib/processor.js | |
# uncomment to view changed file | |
# cat ./node_modules/fluent-ffmpeg/lib/processor.js | |
shell: bash | |
# test application here | |
- name: Start Xvfb | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y xvfb | |
Xvfb :99 -screen 0 1280x1024x24 & | |
env: | |
DISPLAY: :99 | |
# - name: Fire up Application | |
# env: | |
# DISPLAY: :99 | |
# run: npm run test -- --disable-gpu --disable-software-rasterizer --disable-audio-output | |
# end test application | |
# Get the latest tag from origin/master | |
- name: Get the latest tag on origin/master | |
id: get_latest_tag | |
shell: bash | |
run: | | |
LATEST_TAG=$(gh api repos/${{ github.repository }}/tags --jq '.[0].name') | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
# Get the current pushed tag | |
- name: Get the current pushed tag | |
id: get_current_tag | |
shell: bash | |
run: | | |
current_tag="${GITHUB_REF##*/}" | |
echo "CURRENT_TAG=$current_tag" >> $GITHUB_ENV | |
# Compare tags to decide if build should proceed | |
- name: Check if current tag is greater than the latest tag | |
id: check_tag | |
shell: bash | |
run: | | |
if [ "$(printf "%s\n%s" "$LATEST_TAG" "$CURRENT_TAG" | sort -V | tail -n 1)" != "$CURRENT_TAG" ]; then | |
echo "New tag is not greater than the latest tag on origin/master. Skipping build." | |
echo "skip_build=true" >> $GITHUB_ENV | |
fi | |
# Conditional build command for each OS | |
- name: Build Electron application | |
# if: env.skip_build != 'true' # Only run this if the tag comparison was true | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
npm run build | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
npx electron-builder --mac -p always | |
else | |
npx electron-builder build --linux --x64 -p always | |
fi | |
- run: echo "Build status is ${{ job.status }}." | |
- name: Check installer exists | |
if: env.skip_build != 'true' # Only run this if the tag comparison was true | |
shell: bash | |
run: | | |
# Retrieve the version from package.json | |
VERSION=$(jq -r '.version' package.json) | |
# Construct the filename | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
FILENAME="chirpity Setup $VERSION.exe" | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
FILENAME="chirpity-$VERSION-arm64.pkg" | |
else | |
FILENAME="chirpity-$VERSION.AppImage" | |
fi | |
# Check if the file exists | |
if [ -f "./dist/$FILENAME" ]; then | |
echo "Executable $FILENAME found in ./dist" | |
else | |
echo "Executable $FILENAME not found in ./dist" && exit 1 | |
fi | |
- run: echo "File check status is ${{ job.status }}." | |
# Tests | |
- name: Test packaged application | |
if: runner.os != 'Linux' | |
run: npm test | |