From 8c387a628c1189d56c1e7929a58d1ae5380728e6 Mon Sep 17 00:00:00 2001 From: Nicolas Agustin Guevara Pihen <42900763+Tostti@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:25:11 -0300 Subject: [PATCH] Add commit sha of all repositories in package name (#390) --- .../build_wazuh_dashboard_with_plugins.yml | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_wazuh_dashboard_with_plugins.yml b/.github/workflows/build_wazuh_dashboard_with_plugins.yml index 445ef160eab8..221047008413 100644 --- a/.github/workflows/build_wazuh_dashboard_with_plugins.yml +++ b/.github/workflows/build_wazuh_dashboard_with_plugins.yml @@ -116,6 +116,7 @@ jobs: exit 1 fi + build-base: needs: [validate-inputs] name: Build dashboard @@ -168,6 +169,25 @@ jobs: echo "PRODUCTION=--production" >> $GITHUB_ENV fi + - name: Get SHA of wazuh-dashboard-plugins + id: get-plugins-sha + run: | + git clone -b ${{ inputs.reference_wazuh_plugins }} --single-branch https://github.com/wazuh/wazuh-dashboard-plugins.git wzdp + cd wzdp + echo "WAZUH_PLUGINS_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: Get SHA of wazuh-security-dashboards-plugin + id: get-security-sha + run: | + git clone -b ${{ inputs.reference_security_plugins }} --single-branch https://github.com/wazuh/wazuh-security-dashboards-plugin.git wzsp + cd wzsp + echo "WAZUH_SECURITY_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: Get SHA of wazuh-dashboards-reporting + id: get-reporting-sha + run: | + git clone -b ${{ inputs.reference_report_plugins }} --single-branch https://github.com/wazuh/wazuh-dashboards-reporting.git wzrp + cd wzrp + echo "WAZUH_REPORTING_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: Setup packages names run: | echo "WAZUH_DASHBOARD_SLIM=wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x64.tar.gz" >> $GITHUB_ENV @@ -177,14 +197,18 @@ jobs: 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 + echo "FINAL_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 + echo "FINAL_NAME=wazuh-dashboard_${{ env.VERSION }}-${{ inputs.revision }}_${{ inputs.architecture }}_${{ env.COMMIT_SHA}}-${{ env.WAZUH_PLUGINS_SHA}}-${{ env.WAZUH_SECURITY_SHA}}-${{ env.WAZUH_REPORTING_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 + echo "FINAL_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 + echo "FINAL_NAME=wazuh-dashboard_${{ env.VERSION }}-${{ inputs.revision }}_${{ inputs.architecture }}_${{ env.COMMIT_SHA}}-${{ env.WAZUH_PLUGINS_SHA}}-${{ env.WAZUH_SECURITY_SHA}}-${{ env.WAZUH_REPORTING_SHA}}.rpm" >> $GITHUB_ENV fi fi @@ -239,11 +263,21 @@ jobs: bash ./test-packages.sh \ -p ${{env.PACKAGE_NAME}} + - name: Set package final name + run: | + mv ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.PACKAGE_NAME}} ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.FINAL_NAME}} + - name: Set SHA final name + if: ${{ inputs.checksum }} + run: | + mv ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.PACKAGE_NAME}}.sha512 ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.FINAL_NAME}}.sha512 + + + - uses: actions/upload-artifact@v3 if: success() with: name: ${{ env.PACKAGE_NAME }} - path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.PACKAGE_NAME}} + path: ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.FINAL_NAME}} retention-days: 30 - name: Set up AWS CLI @@ -258,14 +292,14 @@ jobs: if: ${{ inputs.upload }} run: | 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/ - s3uri="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/${{env.PACKAGE_NAME}}" + aws s3 cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.FINAL_NAME}} s3://packages-dev.internal.wazuh.com/development/wazuh/5.x/main/packages/ + s3uri="s3://packages-dev.internal.wazuh.com/development/wazuh/5.x/main/packages/${{env.FINAL_NAME}}" echo "S3 URI: ${s3uri}" - name: Upload SHA512 if: ${{ inputs.upload && inputs.checksum }} run: | 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/ - s3uri="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/${{env.PACKAGE_NAME}}.sha512" + aws s3 cp ${{ env.CURRENT_DIR }}/dev-tools/build-packages/output/${{ inputs.system }}/${{env.FINAL_NAME}}.sha512 s3://packages-dev.internal.wazuh.com/development/wazuh/5.x/main/packages/ + s3uri="s3://packages-dev.internal.wazuh.com/development/wazuh/5.x/main/packages/${{env.FINAL_NAME}}.sha512" echo "S3 sha512 URI: ${s3uri}"