diff --git a/.github/workflows/build.yml b/.github/workflows/build_base.yml similarity index 99% rename from .github/workflows/build.yml rename to .github/workflows/build_base.yml index 8baaf0415e3c..6b011be45faa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build_base.yml @@ -1,6 +1,6 @@ # This is a basic workflow that is manually triggered -name: Build +name: Build base on: workflow_call: @@ -10,6 +10,7 @@ on: required: true default: '' type: string + workflow_dispatch: inputs: CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'master' diff --git a/.github/workflows/build_wazuh_dashboard_with_plugins.yml b/.github/workflows/build_wazuh_dashboard_with_plugins.yml index 6f9542309686..b0502402152a 100644 --- a/.github/workflows/build_wazuh_dashboard_with_plugins.yml +++ b/.github/workflows/build_wazuh_dashboard_with_plugins.yml @@ -1,62 +1,92 @@ -name: Build final packages +name: Build 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: + system: type: choice - description: 'Distribution to build' + description: 'Package OS' required: true options: - deb - rpm - - all-platforms - S3UPLOAD: - description: 'Upload to S3' + default: 'deb' + architecture: + type: choice + description: 'Package architecture' + required: true + options: + - amd64 + - x86_64 + default: amd64 + revision: + type: string + description: 'Package revision' + required: true + default: '0' + reference_security_plugins: + type: string + description: 'Branch/tag/commit of the wazuh-security-dashboards-plugin repository to build the security plugin' + required: true + default: 'master' + reference_wazuh_plugins: + type: string + description: 'Branch/tag/commit of the wazuh-dashboard-plugins repository to build the main plugins' + required: true + default: 'master' + is_stage: type: boolean + description: 'Set production nomenclature' required: true + default: false + checksum: + type: boolean + description: 'Generate package checksum' + required: true + default: false + jobs: - build-plugins: - name: Build plugins - uses: wazuh/wazuh-dashboard-plugins/.github/workflows/manual-build.yml@master + validate-inputs: + runs-on: ubuntu-latest + name: Validate inputs + steps: + - name: Validate inputs + run: | + if [ "${{ inputs.architecture }}" = "amd64" ] && [ "${{ inputs.system }}" = "rpm" ]; then + echo "Invalid combination of architecture and system" + exit 1 + fi + if [ "${{ inputs.architecture }}" = "x86_64" ] && [ "${{ inputs.system }}" = "deb" ]; then + echo "Invalid combination of architecture and system" + exit 1 + fi + + build-base: + needs: [validate-inputs] + name: Build dashboard + uses: wazuh/wazuh-dashboard/.github/workflows/build_base.yml@4.9.0 with: - reference: ${{ inputs.REFERENCE_WAZUH_PLUGINS }} + CHECKOUT_TO: ${{ github.head_ref || github.ref_name }} - build-dashboard: - name: Build dashboard - uses: wazuh/wazuh-dashboard/.github/workflows/build.yml@4.9.0 + build-main-plugins: + needs: [validate-inputs] + name: Build plugins + uses: wazuh/wazuh-dashboard-plugins/.github/workflows/manual-build.yml@master with: - CHECKOUT_TO: ${{ inputs.REFERENCE_WAZUH_DASHBOARD }} + reference: ${{ inputs.reference_wazuh_plugins }} build-security-plugin: + needs: [validate-inputs] name: Build security plugin uses: wazuh/wazuh-security-dashboards-plugin/.github/workflows/manual-build.yml@4.9.0 with: - reference: ${{ inputs.REFERENCE_SECURITY_PLUGIN }} - + reference: ${{ inputs.reference_security_plugins }} - Build-base-package: - needs: [build-plugins, build-dashboard, build-security-plugin] + build-and-test-package: + needs: [build-main-plugins, build-base, build-security-plugin] runs-on: ubuntu-latest - name: Generate final packages - strategy: - fail-fast: false - matrix: - # TODO: Add arm64 support - ARCHITECTURE: [ x64 ] + name: Generate packages steps: - name: Checkout code uses: actions/checkout@v4 @@ -70,14 +100,31 @@ jobs: - name: Setup variables run: | echo "CURRENT_DIR=$(pwd -P)" >> $GITHUB_ENV - echo "VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV + echo "VERSION=$(tail -c +2 VERSION)" >> $GITHUB_ENV echo "REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV + echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + if [ "${{ inputs.is_stage }}" = "true" ]; then + echo "PRODUCTION=--production" >> $GITHUB_ENV + fi - 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 + echo "WAZUH_DASHBOARD_SLIM=wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x64_${{ github.head_ref || github.ref_name }}.tar.gz" >> $GITHUB_ENV + echo "WAZUH_SECURITY_PLUGIN=wazuh-security-dashboards-plugin_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.reference_security_plugins }}.zip" >> $GITHUB_ENV + echo "WAZUH_PLUGINS=wazuh-dashboard-plugins_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.reference_wazuh_plugins }}.zip" >> $GITHUB_ENV + if [ "${{ inputs.system }}" = "deb" ]; then + if [ "${{ inputs.is_stage }}" = "true" ]; then + echo "PACKAGE_NAME=wazuh-dashboard_${{ env.VERSION }}-${{ inputs.revision }}_${{ inputs.architecture }}.deb" >> $GITHUB_ENV + else + echo "PACKAGE_NAME=wazuh-dashboard_${{ env.VERSION }}-${{ inputs.revision }}_${{ inputs.architecture }}_${{ env.COMMIT_SHA}}.deb" >> $GITHUB_ENV + fi + else + if [ "${{ inputs.is_stage }}" = "true" ]; then + echo "PACKAGE_NAME=wazuh-dashboard-${{ env.VERSION }}-${{ inputs.revision }}.${{ inputs.architecture }}.rpm" >> $GITHUB_ENV + else + echo "PACKAGE_NAME=wazuh-dashboard_${{ env.VERSION }}-${{ inputs.revision }}_${{ inputs.architecture }}_${{ env.COMMIT_SHA}}.rpm" >> $GITHUB_ENV + fi + fi - name: Download dashboard artifact uses: actions/download-artifact@v3 @@ -103,218 +150,25 @@ jobs: 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 + - name: Build package run: | cd ${{ env.CURRENT_DIR }}/dev-tools/build-packages bash ./build-packages.sh \ -v ${{ env.VERSION }} \ - -r ${{ env.REVISION }} \ + -r ${{ inputs.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 - echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $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_${{env.COMMIT_SHA}}.deb - path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/deb/output/wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64_${{ env.COMMIT_SHA}}.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 - echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $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 + --${{ inputs.system }} ${{ env.PRODUCTION }} - - 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_${{env.COMMIT_SHA}}.rpm - path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/rpm/output/wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x86_64_${{ env.COMMIT_SHA}}.rpm - retention-days: 30 - - test-package-deb: - needs: [build-deb-package] - runs-on: ubuntu-latest - name: Test packages - strategy: - fail-fast: false - 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 - echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - - name: Download deb package - uses: actions/download-artifact@v3 - with: - name: wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64_${{env.COMMIT_SHA}}.deb - path: ${{ env.CURRENT_DIR }}/dev-tools/test-packages/deb - - - name: Run test - run: | - cd ${{ env.CURRENT_DIR }}/dev-tools/test-packages - bash ./test-packages.sh \ - -p wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64_${{env.COMMIT_SHA}}.deb - - - test-package-rpm: - needs: [build-rpm-package] - runs-on: ubuntu-latest - name: Test packages - strategy: - fail-fast: false - 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 - echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - - name: Download rpm package - uses: actions/download-artifact@v3 - with: - name: wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x86_64_${{env.COMMIT_SHA}}.rpm - path: ${{ env.CURRENT_DIR }}/dev-tools/test-packages/rpm - - - name: Run test + - name: Test package run: | cd ${{ env.CURRENT_DIR }}/dev-tools/test-packages - ls -lah ${{ env.CURRENT_DIR }}/dev-tools/test-packages/rpm - ls -lah + ls -la ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }} + cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.PACKAGE_NAME}} ${{ env.CURRENT_DIR }}/dev-tools/test-packages/${{ inputs.system }} bash ./test-packages.sh \ - -p wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x86_64_${{env.COMMIT_SHA}}.rpm - - upload-to-s3: - needs: [test-package-rpm, test-package-deb] - if: | - always() && inputs.S3UPLOAD && contains(needs.*.result, 'success') && !contains(needs.*.result, 'failure') - runs-on: ubuntu-latest - name: Upload to S3 - 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 - echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + -p ${{env.PACKAGE_NAME}} - name: Set up AWS CLI uses: aws-actions/configure-aws-credentials@v1 @@ -323,27 +177,11 @@ jobs: aws-secret-access-key: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY }} aws-region: us-east-1 - - name: Download deb package - if: contains(needs.test-package-deb.result, 'success') - uses: actions/download-artifact@v3 - with: - name: wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64_${{env.COMMIT_SHA}}.deb - path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/deb/ - - - name: Upload deb to S3 - if: contains(needs.test-package-deb.result, 'success') - run: | - echo "Uploading deb package" - aws s3 cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/deb/wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_amd64_${{env.COMMIT_SHA}}.deb s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/ - - - name: Download rpm package - if: contains(needs.test-package-rpm.result, 'success') - uses: actions/download-artifact@v3 - with: - name: wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x86_64_${{env.COMMIT_SHA}}.rpm - path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/rpm - - - name: Upload rpm to S3 - if: contains(needs.test-package-rpm.result, 'success') + - name: Upload package run: | - aws s3 cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/rpm/wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x86_64_${{env.COMMIT_SHA}}.rpm s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/ + echo "Uploading package" + aws s3 cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.PACKAGE_NAME}} s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/ + if [ "${{ inputs.checksum }}" = "true" ]; then + echo "Uploading checksum" + aws s3 cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.PACKAGE_NAME}}.sha512 s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/ + fi diff --git a/VERSION b/VERSION new file mode 100644 index 000000000000..7bd7ebe25063 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v4.9.0 diff --git a/dev-tools/build-packages/build-packages.sh b/dev-tools/build-packages/build-packages.sh index 9a9b4053ab53..bf2d93f22dc3 100755 --- a/dev-tools/build-packages/build-packages.sh +++ b/dev-tools/build-packages/build-packages.sh @@ -10,7 +10,7 @@ deb="no" rpm="no" tar="no" output="$( cd $(dirname $0) ; pwd -P )/output" - +production="" current_path="$( cd $(dirname $0) ; pwd -P )" build_tar() { @@ -29,7 +29,7 @@ build_deb() { echo "Building deb package..." name_package_tar=$(find $output -name "*.tar.gz") cd ./deb - bash ./launcher.sh -v $version -r $revision -p file://$name_package_tar + bash ./launcher.sh -v $version -r $revision -p file://$name_package_tar $production name_package_tar=$(ls ./output) echo "Moving deb package to $output/deb" mv $current_path/deb/output $output/deb @@ -40,7 +40,7 @@ build_rpm() { echo "Building rpm package..." name_package_tar=$(find $output -name "*.tar.gz") cd ./rpm - bash ./launcher.sh -v $version -r $revision -p file://$name_package_tar + bash ./launcher.sh -v $version -r $revision -p file://$name_package_tar $production echo "Moving rpm package to $output/rpm" mv $current_path/rpm/output $output/rpm cd ../ @@ -90,7 +90,8 @@ help() { echo " --deb Build for deb." echo " --rpm Build for rpm." echo " --tar Build for tar." - echo " -r, --revision [Optional] Set the revision of this build. By default, it is set to 1." + echo " --production [Optional] The naming of the package will be ready for production." + echo " -r, --revision [Optional] Set the revision of this build. By default, it is set to 1." echo " -o, --output [Optional] Set the destination path of package. By default, an output folder will be created." echo " -h, --help Show this help." echo @@ -143,6 +144,10 @@ main() { shift 2 fi ;; + "--production") + production="--production" + shift 1 + ;; "--all-platforms") all_platforms="yes" shift 1 diff --git a/dev-tools/build-packages/deb/builder.sh b/dev-tools/build-packages/deb/builder.sh index 245324079c2e..925997dd4b12 100755 --- a/dev-tools/build-packages/deb/builder.sh +++ b/dev-tools/build-packages/deb/builder.sh @@ -16,6 +16,7 @@ architecture=$1 revision=$2 version=$3 commit_sha=$4 +is_production=$5 directory_base="/usr/share/wazuh-dashboard" # Build directories @@ -50,4 +51,10 @@ debuild --no-lintian -b -uc -us \ -eREVISION="${revision}" cd ${pkg_path} && sha512sum ${deb_file} >/tmp/${deb_file}.sha512 -mv ${pkg_path}/${deb_file} /tmp/${final_name} + +if [ "${is_production}" = "no" ]; then + mv ${pkg_path}/${deb_file} /tmp/${final_name} + mv /tmp/${deb_file}.sha512 /tmp/${final_name}.sha512 +else + mv ${pkg_path}/${deb_file} /tmp/ +fi diff --git a/dev-tools/build-packages/deb/launcher.sh b/dev-tools/build-packages/deb/launcher.sh index 4266fb532f3d..1ccc701f4f96 100755 --- a/dev-tools/build-packages/deb/launcher.sh +++ b/dev-tools/build-packages/deb/launcher.sh @@ -11,10 +11,11 @@ # Inputs package="" version="" -revision="1" +revision="0" architecture="amd64" build_base="yes" build_docker="yes" +is_production="no" # Constants deb_amd64_builder="deb_dashboard_builder_amd64" @@ -84,6 +85,7 @@ build_deb() { tar -zxf wazuh-dashboard.tar.gz rm wazuh-dashboard.tar.gz mv $directory_name wazuh-dashboard-base + jq '.wazuh.revision="'${revision}'"' wazuh-dashboard-base/package.json > pkgtmp.json && mv pkgtmp.json wazuh-dashboard-base/package.json cp $config_path/* wazuh-dashboard-base echo ${version} >wazuh-dashboard-base/VERSION tar -czf ./wazuh-dashboard.tar.gz wazuh-dashboard-base @@ -104,7 +106,7 @@ build_deb() { docker run -t --rm ${volumes} \ -v ${current_path}/../..:/root:Z \ ${container_name} ${architecture} \ - ${revision} ${version} ${commit_sha}\ + ${revision} ${version} ${commit_sha} ${is_production}\ || return 1 echo "Package $(ls -Art ${out_dir} | tail -n 1) added to ${out_dir}." @@ -119,7 +121,7 @@ build_deb() { build() { build_name="${deb_amd64_builder}" file_path="../${deb_builder_dockerfile}/${architecture}" - build_deb ${build_name} ${file_path} ${commit_sha}|| return 1 + build_deb ${build_name} ${file_path} ${commit_sha} ${is_production}|| return 1 return 0 } @@ -132,6 +134,7 @@ help() { echo " -r, --revision [Optional] Package revision. By default: 1." echo " -o, --output [Optional] Set the destination path of package. By default, an output folder will be created." echo " --dont-build-docker [Optional] Locally built Docker image will be used instead of generating a new one." + echo " --production [Optional] The naming of the package will be ready for production." echo " -h, --help Show this help." echo exit $1 @@ -171,6 +174,10 @@ main() { build_docker="no" shift 1 ;; + "--production") + is_production="yes" + shift 1 + ;; "-o" | "--output") if [ -n "${2}" ]; then out_dir="${2}" diff --git a/dev-tools/build-packages/rpm/builder.sh b/dev-tools/build-packages/rpm/builder.sh index 65542dc4fe03..63f5043a77b8 100755 --- a/dev-tools/build-packages/rpm/builder.sh +++ b/dev-tools/build-packages/rpm/builder.sh @@ -16,6 +16,7 @@ architecture=$1 revision=$2 version=$3 commit_sha=$4 +is_production=$5 directory_base="/usr/share/wazuh-dashboard" # Build directories @@ -50,4 +51,7 @@ cd ${build_dir} && tar czf "${rpm_build_dir}/SOURCES/${pkg_name}.tar.gz" "${pkg_ cd ${pkg_path} && sha512sum ${rpm_file} >/tmp/${rpm_file}.sha512 find ${pkg_path}/ -maxdepth 3 -type f -name "${file_name}*" -exec mv {} /tmp/ \; -mv /tmp/${rpm_file} /tmp/${final_name} +if [ "${is_production}" = "no" ]; then + mv /tmp/${rpm_file} /tmp/${final_name} + mv /tmp/${rpm_file}.sha512 /tmp/${final_name}.sha512 +fi diff --git a/dev-tools/build-packages/rpm/launcher.sh b/dev-tools/build-packages/rpm/launcher.sh index bbe2fb77984f..cc2996240461 100755 --- a/dev-tools/build-packages/rpm/launcher.sh +++ b/dev-tools/build-packages/rpm/launcher.sh @@ -11,10 +11,11 @@ # Inputs package="" version="" -revision="1" +revision="0" architecture="x86_64" build_base="yes" build_docker="yes" +is_production="no" # Constants rpm_x86_builder="rpm_dashboard_builder_x86" @@ -85,6 +86,7 @@ build_rpm() { tar -zxf wazuh-dashboard.tar.gz rm wazuh-dashboard.tar.gz mv $directory_name wazuh-dashboard-base + jq '.wazuh.revision="'${revision}'"' wazuh-dashboard-base/package.json > pkgtmp.json && mv pkgtmp.json wazuh-dashboard-base/package.json mkdir -p wazuh-dashboard-base/etc/services cp $config_path/* wazuh-dashboard-base/etc/services echo ${version} >wazuh-dashboard-base/VERSION @@ -107,7 +109,7 @@ build_rpm() { docker run -t --rm ${volumes} \ -v ${current_path}/../..:/root:Z \ ${container_name} ${architecture} \ - ${revision} ${version} ${commit_sha} \ + ${revision} ${version} ${commit_sha} ${is_production}\ || return 1 echo "Package $(ls -Art ${out_dir} | tail -n 1) added to ${out_dir}." @@ -122,7 +124,7 @@ build_rpm() { build() { build_name="${rpm_x86_builder}" file_path="../${rpm_builder_dockerfile}/${architecture}" - build_rpm ${build_name} ${file_path} ${commit_sha}|| return 1 + build_rpm ${build_name} ${file_path} ${commit_sha} ${is_production}|| return 1 return 0 } @@ -135,6 +137,7 @@ help() { echo " -r, --revision [Optional] Package revision. By default: 1." echo " -o, --output [Optional] Set the destination path of package. By default, an output folder will be created." echo " --dont-build-docker [Optional] Locally built Docker image will be used instead of generating a new one." + echo " --production [Optional] The naming of the package will be ready for production." echo " -h, --help Show this help." echo exit $1 @@ -174,6 +177,10 @@ main() { build_docker="no" shift 1 ;; + "--production") + is_production="yes" + shift 1 + ;; "-o" | "--output") if [ -n "${2}" ]; then outdir="${2}"