mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-03-03 05:54:23 +01:00
* Refactor GitHub Actions workflows for build, documentation, and linting - Consolidated build logic into reusable workflows (`task-build.yml` and `task-docs.yml`) to reduce duplication across multiple workflows. - Introduced `environments.json` to centralize the list of PlatformIO build environments, improving maintainability and clarity. - Updated `build.yml` and `build_and_docs_to_dev.yml` to utilize the new reusable workflows and environment definitions. - Enhanced `release.yml` to streamline the release process and integrate documentation generation. - Created reusable linting workflow (`task-lint.yml`) to standardize code formatting checks across the repository. - Simplified manual documentation workflow by leveraging the new reusable documentation workflow. - Improved artifact management and retention policies across workflows. - Updated dependencies and versions in workflows to ensure compatibility and performance. * CI/CD pipeline agnostic of Workflow Engine and integrated on github actions - Implemented ci.sh for orchestrating the complete build pipeline. - Created ci_00_config.sh for centralized configuration of build scripts. - Created ci_build_firmware.sh for building firmware for specified PlatformIO environments. - Created ci_prepare_artifacts.sh for preparing firmware artifacts for upload or deployment. - Created ci_set_version.sh for updating version tags in firmware configuration files. - Created ci_build.sh to orchestrate the complete build pipeline. - Created ci_qa.sh for code linting and formatting checks using clang-format. - Created ci_site.sh for building and deploying VuePress documentation with version management. - Implemented checks for required tools and dependencies in the new scripts. - Updated common_wu.py, compressFirmware.py, gen_wu.py, generate_board_docs.py, and prepare_deploy.sh with descriptive comments. Refactor CI/CD scripts for improved modularity and clarity - Consolidated build steps in task-build.yml to utilize ci.sh for version tagging, building, and artifact preparation. - Updated task-lint.yml to use ci.sh for code formatting checks instead of ci_qa.sh. - Enhanced CI_SCRIPTS.md documentation to reflect changes in script usage, command structure, and output organization. - Improved internal scripts for better error handling and logging. - Streamlined the output structure for build artifacts and documentation.
105 lines
3.2 KiB
YAML
105 lines
3.2 KiB
YAML
name: Reusable Build Workflow
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
python-version:
|
|
description: 'Python version to use'
|
|
required: false
|
|
type: string
|
|
default: '3.13'
|
|
enable-dev-ota:
|
|
description: 'Enable development OTA builds'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
version-tag:
|
|
description: 'Version tag to inject into firmware (e.g., SHA or release tag)'
|
|
required: false
|
|
type: string
|
|
default: 'unspecified'
|
|
artifact-retention-days:
|
|
description: 'Number of days to retain build artifacts'
|
|
required: false
|
|
type: number
|
|
default: 7
|
|
artifact-name-prefix:
|
|
description: 'Prefix for artifact names (e.g., "firmware-" for dev builds)'
|
|
required: false
|
|
type: string
|
|
default: ''
|
|
prepare-for-deploy:
|
|
description: 'Prepare firmware files for deployment with specific naming'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
load-environments:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- id: set-matrix
|
|
run: |
|
|
ENVIRONMENTS=$(jq -c '.environments.all' .github/workflows/environments.json)
|
|
echo "matrix=${ENVIRONMENTS}" >> $GITHUB_OUTPUT
|
|
|
|
build:
|
|
needs: load-environments
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
environments: ${{ fromJson(needs.load-environments.outputs.matrix) }}
|
|
name: Build ${{ matrix.environments }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
version: "latest"
|
|
enable-cache: false
|
|
|
|
- name: Install PlatformIO dependencies
|
|
run: |
|
|
uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip
|
|
|
|
- name: Build firmware using ci.sh
|
|
run: |
|
|
BUILD_ARGS="${{ matrix.environments }}"
|
|
|
|
# Add version tag if specified
|
|
if [ "${{ inputs.version-tag }}" != "unspecified" ]; then
|
|
BUILD_ARGS="$BUILD_ARGS --version ${{ inputs.version-tag }}"
|
|
fi
|
|
|
|
# Add mode flag (dev/prod)
|
|
if [ "${{ inputs.enable-dev-ota }}" = "true" ]; then
|
|
BUILD_ARGS="$BUILD_ARGS --mode dev"
|
|
else
|
|
BUILD_ARGS="$BUILD_ARGS --mode prod"
|
|
fi
|
|
|
|
# Add deploy flag if needed
|
|
if [ "${{ inputs.prepare-for-deploy }}" = "true" ]; then
|
|
BUILD_ARGS="$BUILD_ARGS --deploy-ready"
|
|
fi
|
|
|
|
# Execute build (uses default generated/artifacts/ directory)
|
|
./scripts/ci.sh build $BUILD_ARGS
|
|
|
|
- name: Upload firmware artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ inputs.artifact-name-prefix }}${{ matrix.environments }}
|
|
path: generated/artifacts/
|
|
retention-days: ${{ inputs.artifact-retention-days }}
|