Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change build action #124

Merged
merged 13 commits into from
Dec 19, 2023
49 changes: 35 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,39 @@
name: Build

on:
workflow_dispatch
workflow_call:
inputs:
CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'master'
description: 'The branch/tag/commit to checkout to'
required: true
default: ''
type: string
workflow_dispatch:
inputs:
CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'master'
description: 'The branch/tag/commit to checkout to'
required: true
default: ''

jobs:
generate-linux-image:
build:
runs-on: ubuntu-latest
name: Generate Linux image
name: Build
defaults:
run:
working-directory: ./artifacts
strategy:
matrix:
include:
- name: Linux x64
ext: tar.gz
suffix: linux-x64
script: build-platform --linux --skip-os-packages --release
DISTRIBUTION: [ tar.gz ]
ARCHITECTURE: [ x64 ]

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: wazuh/wazuh-dashboard
path: ./artifacts
ref: ${{ inputs.CHECKOUT_TO }}

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -52,20 +63,30 @@ jobs:
- name: Get package version
run: |
echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
echo "WZD_VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV
echo "WZD_REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV

- name: Get artifact build name
run: |
echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $GITHUB_ENV
echo "ARTIFACT_BUILD_NAME=wazuh-dashboard_${{ env.WZD_VERSION }}-${{ env.WZD_REVISION }}_${{ matrix.ARCHITECTURE }}_${{ inputs.CHECKOUT_TO }}.${{ matrix.DISTRIBUTION }}" >> $GITHUB_ENV

- name: Run bootstrap
run: yarn osd bootstrap

- name: Build `${{ matrix.name }}`
run: yarn ${{ matrix.script }} --release
- name: Build linux-x64
if: matrix.ARCHITECTURE == 'x64'
run: yarn build-platform --linux --skip-os-packages --release

- name: Build linux-arm64
if: matrix.ARCHITECTURE == 'arm64'
run: yarn build-platform --linux-arm --skip-os-packages --release

- name: Rename artifact
run: mv /home/runner/work/wazuh-dashboard/wazuh-dashboard/artifacts/target/opensearch-dashboards-${{ env.VERSION }}-linux-${{ matrix.ARCHITECTURE }}.${{ matrix.DISTRIBUTION }} /home/runner/work/wazuh-dashboard/wazuh-dashboard/artifacts/target/${{ env.ARTIFACT_BUILD_NAME }}

- uses: actions/upload-artifact@v3
if: success()
with:
name: ${{ matrix.suffix }}-${{ env.VERSION }}
name: ${{ env.ARTIFACT_BUILD_NAME }}
path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }}
retention-days: 30
retention-days: 30
212 changes: 212 additions & 0 deletions .github/workflows/build_wazuh_dashboard_with_plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
name: Build final packages

on:
workflow_dispatch:
inputs:
REFERENCE_SECURITY_PLUGIN:
description: 'Reference Wazuh security packages (branch/tag/commit)'
required: true
default: ''
REFERENCE_WAZUH_PLUGINS:
description: 'Reference Wazuh plugins (branch/tag/commit)'
required: true
default: ''
REFERENCE_WAZUH_DASHBOARD:
description: 'Reference Wazuh dashboard (branch/tag/commit)'
required: true
default: ''
DISTRIBUTION:
description: 'Distribution to build (deb | rpm | tar | all-platforms)'
required: true
default: ''

jobs:
build-plugins:
name: Build plugins
uses: wazuh/wazuh-dashboard-plugins/.github/workflows/manual-build.yml@master
with:
reference: ${{ inputs.REFERENCE_WAZUH_PLUGINS }}

build-dashboard:
name: Build dashboard
uses: wazuh/wazuh-dashboard/.github/workflows/[email protected]
with:
CHECKOUT_TO: ${{ inputs.REFERENCE_WAZUH_DASHBOARD }}

build-security-plugin:
name: Build security plugin
uses: wazuh/wazuh-security-dashboards-plugin/.github/workflows/[email protected]
with:
reference: ${{ inputs.REFERENCE_SECURITY_PLUGIN }}


Build-base-package:
needs: [build-plugins, build-dashboard, build-security-plugin]
runs-on: ubuntu-latest
name: Generate final packages
strategy:
fail-fast: false
matrix:
# TODO: Add arm64 support
ARCHITECTURE: [ x64 ]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Setup variables
run: |
echo "CURRENT_DIR=$(pwd -P)" >> $GITHUB_ENV
echo "VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV
echo "REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV

- name: Setup packages names
run: |
echo "WAZUH_DASHBOARD_SLIM=wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_${{ matrix.ARCHITECTURE }}_${{ inputs.REFERENCE_WAZUH_DASHBOARD }}.tar.gz" >> $GITHUB_ENV
echo "WAZUH_SECURITY_PLUGIN=wazuh-security-dashboards-plugin_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.REFERENCE_SECURITY_PLUGIN }}.zip" >> $GITHUB_ENV
echo "WAZUH_PLUGINS=wazuh-dashboard-plugins_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.REFERENCE_WAZUH_PLUGINS }}.zip" >> $GITHUB_ENV

- name: Download dashboard artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.WAZUH_DASHBOARD_SLIM }}
path: ${{ env.CURRENT_DIR }}/artifacts/dashboard

- name: Download security plugin artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.WAZUH_SECURITY_PLUGIN }}
path: ${{ env.CURRENT_DIR }}/artifacts/security-plugin

- name: Download plugins artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.WAZUH_PLUGINS }}
path: ${{ env.CURRENT_DIR }}/artifacts/plugins

