|
1 |
| -name: Build packages |
| 1 | +name: Build packages (on demand) |
2 | 2 |
|
3 | 3 | # This workflow runs when any of the following occur:
|
4 | 4 | # - Run manually
|
| 5 | +# - Invoked from another workflow |
5 | 6 | on:
|
6 |
| - push: |
7 |
| - # Sequence of patterns matched against refs/heads |
8 |
| - branches: |
9 |
| - - "ci/*" |
10 | 7 | workflow_dispatch:
|
11 | 8 | inputs:
|
12 | 9 | revision:
|
13 | 10 | description: "Revision"
|
14 | 11 | type: string
|
15 |
| - required: true |
16 |
| - default: "1" |
| 12 | + default: "0" |
17 | 13 | upload:
|
18 | 14 | description: "Upload ?"
|
19 |
| - type: bool |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + is_stage: |
| 18 | + description: "Is stage ?" |
| 19 | + type: boolean |
| 20 | + default: false |
| 21 | + distribution: |
| 22 | + description: '[ "tar", "rpm", "deb" ]' |
| 23 | + type: string |
| 24 | + default: '[ "rpm", "deb" ]' |
| 25 | + architecture: |
| 26 | + description: '[ "x64", "arm64" ]' |
| 27 | + type: string |
| 28 | + default: '[ "x64" ]' |
| 29 | + checksum: |
| 30 | + description: "Checksum ?" |
| 31 | + type: boolean |
20 | 32 | default: false
|
| 33 | + workflow_call: |
| 34 | + inputs: |
| 35 | + revision: |
| 36 | + description: "Revision" |
| 37 | + type: string |
| 38 | + default: "0" |
| 39 | + upload: |
| 40 | + description: "Upload ?" |
| 41 | + type: boolean |
| 42 | + default: false |
| 43 | + is_stage: |
| 44 | + description: "Is stage ?" |
| 45 | + type: boolean |
| 46 | + default: false |
| 47 | + distribution: |
| 48 | + description: '[ "tar", "rpm", "deb" ]' |
| 49 | + type: string |
| 50 | + default: '[ "rpm", "deb" ]' |
| 51 | + architecture: |
| 52 | + description: '[ "x64", "arm64" ]' |
| 53 | + type: string |
| 54 | + default: '[ "x64" ]' |
| 55 | + checksum: |
| 56 | + description: "Checksum ?" |
| 57 | + type: boolean |
| 58 | + default: false |
| 59 | + secrets: |
| 60 | + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY: |
| 61 | + required: true |
| 62 | + description: "AWS user access key" |
| 63 | + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY: |
| 64 | + required: true |
| 65 | + description: "AWS user secret key" |
21 | 66 |
|
22 | 67 | # ==========================
|
23 | 68 | # Bibliography
|
|
33 | 78 | # | https://docs.github.com/en/actions/learn-github-actions/expressions#example
|
34 | 79 |
|
35 | 80 | jobs:
|
36 |
| - version: |
37 |
| - uses: ./.github/workflows/r_version.yml |
38 |
| - |
39 |
| - commit_sha: |
40 |
| - uses: ./.github/workflows/r_commit_sha.yml |
| 81 | + matrix: |
| 82 | + name: Set up matrix |
| 83 | + runs-on: ubuntu-latest |
| 84 | + outputs: |
| 85 | + matrix: ${{ steps.setup.outputs.matrix }} |
| 86 | + steps: |
| 87 | + - id: setup |
| 88 | + run: | |
| 89 | + matrix=$(jq -cn \ |
| 90 | + --argjson distribution '${{ inputs.distribution }}' \ |
| 91 | + --argjson architecture '${{ inputs.architecture }}' \ |
| 92 | + '{distribution: $distribution, architecture: $architecture}' |
| 93 | + ) |
| 94 | + echo "matrix=$matrix" >> $GITHUB_OUTPUT |
41 | 95 |
|
42 | 96 | build:
|
43 |
| - needs: [version, commit_sha] |
44 |
| - strategy: |
45 |
| - matrix: |
46 |
| - distribution: [tar, rpm, deb] |
47 |
| - architecture: [x64, arm64] |
48 |
| - uses: ./.github/workflows/r_build.yml |
49 |
| - with: |
50 |
| - architecture: ${{ matrix.architecture }} |
51 |
| - distribution: ${{ matrix.distribution }} |
52 |
| - revision: ${{ github.event_name == 'push' && '1' || inputs.revision }} |
53 |
| - name: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} |
54 |
| - |
55 |
| - assemble: |
56 |
| - needs: [version, commit_sha, build] |
57 |
| - strategy: |
58 |
| - matrix: |
59 |
| - distribution: [tar, rpm, deb] |
60 |
| - architecture: [x64, arm64] |
61 |
| - exclude: |
62 |
| - # skip arm64 until we have arm runners |
63 |
| - - architecture: arm64 |
64 |
| - - distribution: tar |
65 |
| - |
66 |
| - uses: ./.github/workflows/r_assemble.yml |
67 |
| - with: |
68 |
| - architecture: ${{ matrix.architecture }} |
69 |
| - distribution: ${{ matrix.distribution }} |
70 |
| - min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} |
71 |
| - |
72 |
| - test: |
73 |
| - needs: [version, commit_sha, assemble] |
| 97 | + needs: [matrix] |
| 98 | + runs-on: ubuntu-latest |
74 | 99 | strategy:
|
75 | 100 | fail-fast: false
|
76 |
| - matrix: |
77 |
| - os: [{ suffix: "amd64", ext: "deb" }, { suffix: "x86_64", ext: "rpm" }] |
78 |
| - uses: ./.github/workflows/r_test.yml |
79 |
| - with: |
80 |
| - package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} |
81 |
| - |
82 |
| - upload: |
83 |
| - needs: [version, commit_sha, test] |
84 |
| - # Upload only on 'workflow_dispatch' event and if 'upload=true' |
85 |
| - if: ${{ github.event_name == 'push' && inputs.upload }} |
86 |
| - uses: ./.github/workflows/r_upload.yml |
87 |
| - with: |
88 |
| - package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} |
89 |
| - secrets: inherit |
| 101 | + matrix: ${{ fromJson(needs.matrix.outputs.matrix) }} |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + - uses: actions/setup-java@v4 |
| 105 | + with: |
| 106 | + distribution: temurin |
| 107 | + java-version: 11 |
| 108 | + |
| 109 | + - name: Setup Gradle |
| 110 | + uses: gradle/actions/setup-gradle@v3 |
| 111 | + |
| 112 | + - name: Provision |
| 113 | + if: ${{ matrix.distribution == 'deb' }} |
| 114 | + run: | |
| 115 | + sudo bash packaging_scripts/provision.sh |
| 116 | +
|
| 117 | + - name: Run `baptizer.sh` (min) |
| 118 | + run: | |
| 119 | + name=$(bash packaging_scripts/baptizer.sh -m \ |
| 120 | + -a ${{ matrix.architecture }} \ |
| 121 | + -d ${{ matrix.distribution }} \ |
| 122 | + -r ${{ inputs.revision }} \ |
| 123 | + ${{ inputs.is_stage && '-x' || '' }} \ |
| 124 | + ) |
| 125 | + echo "name=$name" >> $GITHUB_OUTPUT |
| 126 | + id: min_package |
| 127 | + |
| 128 | + - name: Run `baptizer.sh` |
| 129 | + run: | |
| 130 | + name=$(bash packaging_scripts/baptizer.sh \ |
| 131 | + -a ${{ matrix.architecture }} \ |
| 132 | + -d ${{ matrix.distribution }} \ |
| 133 | + -r ${{ inputs.revision }} \ |
| 134 | + ${{ inputs.is_stage && '-x' || '' }} \ |
| 135 | + ) |
| 136 | + echo "name=$name" >> $GITHUB_OUTPUT |
| 137 | + id: package |
| 138 | + |
| 139 | + - name: Run `build.sh` |
| 140 | + run: | |
| 141 | + bash packaging_scripts/build.sh \ |
| 142 | + -a ${{ matrix.architecture }} \ |
| 143 | + -d ${{ matrix.distribution }} \ |
| 144 | + -n ${{ steps.min_package.outputs.name }} |
| 145 | +
|
| 146 | + - name: Run `assemble.sh` |
| 147 | + run: | |
| 148 | + bash packaging_scripts/assemble.sh \ |
| 149 | + -a ${{ matrix.architecture }} \ |
| 150 | + -d ${{ matrix.distribution }} \ |
| 151 | + -r ${{ inputs.revision }} |
| 152 | +
|
| 153 | + - name: Test RPM package |
| 154 | + if: ${{ matrix.distribution == 'rpm' }} |
| 155 | + uses: addnab/docker-run-action@v3 |
| 156 | + with: |
| 157 | + image: redhat/ubi9:latest |
| 158 | + options: -v ${{ github.workspace }}/artifacts/dist:/artifacts/dist |
| 159 | + run: | |
| 160 | + yum localinstall "/artifacts/dist/${{ steps.package.outputs.name }}" -y |
| 161 | +
|
| 162 | + - name: Test DEB package |
| 163 | + if: ${{ matrix.distribution == 'deb' }} |
| 164 | + run: | |
| 165 | + sudo dpkg -i "artifacts/dist/${{ steps.package.outputs.name }}" |
| 166 | +
|
| 167 | + - name: Upload artifact |
| 168 | + uses: actions/upload-artifact@v4 |
| 169 | + with: |
| 170 | + name: ${{ steps.package.outputs.name }} |
| 171 | + path: artifacts/dist/${{ steps.package.outputs.name }} |
| 172 | + if-no-files-found: error |
| 173 | + |
| 174 | + - name: Set up AWS CLI |
| 175 | + if: ${{ inputs.upload }} |
| 176 | + uses: aws-actions/configure-aws-credentials@v4 |
| 177 | + with: |
| 178 | + aws-access-key-id: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY }} |
| 179 | + aws-secret-access-key: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY }} |
| 180 | + aws-region: us-east-1 |
| 181 | + |
| 182 | + - name: Upload package to S3 |
| 183 | + if: ${{ inputs.upload }} |
| 184 | + run: | |
| 185 | + src="artifacts/dist/${{ steps.package.outputs.name }}" |
| 186 | + dest="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/" |
| 187 | + aws s3 cp "$src" "$dest" |
| 188 | +
|
| 189 | + - name: Upload checksum to S3 |
| 190 | + if: ${{ inputs.upload && inputs.checksum }} |
| 191 | + run: | |
| 192 | + src="artifacts/dist/${{ steps.package.outputs.name }}.sha512" |
| 193 | + dest="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/" |
| 194 | + aws s3 cp "$src" "$dest" |
0 commit comments