summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/.github/actions/generate-package-build-matrix/action.yaml
blob: f8355e4bb361996eab14617a599965cc45a6b0f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Composite action to generate the matrix of targets to build packages for.
description: Remove any duplication of this information so we only have to update in one place.

# Remember to add any new checks and target creation required.
# For example, when 2.0 comes out we should detect it and add any target changes.

inputs:
  target:
    description: Override to build a single target for debug/test only.
    required: false
    default: ""
  ref:
    description: The commit, tag or branch of Fluent Bit to checkout for building we then use to determine version for.
    required: true
outputs:
  build-matrix:
    description: The total build matrix we have created.
    value: ${{ steps.set-matrix.outputs.matrix }}
  deb-build-matrix:
    description: The targets that provide DEB artefacts.
    value: ${{ steps.set-matrix.outputs.debmatrix }}
  rpm-build-matrix:
    description: The targets that provide RPN artefacts.
    value: ${{ steps.set-matrix.outputs.rpmmatrix }}
runs:
  using: "composite"
  steps:
    - name: Checkout code for version check
      uses: actions/checkout@v3
      with:
        ref: ${{ inputs.ref }}
        path: version-check

    - name: Determine target type
      id: determine-build-type
      run: |
        BUILD_TYPE="legacy"
        if [[ -f "packaging/build-config.json" ]]; then
          BUILD_TYPE="modern"
        fi
        echo "Detected type: $BUILD_TYPE"
        echo "BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_OUTPUT
      shell: bash
      working-directory: version-check

    - name: 2.0+ targets
      if: steps.determine-build-type.outputs.BUILD_TYPE == 'modern'
      run: |
        matrix=$(echo '{ "distro" : '$(jq -cr '.linux_targets|map(.target)' packaging/build-config.json)'}'|jq -c .)
        echo "MATRIX=$matrix" >> $GITHUB_ENV

        # The following are only used by release so exclude architecture as well

        debtargets=$(jq -cr '[.linux_targets[] | select(.target|contains("arm64v8")|not) | select(.type=="deb") | .target ]' packaging/build-config.json)
        debmatrix=$(echo "{ \"distro\" : $debtargets }"|jq -c .)
        echo "DEB_MATRIX=$debmatrix" >> $GITHUB_ENV

        rpmtargets=$(jq -cr '[.linux_targets[] | select(.target|contains("arm64v8")|not) | select(.type=="rpm") | .target ]' packaging/build-config.json)
        rpmmatrix=$(echo "{ \"distro\" : $rpmtargets}"|jq -c .)
        echo "RPM_MATRIX=$rpmmatrix" >> $GITHUB_ENV
      shell: bash

    - name: 1.9 targets
      if: steps.determine-build-type.outputs.BUILD_TYPE == 'legacy'
      run: |
        matrix=$((
          echo '{ "distro" : ['
          echo '"amazonlinux/2", "amazonlinux/2.arm64v8",'
          echo '"centos/7", "centos/7.arm64v8", "centos/8", "centos/8.arm64v8",'
          echo '"debian/buster", "debian/buster.arm64v8", "debian/bullseye", "debian/bullseye.arm64v8",'
          echo '"ubuntu/16.04", "ubuntu/18.04", "ubuntu/20.04", "ubuntu/22.04",'
          echo '"ubuntu/18.04.arm64v8", "ubuntu/20.04.arm64v8", "ubuntu/22.04.arm64v8",'
          echo '"raspbian/buster", "raspbian/bullseye"'
          echo ']}'
        ) | jq -c .)
        echo "MATRIX=$matrix" >> $GITHUB_ENV
        debmatrix=$((
          echo '{ "distro" : ['
          echo '"debian/buster", "debian/bullseye",'
          echo '"ubuntu/16.04", "ubuntu/18.04", "ubuntu/20.04", "ubuntu/22.04",'
          echo '"raspbian/buster", "raspbian/bullseye"'
          echo ']}'
        ) | jq -c .)
        echo "DEB_MATRIX=$debmatrix" >> $GITHUB_ENV
        rpmmatrix=$((
          echo '{ "distro" : ['
          echo '"amazonlinux/2",'
          echo '"centos/7", "centos/8"'
          echo ']}'
        ) | jq -c .)
        echo "RPM_MATRIX=$rpmmatrix" >> $GITHUB_ENV
      shell: bash

    - name: Manual override of target
      if: inputs.target != ''
      run: |
        if [ -n "${{ inputs.target || '' }}" ]; then
          echo "Overriding matrix to build: ${{ inputs.target }}"
          matrix=$((
            echo '{ "distro" : ['
            echo '"${{ inputs.target }}"'
            echo ']}'
          ) | jq -c .)
        fi
        echo "MATRIX=$matrix" >> $GITHUB_ENV
      shell: bash

    - id: set-matrix
      run: |
        echo $MATRIX
        echo $MATRIX| jq .
        echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
        echo $DEB_MATRIX
        echo $DEB_MATRIX| jq .
        echo "debmatrix=$DEB_MATRIX" >> $GITHUB_OUTPUT
        echo $RPM_MATRIX
        echo $RPM_MATRIX| jq .
        echo "rpmmatrix=$RPM_MATRIX" >> $GITHUB_OUTPUT
      shell: bash