- name: Zip plugins
run: |
zip -r -j ${{ env.CURRENT_DIR }}/artifacts/wazuh-package.zip ${{ env.CURRENT_DIR }}/artifacts/plugins
zip -r -j ${{ env.CURRENT_DIR }}/artifacts/security-package.zip ${{ env.CURRENT_DIR }}/artifacts/security-plugin
zip -r -j ${{ env.CURRENT_DIR }}/artifacts/dashboard-package.zip ${{ env.CURRENT_DIR }}/artifacts/dashboard/${{ env.WAZUH_DASHBOARD_SLIM }}


- name: Build packages
run: |
cd ${{ env.CURRENT_DIR }}/dev-tools/build-packages
bash ./build-packages.sh \
-v ${{ env.VERSION }} \
-r ${{ env.REVISION }} \
-a file://${{env.CURRENT_DIR}}/artifacts/wazuh-package.zip \
-s file://${{env.CURRENT_DIR}}/artifacts/security-package.zip \
-b file://${{env.CURRENT_DIR}}/artifacts/dashboard-package.zip \
--tar


- name: Upload tar packages
uses: actions/upload-artifact@v3
with:
name: wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}-linux-${{ matrix.ARCHITECTURE }}.tar.gz
path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}-linux-${{ matrix.ARCHITECTURE }}.tar.gz
retention-days: 30

build-deb-package:
needs: [Build-base-package]
if: ( contains(inputs.DISTRIBUTION, 'deb') || contains(inputs.DISTRIBUTION, 'all-platforms') )
runs-on: ubuntu-latest
name: Build deb package
strategy:
fail-fast: false
matrix:
# TODO: Add arm64 support
ARCHITECTURE: [ x64 ]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Setup variables
run: |
echo "CURRENT_DIR=$(pwd -P)" >> $GITHUB_ENV
echo "VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV
echo "REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV

- name: Download dashboard artifact
uses: actions/download-artifact@v3
with:
name: wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}-linux-${{ matrix.ARCHITECTURE }}.tar.gz
path: ${{ env.CURRENT_DIR }}/artifacts/dashboard-tar

- name: Build packages
run: |
cd ${{ env.CURRENT_DIR }}/dev-tools/build-packages/deb/
bash ./launcher.sh \
-v ${{ env.VERSION }} \
-r ${{ env.REVISION }} \
-p file://${{env.CURRENT_DIR}}/artifacts/dashboard-tar/wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}-linux-${{ matrix.ARCHITECTURE }}.tar.gz

- name: Upload deb packages
uses: actions/upload-artifact@v3
if: success()
with:
name: wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64.deb
path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/deb/output/wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64.deb
retention-days: 30


build-rpm-package:
needs: [Build-base-package]
if: ( contains(inputs.DISTRIBUTION, 'rpm') || contains(inputs.DISTRIBUTION, 'all-platforms') )
runs-on: ubuntu-latest
name: Build rpm package
strategy:
fail-fast: false
matrix:
ARCHITECTURE: [ x64 ]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Setup variables
run: |
echo "CURRENT_DIR=$(pwd -P)" >> $GITHUB_ENV
echo "VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV
echo "REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV

- name: Download dashboard artifact
uses: actions/download-artifact@v3
with:
name: wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}-linux-${{ matrix.ARCHITECTURE }}.tar.gz
path: ${{ env.CURRENT_DIR }}/artifacts/dashboard-tar

- name: Build packages
run: |
cd ${{ env.CURRENT_DIR }}/dev-tools/build-packages/rpm/
bash ./launcher.sh \
-v ${{ env.VERSION }} \
-r ${{ env.REVISION }} \
-p file://${{env.CURRENT_DIR}}/artifacts/dashboard-tar/wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}-linux-${{ matrix.ARCHITECTURE }}.tar.gz

- name: Upload rpm packages
uses: actions/upload-artifact@v3
if: success()
with:
name: wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}.x86_64.rpm
path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/rpm/output/wazuh-dashboard-${{ env.VERSION }}-${{ env.REVISION }}.x86_64.rpm
retention-days: 30
5 changes: 3 additions & 2 deletions dev-tools/build-packages/base/generate_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ build() {
mkdir -p $tmp_dir
cd $tmp_dir
mkdir -p applications
mkdir -p dashboards
if [[ $app =~ $valid_url ]]; then
if ! curl --output applications/app.zip --silent --fail "${app}"; then
echo "The given URL or Path to the Wazuh Apps is not working: ${app}"
Expand All @@ -83,9 +84,9 @@ build() {
clean 1
else
echo "Extracting Wazuh Dashboard base"
unzip -q wazuh-dashboard.zip -d .
unzip -q wazuh-dashboard.zip -d ./dashboards/
rm wazuh-dashboard.zip
mv $(ls | grep wazuh-dashboard) wazuh-dashboard.tar.gz
mv ./dashboards/$(ls ./dashboards) wazuh-dashboard.tar.gz
fi
else
if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${base}"; then
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"sha": "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9"
},
"wazuh": {
"version": "4.9.0"
"version": "4.9.0",
"revision": "00"
},
"homepage": "https://opensearch.org",
"bugs": {
Expand Down Expand Up @@ -77,7 +78,9 @@
"docs:acceptApiChanges": "scripts/use_node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"osd:bootstrap": "scripts/use_node scripts/build_ts_refs && scripts/use_node scripts/register_git_hook",
"spec_to_console": "scripts/use_node scripts/spec_to_console",
"pkg-version": "scripts/use_node -e \"console.log(require('./package.json').version)\""
"pkg-version": "scripts/use_node -e \"console.log(require('./package.json').version)\"",
"wzd-revision": "scripts/use_node -e \"console.log(require('./package.json').wazuh.revision)\"",
"wzd-version": "scripts/use_node -e \"console.log(require('./package.json').wazuh.version)\""
},
"repository": {
"type": "git",
Expand Down
Loading