Skip to content

Commit

Permalink
Simplify build process
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Dec 1, 2024
1 parent 67e93b9 commit d5cdf2c
Showing 1 changed file with 5 additions and 46 deletions.
51 changes: 5 additions & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,18 @@ jobs:
runs-on: ubuntu-latest
needs: prepare
outputs:
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 }}
matrix: ${{ steps.defaults.outputs.matrix }}
steps:
- id: defaults
run: |
# Retrieve user inputs or set fallback defaults
# Retrieve inputs and package availability
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' }}
Expand All @@ -168,45 +158,14 @@ jobs:
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
# Build matrix
matrix=$(jq -n '{"include": []}')
# Helper function to add entries to the matrix
add_to_matrix() {
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"
Expand Down Expand Up @@ -262,11 +221,11 @@ jobs:
build:
name: Build
needs: [prepare, set-defaults, generate-matrix]
needs: set-defaults
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
matrix: ${{ fromJSON(needs.set-defaults.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down

0 comments on commit d5cdf2c

Please sign in to comment.