From 4f54ed0f4c9bf8a634dca8385cec33c155be19c3 Mon Sep 17 00:00:00 2001 From: Federico Gustavo Galland <99492720+f-galland@users.noreply.github.com> Date: Wed, 10 Jan 2024 13:00:53 -0300 Subject: [PATCH] Use short SHA as Git reference in packages naming (#100) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Switching to short SHA commit form in package names Signed-off-by: Fede Tux * Update r_commit_sha.yml Signed-off-by: Federico Gustavo Galland <99492720+f-galland@users.noreply.github.com> * Update r_commit_sha.yml Signed-off-by: Álex Ruiz --------- Signed-off-by: Fede Tux Signed-off-by: Federico Gustavo Galland <99492720+f-galland@users.noreply.github.com> Signed-off-by: Álex Ruiz Co-authored-by: Fede Tux Co-authored-by: Álex Ruiz --- .github/workflows/build.yml | 11 +++++++---- .github/workflows/r_commit_sha.yml | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/r_commit_sha.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07531eb598a94..3d5a1d1e67f88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,8 +26,11 @@ jobs: version: uses: ./.github/workflows/r_version.yml + commit_sha: + uses: ./.github/workflows/r_commit_sha.yml + build: - needs: version + needs: [ version, commit_sha ] strategy: matrix: distribution: [tar, rpm, deb] @@ -37,10 +40,10 @@ jobs: architecture: ${{ matrix.architecture }} distribution: ${{ matrix.distribution }} revision: ${{ inputs.revision }} - name: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }} + name: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} assemble: - needs: [version, build] + needs: [version, commit_sha, build] strategy: matrix: distribution: [tar, rpm, deb] @@ -54,4 +57,4 @@ jobs: with: architecture: ${{ matrix.architecture }} distribution: ${{ matrix.distribution }} - min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ github.sha }}.${{ matrix.distribution }} + min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} diff --git a/.github/workflows/r_commit_sha.yml b/.github/workflows/r_commit_sha.yml new file mode 100644 index 0000000000000..44860cb3e7363 --- /dev/null +++ b/.github/workflows/r_commit_sha.yml @@ -0,0 +1,22 @@ +name: "Get commit's short SHA (reusable)" + +# This workflow runs when any of the following occur: +# - Run from another workflow +on: + workflow_call: + outputs: + commit_sha: + description: "Returns the short SHA of the latest commit" + value: ${{ jobs.r_commit_sha.outputs.commit_sha }} + +jobs: + r_commit_sha: + runs-on: ubuntu-latest + outputs: + commit_sha: ${{ steps.get_commit_sha.outputs.commit_sha }} + steps: + - uses: actions/checkout@v4 + - name: Get git commit SHA + id: get_commit_sha + run: | + echo "commit_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT