From 2f238ed300cf78d3e5dd598147ba80fec7c24040 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 24 Sep 2025 17:09:13 +0100 Subject: [PATCH] Simplify layered workflows around version string generation (#30865) * Add reusable build workflow Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to composite action Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Make checkout happier Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Hoist upload artifact Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * copy pasta Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Description Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix passing env Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .github/workflows/build.yml | 17 +++-------------- .github/workflows/end-to-end-tests.yaml | 11 ++--------- .github/workflows/static_analysis.yaml | 3 +-- scripts/get-version-from-git.sh | 6 +++--- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bce04aaa08..ee6d9526ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,8 +10,7 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} # develop pushes and repository_dispatch handled in build_develop.yaml env: - # These must be set for fetchdep.sh to get the right branch - REPOSITORY: ${{ github.repository }} + # This must be set for fetchdep.sh to get the right branch PR_NUMBER: ${{ github.event.pull_request.number }} permissions: {} # No permissions required jobs: @@ -56,15 +55,7 @@ jobs: - run: yarn config set network-timeout 300000 - name: Fetch layered build - id: layered_build - env: - # tell layered.sh to check out the right sha of the JS-SDK & EW, if they were given one - JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }} - run: | - scripts/layered.sh - JSSDK_SHA=$(git -C matrix-js-sdk rev-parse --short=12 HEAD) - VECTOR_SHA=$(git rev-parse --short=12 HEAD) - echo "VERSION=$VECTOR_SHA--js-$JSSDK_SHA" >> $GITHUB_OUTPUT + run: ./scripts/layered.sh - name: Copy config run: cp element.io/develop/config.json config.json @@ -72,9 +63,7 @@ jobs: - name: Build env: CI_PACKAGE: true - VERSION: "${{ steps.layered_build.outputs.VERSION }}" - run: | - yarn build + run: VERSION=$(scripts/get-version-from-git.sh) yarn build - name: Upload Artifact uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 diff --git a/.github/workflows/end-to-end-tests.yaml b/.github/workflows/end-to-end-tests.yaml index 4879f31a81..40f6d15e94 100644 --- a/.github/workflows/end-to-end-tests.yaml +++ b/.github/workflows/end-to-end-tests.yaml @@ -60,15 +60,10 @@ jobs: node-version: "lts/*" - name: Fetch layered build - id: layered_build env: # tell layered.sh to check out the right sha of the JS-SDK & EW, if they were given one JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }} - run: | - scripts/layered.sh - JSSDK_SHA=$(git -C matrix-js-sdk rev-parse --short=12 HEAD) - VECTOR_SHA=$(git rev-parse --short=12 HEAD) - echo "VERSION=$VECTOR_SHA--js-$JSSDK_SHA" >> $GITHUB_OUTPUT + run: scripts/layered.sh - name: Copy config run: cp element.io/develop/config.json config.json @@ -76,9 +71,7 @@ jobs: - name: Build env: CI_PACKAGE: true - VERSION: "${{ steps.layered_build.outputs.VERSION }}" - run: | - yarn build + run: VERSION=$(scripts/get-version-from-git.sh) yarn build - name: Upload Artifact uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml index 3f62b1c6d4..db75583821 100644 --- a/.github/workflows/static_analysis.yaml +++ b/.github/workflows/static_analysis.yaml @@ -12,8 +12,7 @@ concurrency: cancel-in-progress: true env: - # These must be set for fetchdep.sh to get the right branch - REPOSITORY: ${{ github.repository }} + # This must be set for fetchdep.sh to get the right branch PR_NUMBER: ${{ github.event.pull_request.number }} permissions: {} # No permissions required diff --git a/scripts/get-version-from-git.sh b/scripts/get-version-from-git.sh index c8459dba44..90de770478 100755 --- a/scripts/get-version-from-git.sh +++ b/scripts/get-version-from-git.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash -# Echoes a version based on the git hashes of the element-web, react-sdk & js-sdk checkouts, for the case where +# Echoes a version based on the git hashes of the element-web & js-sdk checkouts, for the case where # these dependencies are git checkouts. set -e -# Since the deps are fetched from git, we can rev-parse +# Since the deps are fetched from git & linked, we can rev-parse JSSDK_SHA=$(git -C node_modules/matrix-js-sdk rev-parse --short=12 HEAD) VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop -echo $VECTOR_SHA-js-$JSSDK_SHA +echo "$VECTOR_SHA-js-$JSSDK_SHA"