- Added conditional checks to ensure build steps only run when necessary. - Streamlined the installation and build processes for NodeJS and Python based on the new build input logic. - Improved clarity and efficiency in the workflow by consolidating conditions for Linux-specific tasks.
221 lines
7.0 KiB
YAML
221 lines
7.0 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
build_windows:
|
|
description: 'Build Windows'
|
|
required: false
|
|
default: 'true'
|
|
type: boolean
|
|
build_mac:
|
|
description: 'Build macOS'
|
|
required: false
|
|
default: 'true'
|
|
type: boolean
|
|
build_linux:
|
|
description: 'Build Linux'
|
|
required: false
|
|
default: 'true'
|
|
type: boolean
|
|
build_docker:
|
|
description: 'Build Docker'
|
|
required: false
|
|
default: 'true'
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build_frontend:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Clone Repo
|
|
uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1
|
|
|
|
- name: Install NodeJS
|
|
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e # v1
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Install Python
|
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Sync versions
|
|
run: python scripts/sync_version.py
|
|
|
|
- name: Install NodeJS Deps
|
|
run: npm install
|
|
|
|
- name: Build Frontend
|
|
run: npm run build-frontend
|
|
|
|
- name: Upload frontend artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: frontend-build
|
|
path: meshchatx/public
|
|
if-no-files-found: error
|
|
|
|
build_desktop:
|
|
name: Build Desktop (${{ matrix.name }})
|
|
needs: build_frontend
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: windows
|
|
os: windows-latest
|
|
node: 22
|
|
python: "3.12"
|
|
release_artifacts: "dist/*-win-installer.exe,dist/*-win-portable.exe"
|
|
build_input: build_windows
|
|
- name: mac
|
|
os: macos-13
|
|
node: 18
|
|
python: "3.11"
|
|
release_artifacts: "dist/*-mac.dmg"
|
|
build_input: build_mac
|
|
- name: linux
|
|
os: ubuntu-latest
|
|
node: 22
|
|
python: "3.12"
|
|
release_artifacts: "dist/*-linux.AppImage,dist/*-linux.deb,python-dist/*.whl"
|
|
build_input: build_linux
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Check if build should run
|
|
id: should_build
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "push" ]; then
|
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
if [ "${{ github.event.inputs[matrix.build_input] }}" = "true" ]; then
|
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
else
|
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Clone Repo
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1
|
|
|
|
- name: Install NodeJS
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e # v1
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
|
|
- name: Install Python
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
|
with:
|
|
python-version: ${{ matrix.python }}
|
|
|
|
- name: Install Poetry
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
run: python -m pip install --upgrade pip poetry
|
|
|
|
- name: Sync versions
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
run: python scripts/sync_version.py
|
|
|
|
- name: Install Python Deps
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
run: python -m poetry install
|
|
|
|
- name: Install NodeJS Deps
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
run: npm install
|
|
|
|
- name: Prepare frontend directory
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
run: python scripts/prepare_frontend_dir.py
|
|
|
|
- name: Download frontend artifact
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: frontend-build
|
|
path: meshchatx/public
|
|
|
|
- name: Install patchelf
|
|
if: steps.should_build.outputs.should_run == 'true' && matrix.name == 'linux'
|
|
run: sudo apt-get update && sudo apt-get install -y patchelf
|
|
|
|
- name: Build Python wheel
|
|
if: steps.should_build.outputs.should_run == 'true' && matrix.name == 'linux'
|
|
run: |
|
|
python -m poetry build -f wheel
|
|
mkdir -p python-dist
|
|
mv dist/*.whl python-dist/
|
|
rm -rf dist
|
|
|
|
- name: Build Electron App
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
run: npm run dist-prebuilt
|
|
|
|
- name: Create Release
|
|
if: steps.should_build.outputs.should_run == 'true'
|
|
uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1
|
|
with:
|
|
draft: true
|
|
allowUpdates: true
|
|
replacesArtifacts: true
|
|
omitDraftDuringUpdate: true
|
|
omitNameDuringUpdate: true
|
|
artifacts: ${{ matrix.release_artifacts }}
|
|
|
|
build_docker:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.build_docker == 'true')
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
steps:
|
|
- name: Clone Repo
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
|
|
|
|
- name: Set lowercase repository owner
|
|
run: echo "REPO_OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
|
|
|
|
- name: Log in to the GitHub Container registry
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker images
|
|
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: >-
|
|
ghcr.io/${{ env.REPO_OWNER_LC }}/reticulum-meshchatx:latest,
|
|
ghcr.io/${{ env.REPO_OWNER_LC }}/reticulum-meshchatx:${{ github.ref_name }}
|
|
labels: >-
|
|
org.opencontainers.image.title=Reticulum MeshChatX,
|
|
org.opencontainers.image.description=Docker image for Reticulum MeshChatX,
|
|
org.opencontainers.image.url=https://github.com/${{ github.repository }}/pkgs/container/reticulum-meshchatx/
|