diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b690c3378a0..6e85d889b83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ on: type: boolean # Add a separator as a non-input description build_settings_description: - description: 'Build Settings (check the architectures to include):' + description: 'Build Settings (archs to include):' required: false default: '' type: choice @@ -76,13 +76,7 @@ jobs: outputs: arch_packages: ${{ steps.dependencies.outputs.arch_packages }} noarch_packages: ${{ steps.dependencies.outputs.noarch_packages }} - add_noarch_builds: ${{ steps.set-defaults.outputs.add_noarch_builds }} - add_noarch_dsm72_builds: ${{ steps.set-defaults.outputs.add_noarch_dsm72_builds }} - add_dsm72_builds: ${{ steps.set-defaults.outputs.add_dsm72_builds }} - add_dsm71_builds: ${{ steps.set-defaults.outputs.add_dsm71_builds }} - add_dsm62_builds: ${{ steps.set-defaults.outputs.add_dsm62_builds }} - add_dsm52_builds: ${{ steps.set-defaults.outputs.add_dsm52_builds }} - add_srm12_builds: ${{ steps.set-defaults.outputs.add_srm12_builds }} + has_min_dsm72_packages: ${{ steps.dependencies.outputs.has_min_dsm72_packages }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -111,18 +105,6 @@ jobs: GH_FILES: ${{ steps.getfile.outputs.files }} ${{ steps.getfile_pr.outputs.files }} SPK_TO_BUILD: ${{ github.event.inputs.package }} - # Set default values for all builds (manual or automated) - - name: Set default values for generate matrix - id: set-defaults - run: | - echo "add_noarch_builds=${{ github.event.inputs.add_noarch_builds || steps.dependencies.outputs.has_noarch_packages }}" >> $GITHUB_OUTPUT - echo "add_noarch_dsm72_builds=${{ github.event.inputs.add_noarch_dsm72_builds || (steps.dependencies.outputs.has_noarch_packages && steps.dependencies.outputs.has_min_dsm72_packages) }}" >> $GITHUB_OUTPUT - echo "add_dsm72_builds=${{ github.event.inputs.add_dsm72_builds || (steps.dependencies.outputs.has_arch_packages && steps.dependencies.outputs.has_min_dsm72_packages) }}" >> $GITHUB_OUTPUT - echo "add_dsm71_builds=${{ github.event.inputs.add_dsm71_builds || steps.dependencies.outputs.has_arch_packages }}" >> $GITHUB_OUTPUT - echo "add_dsm62_builds=${{ github.event.inputs.add_dsm62_builds || steps.dependencies.outputs.has_arch_packages }}" >> $GITHUB_OUTPUT - echo "add_dsm52_builds=${{ github.event.inputs.add_dsm52_builds || 'false' }}" >> $GITHUB_OUTPUT - echo "add_srm12_builds=${{ github.event.inputs.add_srm12_builds || 'false' }}" >> $GITHUB_OUTPUT - - name: Cache downloaded files uses: actions/cache@v4 with: @@ -137,26 +119,75 @@ jobs: ARCH_PACKAGES: ${{ needs.prepare.outputs.arch_packages }} NOARCH_PACKAGES: ${{ needs.prepare.outputs.noarch_packages }} - generate_matrix: - name: Generate Matrix - needs: prepare + set-defaults: + name: Set Defaults runs-on: ubuntu-latest + needs: prepare outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + add_noarch_builds: ${{ steps.defaults.outputs.add_noarch_builds }} + add_noarch_dsm72_builds: ${{ steps.defaults.outputs.add_noarch_dsm72_builds }} + add_dsm72_builds: ${{ steps.defaults.outputs.add_dsm72_builds }} + add_dsm71_builds: ${{ steps.defaults.outputs.add_dsm71_builds }} + add_dsm62_builds: ${{ steps.defaults.outputs.add_dsm62_builds }} + add_dsm52_builds: ${{ steps.defaults.outputs.add_dsm52_builds }} + add_srm12_builds: ${{ steps.defaults.outputs.add_srm12_builds }} + has_noarch_packages: ${{ steps.defaults.outputs.has_noarch_packages }} + has_arch_packages: ${{ steps.defaults.outputs.has_arch_packages }} steps: - - id: set-matrix + - id: defaults run: | - # Retrieve values from the prepare step - add_noarch_builds=${{ needs.prepare.outputs.add_noarch_builds }} - add_noarch_dsm72_builds=${{ needs.prepare.outputs.add_noarch_dsm72_builds }} - add_dsm72_builds=${{ needs.prepare.outputs.add_dsm72_builds }} - add_dsm71_builds=${{ needs.prepare.outputs.add_dsm71_builds }} - add_dsm62_builds=${{ needs.prepare.outputs.add_dsm62_builds }} - add_dsm52_builds=${{ needs.prepare.outputs.add_dsm52_builds }} - add_srm12_builds=${{ needs.prepare.outputs.add_srm12_builds }} + # Retrieve user inputs or set fallback defaults + add_noarch_builds=${{ github.event.inputs.add_noarch_builds || 'false' }} + add_noarch_dsm72_builds=${{ github.event.inputs.add_noarch_dsm72_builds || 'false' }} + add_dsm72_builds=${{ github.event.inputs.add_dsm72_builds || 'false' }} + add_dsm71_builds=${{ github.event.inputs.add_dsm71_builds || 'false' }} + add_dsm62_builds=${{ github.event.inputs.add_dsm62_builds || 'false' }} + add_dsm52_builds=${{ github.event.inputs.add_dsm52_builds || 'false' }} + add_srm12_builds=${{ github.event.inputs.add_srm12_builds || 'false' }} + + # Dynamically check for package availability and requirements has_noarch_packages=$([ -n "${{ needs.prepare.outputs.noarch_packages }}" ] && echo "true" || echo "false") has_arch_packages=$([ -n "${{ needs.prepare.outputs.arch_packages }}" ] && echo "true" || echo "false") + has_min_dsm72_packages=${{ needs.prepare.outputs.has_min_dsm72_packages || 'false' }} + + # Dynamic logic for automatic builds + if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then + # Enable noarch builds if noarch packages exist + add_noarch_builds=$([ "$has_noarch_packages" == "true" ] && echo "true" || echo "false") + + # Enable noarch DSM 7.2 builds if noarch packages exist and minimum DSM 7.2 requirements are met + add_noarch_dsm72_builds=$([ "$has_noarch_packages" == "true" ] && [ "$has_min_dsm72_packages" == "true" ] && echo "true" || echo "false") + + # Enable DSM 7.2 builds if arch packages exist and minimum DSM 7.2 requirements are met + add_dsm72_builds=$([ "$has_arch_packages" == "true" ] && [ "$has_min_dsm72_packages" == "true" ] && echo "true" || echo "false") + + # Enable DSM 7.1 builds if arch packages exist + add_dsm71_builds=$([ "$has_arch_packages" == "true" ] && echo "true" || echo "false") + # Enable DSM 6.2 builds if arch packages exist + add_dsm62_builds=$([ "$has_arch_packages" == "true" ] && echo "true" || echo "false") + fi + + # Output all values + echo "add_noarch_builds=$add_noarch_builds" >> $GITHUB_OUTPUT + echo "add_noarch_dsm72_builds=$add_noarch_dsm72_builds" >> $GITHUB_OUTPUT + echo "add_dsm72_builds=$add_dsm72_builds" >> $GITHUB_OUTPUT + echo "add_dsm71_builds=$add_dsm71_builds" >> $GITHUB_OUTPUT + echo "add_dsm62_builds=$add_dsm62_builds" >> $GITHUB_OUTPUT + echo "add_dsm52_builds=$add_dsm52_builds" >> $GITHUB_OUTPUT + echo "add_srm12_builds=$add_srm12_builds" >> $GITHUB_OUTPUT + echo "has_noarch_packages=$has_noarch_packages" >> $GITHUB_OUTPUT + echo "has_arch_packages=$has_arch_packages" >> $GITHUB_OUTPUT + + generate-matrix: + name: Generate Matrix + runs-on: ubuntu-latest + needs: set-defaults + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - id: matrix + run: | # Initialize an empty matrix using jq matrix=$(jq -n '{"include": []}') @@ -165,6 +196,17 @@ jobs: matrix=$(echo "$matrix" | jq --arg arch "$1" '.include += [{"arch": $arch}]') } + # Parse outputs from set-defaults + add_noarch_builds="${{ needs.set-defaults.outputs.add_noarch_builds }}" + add_noarch_dsm72_builds="${{ needs.set-defaults.outputs.add_noarch_dsm72_builds }}" + add_dsm72_builds="${{ needs.set-defaults.outputs.add_dsm72_builds }}" + add_dsm71_builds="${{ needs.set-defaults.outputs.add_dsm71_builds }}" + add_dsm62_builds="${{ needs.set-defaults.outputs.add_dsm62_builds }}" + add_dsm52_builds="${{ needs.set-defaults.outputs.add_dsm52_builds }}" + add_srm12_builds="${{ needs.set-defaults.outputs.add_srm12_builds }}" + has_noarch_packages="${{ needs.set-defaults.outputs.has_noarch_packages }}" + has_arch_packages="${{ needs.set-defaults.outputs.has_arch_packages }}" + # Add noarch builds if [ "$add_noarch_builds" == "true" ] && [ "$has_noarch_packages" == "true" ]; then add_to_matrix "noarch-1.1"