|
| 1 | +# This is a basic workflow that is manually triggered |
| 2 | +# |
| 3 | +# This workflow automates the build of Wazuh dashboard core for different |
| 4 | +# architectures and distributions. |
| 5 | +# |
| 6 | +# This workflow: |
| 7 | +# - Clone, configure, build and package the Wazuh dashboard core. |
| 8 | +# - Customizable in architecture and reference (`branch/tag/commit`). |
| 9 | +# - Upload the final package with a structured name. |
| 10 | + |
| 11 | +name: (4.x) Build Wazuh dashboard core package (on demand) |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_call: |
| 15 | + inputs: |
| 16 | + CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'main' |
| 17 | + description: 'The branch/tag/commit to checkout to' |
| 18 | + required: true |
| 19 | + default: 'main' |
| 20 | + type: string |
| 21 | + ARCHITECTURE: |
| 22 | + description: 'The architecture to build the package for' |
| 23 | + required: true |
| 24 | + default: 'amd64' |
| 25 | + type: string |
| 26 | + |
| 27 | + workflow_dispatch: |
| 28 | + inputs: |
| 29 | + CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'main' |
| 30 | + description: 'The branch/tag/commit to checkout to' |
| 31 | + required: true |
| 32 | + default: 'main' |
| 33 | + ARCHITECTURE: |
| 34 | + description: 'The architecture to build the package for' |
| 35 | + required: true |
| 36 | + default: 'amd64' |
| 37 | + type: string |
| 38 | + |
| 39 | +jobs: |
| 40 | + build: |
| 41 | + runs-on: ${{ (inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'ubuntu-latest' || 'wz-linux-arm64' }} |
| 42 | + name: Build |
| 43 | + defaults: |
| 44 | + run: |
| 45 | + working-directory: ./artifacts |
| 46 | + strategy: |
| 47 | + matrix: |
| 48 | + DISTRIBUTION: [tar.gz] |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@v4 |
| 53 | + with: |
| 54 | + repository: wazuh/wazuh-dashboard |
| 55 | + path: ./artifacts |
| 56 | + ref: ${{ inputs.CHECKOUT_TO }} |
| 57 | + |
| 58 | + - name: Setup Node |
| 59 | + uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version-file: './artifacts/.nvmrc' |
| 62 | + registry-url: 'https://registry.npmjs.org' |
| 63 | + |
| 64 | + - name: Setup Yarn |
| 65 | + run: | |
| 66 | + npm uninstall -g yarn |
| 67 | + npm i -g yarn@1.22.10 |
| 68 | + yarn config set network-timeout 1000000 -g |
| 69 | +
|
| 70 | + - name: Configure Yarn Cache |
| 71 | + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV |
| 72 | + |
| 73 | + - name: Initialize Yarn Cache |
| 74 | + uses: actions/cache@v4 |
| 75 | + with: |
| 76 | + path: ${{ env.YARN_CACHE_LOCATION }} |
| 77 | + key: yarn-${{ hashFiles('**/yarn.lock') }} |
| 78 | + restore-keys: | |
| 79 | + yarn- |
| 80 | +
|
| 81 | + - name: Get package version |
| 82 | + run: | |
| 83 | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV |
| 84 | + echo "WZD_VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV |
| 85 | + echo "WZD_REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV |
| 86 | +
|
| 87 | + - name: Get artifact build name |
| 88 | + run: | |
| 89 | + echo "ARTIFACT_BUILD_NAME=wazuh-dashboard_${{ env.WZD_VERSION }}-${{ env.WZD_REVISION }}_${{ (inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'x64' || 'arm64' }}.${{ matrix.DISTRIBUTION }}" >> $GITHUB_ENV |
| 90 | +
|
| 91 | + - name: Run bootstrap |
| 92 | + run: yarn osd bootstrap |
| 93 | + |
| 94 | + - name: Build |
| 95 | + run: yarn build-platform --${{(inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'linux' || 'linux-arm'}} --skip-os-packages --release |
| 96 | + |
| 97 | + - name: Rename artifact |
| 98 | + run: mv /home/runner/work/wazuh-dashboard/wazuh-dashboard/artifacts/target/opensearch-dashboards-${{ env.VERSION }}-linux-${{ (inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'x64' || 'arm64' }}.${{ matrix.DISTRIBUTION }} /home/runner/work/wazuh-dashboard/wazuh-dashboard/artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} |
| 99 | + |
| 100 | + - uses: actions/upload-artifact@v4 |
| 101 | + if: success() |
| 102 | + with: |
| 103 | + name: ${{ env.ARTIFACT_BUILD_NAME }} |
| 104 | + path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} |
| 105 | + retention-days: 30 |
| 106 | + overwrite: true |
0 commit comments