|
| 1 | +name: Composite action to generate the matrix of targets to build packages for. |
| 2 | +description: Remove any duplication of this information so we only have to update in one place. |
| 3 | + |
| 4 | +# Remember to add any new checks and target creation required. |
| 5 | +# For example, when 2.0 comes out we should detect it and add any target changes. |
| 6 | + |
| 7 | +inputs: |
| 8 | + target: |
| 9 | + description: Override to build a single target for debug/test only. |
| 10 | + required: false |
| 11 | + default: "" |
| 12 | + ref: |
| 13 | + description: The commit, tag or branch of Fluent Bit to checkout for building we then use to determine version for. |
| 14 | + required: true |
| 15 | +outputs: |
| 16 | + build-matrix: |
| 17 | + description: The total build matrix we have created. |
| 18 | + value: ${{ steps.set-matrix.outputs.matrix }} |
| 19 | + deb-build-matrix: |
| 20 | + description: The targets that provide DEB artefacts. |
| 21 | + value: ${{ steps.set-matrix.outputs.debmatrix }} |
| 22 | + rpm-build-matrix: |
| 23 | + description: The targets that provide RPN artefacts. |
| 24 | + value: ${{ steps.set-matrix.outputs.rpmmatrix }} |
| 25 | +runs: |
| 26 | + using: "composite" |
| 27 | + steps: |
| 28 | + - name: Checkout code for version check |
| 29 | + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 30 | + with: |
| 31 | + ref: ${{ inputs.ref }} |
| 32 | + path: version-check |
| 33 | + persist-credentials: false |
| 34 | + |
| 35 | + - name: Determine target type |
| 36 | + id: determine-build-type |
| 37 | + run: | |
| 38 | + BUILD_TYPE="legacy" |
| 39 | + if [[ -f "packaging/build-config.json" ]]; then |
| 40 | + BUILD_TYPE="modern" |
| 41 | + fi |
| 42 | + echo "Detected type: $BUILD_TYPE" |
| 43 | + echo "BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_OUTPUT |
| 44 | + shell: bash |
| 45 | + working-directory: version-check |
| 46 | + |
| 47 | + - name: 2.0+ targets |
| 48 | + if: steps.determine-build-type.outputs.BUILD_TYPE == 'modern' |
| 49 | + run: | |
| 50 | + matrix=$(echo '{ "distro" : '$(jq -cr '.linux_targets|map(.target)' packaging/build-config.json)'}'|jq -c .) |
| 51 | + echo "MATRIX=$matrix" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + # The following are only used by release so exclude architecture as well |
| 54 | +
|
| 55 | + debtargets=$(jq -cr '[.linux_targets[] | select(.target|contains("arm64v8")|not) | select(.type=="deb") | .target ]' packaging/build-config.json) |
| 56 | + debmatrix=$(echo "{ \"distro\" : $debtargets }"|jq -c .) |
| 57 | + echo "DEB_MATRIX=$debmatrix" >> $GITHUB_ENV |
| 58 | +
|
| 59 | + rpmtargets=$(jq -cr '[.linux_targets[] | select(.target|contains("arm64v8")|not) | select(.type=="rpm") | .target ]' packaging/build-config.json) |
| 60 | + rpmmatrix=$(echo "{ \"distro\" : $rpmtargets}"|jq -c .) |
| 61 | + echo "RPM_MATRIX=$rpmmatrix" >> $GITHUB_ENV |
| 62 | + shell: bash |
| 63 | + |
| 64 | + - name: 1.9 targets |
| 65 | + if: steps.determine-build-type.outputs.BUILD_TYPE == 'legacy' |
| 66 | + run: | |
| 67 | + matrix=$(( |
| 68 | + echo '{ "distro" : [' |
| 69 | + echo '"amazonlinux/2", "amazonlinux/2.arm64v8",' |
| 70 | + echo '"centos/7", "centos/7.arm64v8", "centos/8", "centos/8.arm64v8",' |
| 71 | + echo '"debian/buster", "debian/buster.arm64v8", "debian/bullseye", "debian/bullseye.arm64v8",' |
| 72 | + echo '"ubuntu/16.04", "ubuntu/18.04", "ubuntu/20.04", "ubuntu/22.04",' |
| 73 | + echo '"ubuntu/18.04.arm64v8", "ubuntu/20.04.arm64v8", "ubuntu/22.04.arm64v8",' |
| 74 | + echo '"raspbian/buster", "raspbian/bullseye"' |
| 75 | + echo ']}' |
| 76 | + ) | jq -c .) |
| 77 | + echo "MATRIX=$matrix" >> $GITHUB_ENV |
| 78 | + debmatrix=$(( |
| 79 | + echo '{ "distro" : [' |
| 80 | + echo '"debian/buster", "debian/bullseye",' |
| 81 | + echo '"ubuntu/16.04", "ubuntu/18.04", "ubuntu/20.04", "ubuntu/22.04",' |
| 82 | + echo '"raspbian/buster", "raspbian/bullseye"' |
| 83 | + echo ']}' |
| 84 | + ) | jq -c .) |
| 85 | + echo "DEB_MATRIX=$debmatrix" >> $GITHUB_ENV |
| 86 | + rpmmatrix=$(( |
| 87 | + echo '{ "distro" : [' |
| 88 | + echo '"amazonlinux/2",' |
| 89 | + echo '"centos/7", "centos/8"' |
| 90 | + echo ']}' |
| 91 | + ) | jq -c .) |
| 92 | + echo "RPM_MATRIX=$rpmmatrix" >> $GITHUB_ENV |
| 93 | + shell: bash |
| 94 | + |
| 95 | + - name: Manual override of target |
| 96 | + if: inputs.target != '' |
| 97 | + run: | |
| 98 | + if [ -n "${{ inputs.target || '' }}" ]; then |
| 99 | + echo "Overriding matrix to build: ${{ inputs.target }}" |
| 100 | + matrix=$(( |
| 101 | + echo '{ "distro" : [' |
| 102 | + echo '"${{ inputs.target }}"' |
| 103 | + echo ']}' |
| 104 | + ) | jq -c .) |
| 105 | + fi |
| 106 | + echo "MATRIX=$matrix" >> $GITHUB_ENV |
| 107 | + shell: bash |
| 108 | + |
| 109 | + - id: set-matrix |
| 110 | + run: | |
| 111 | + echo $MATRIX |
| 112 | + echo $MATRIX| jq . |
| 113 | + echo "matrix=$MATRIX" >> $GITHUB_OUTPUT |
| 114 | + echo $DEB_MATRIX |
| 115 | + echo $DEB_MATRIX| jq . |
| 116 | + echo "debmatrix=$DEB_MATRIX" >> $GITHUB_OUTPUT |
| 117 | + echo $RPM_MATRIX |
| 118 | + echo $RPM_MATRIX| jq . |
| 119 | + echo "rpmmatrix=$RPM_MATRIX" >> $GITHUB_OUTPUT |
| 120 | + shell: bash |
0 commit comments