From ebca3b9dd70933d9e7bf833c1194bdefffd6ae94 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 8 Oct 2024 12:14:20 +0200 Subject: [PATCH] build: correctly build pr to generate assets --- .github/workflows/insider-linux.yml | 34 ++++++++++++++++++++++++--- .github/workflows/insider-macos.yml | 7 ++++-- .github/workflows/insider-windows.yml | 7 ++++-- .github/workflows/stable-linux.yml | 34 ++++++++++++++++++++++++--- .github/workflows/stable-macos.yml | 9 +++++-- .github/workflows/stable-windows.yml | 12 +++++++--- get_pr.sh | 14 +++++++++++ get_repo.sh | 11 --------- 8 files changed, 102 insertions(+), 26 deletions(-) create mode 100755 get_pr.sh diff --git a/.github/workflows/insider-linux.yml b/.github/workflows/insider-linux.yml index 1a3ac3c209a..ce134777820 100644 --- a/.github/workflows/insider-linux.yml +++ b/.github/workflows/insider-linux.yml @@ -49,9 +49,12 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} - - name: Clone VSCode repo + - name: Switch to relevant branch env: PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + + - name: Clone VSCode repo run: ./get_repo.sh - name: Check PR or cron @@ -84,6 +87,11 @@ jobs: ref: ${{ env.GITHUB_BRANCH }} if: env.SHOULD_BUILD == 'yes' + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Setup Node.js environment uses: actions/setup-node@v4 with: @@ -105,8 +113,6 @@ jobs: if: env.SHOULD_BUILD == 'yes' - name: Clone VSCode repo - env: - PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} run: ./get_repo.sh if: env.SHOULD_BUILD == 'yes' @@ -175,6 +181,11 @@ jobs: ref: ${{ env.GITHUB_BRANCH }} if: env.SHOULD_BUILD == 'yes' + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Install GH run: ./install_gh.sh if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' @@ -268,6 +279,11 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Setup Node.js environment uses: actions/setup-node@v4 with: @@ -348,6 +364,11 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Install GH run: ./install_gh.sh if: env.SHOULD_DEPLOY == 'yes' @@ -436,6 +457,13 @@ jobs: steps: - uses: actions/checkout@v3 + with: + ref: ${{ env.GITHUB_BRANCH }} + + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh - uses: docker/setup-qemu-action@v3 diff --git a/.github/workflows/insider-macos.yml b/.github/workflows/insider-macos.yml index ba63fba32ce..e3fac12f704 100644 --- a/.github/workflows/insider-macos.yml +++ b/.github/workflows/insider-macos.yml @@ -51,6 +51,11 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Setup Node.js environment uses: actions/setup-node@v4 with: @@ -63,8 +68,6 @@ jobs: if: env.VSCODE_ARCH == 'x64' - name: Clone VSCode repo - env: - PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} run: . get_repo.sh - name: Check PR or cron diff --git a/.github/workflows/insider-windows.yml b/.github/workflows/insider-windows.yml index 3b3cb14b30a..abea90c83b8 100644 --- a/.github/workflows/insider-windows.yml +++ b/.github/workflows/insider-windows.yml @@ -55,6 +55,11 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Setup Node.js environment uses: actions/setup-node@v4 with: @@ -69,8 +74,6 @@ jobs: python-version: '3.11' - name: Clone VSCode repo - env: - PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} run: ./get_repo.sh - name: Check PR or cron diff --git a/.github/workflows/stable-linux.yml b/.github/workflows/stable-linux.yml index d9dfb4608f4..ecb17f3eda5 100644 --- a/.github/workflows/stable-linux.yml +++ b/.github/workflows/stable-linux.yml @@ -48,9 +48,12 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} - - name: Clone VSCode repo + - name: Switch to relevant branch env: PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + + - name: Clone VSCode repo run: ./get_repo.sh - name: Check PR or cron @@ -83,6 +86,11 @@ jobs: ref: ${{ env.GITHUB_BRANCH }} if: env.SHOULD_BUILD == 'yes' + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Setup Node.js environment uses: actions/setup-node@v4 with: @@ -104,8 +112,6 @@ jobs: if: env.SHOULD_BUILD == 'yes' - name: Clone VSCode repo - env: - PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} run: ./get_repo.sh if: env.SHOULD_BUILD == 'yes' @@ -174,6 +180,11 @@ jobs: ref: ${{ env.GITHUB_BRANCH }} if: env.SHOULD_BUILD == 'yes' + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Install GH run: ./install_gh.sh if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' @@ -267,6 +278,11 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Setup Node.js environment uses: actions/setup-node@v4 with: @@ -347,6 +363,11 @@ jobs: with: ref: ${{ env.GITHUB_BRANCH }} + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh + - name: Install GH run: ./install_gh.sh if: env.SHOULD_DEPLOY == 'yes' @@ -432,6 +453,13 @@ jobs: steps: - uses: actions/checkout@v3 + with: + ref: ${{ env.GITHUB_BRANCH }} + + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh - name: Check version env: diff --git a/.github/workflows/stable-macos.yml b/.github/workflows/stable-macos.yml index a3b7c52c73e..1d8600a1d78 100644 --- a/.github/workflows/stable-macos.yml +++ b/.github/workflows/stable-macos.yml @@ -47,6 +47,13 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ env.GITHUB_BRANCH }} + + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh - name: Setup Node.js environment uses: actions/setup-node@v4 @@ -60,8 +67,6 @@ jobs: if: env.VSCODE_ARCH == 'x64' - name: Clone VSCode repo - env: - PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} run: . get_repo.sh - name: Check PR or cron diff --git a/.github/workflows/stable-windows.yml b/.github/workflows/stable-windows.yml index fdfd2dcfda9..3f7e28368ce 100644 --- a/.github/workflows/stable-windows.yml +++ b/.github/workflows/stable-windows.yml @@ -52,6 +52,13 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ env.GITHUB_BRANCH }} + + - name: Switch to relevant branch + env: + PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} + run: ./get_pr.sh - name: Setup Node.js environment uses: actions/setup-node@v4 @@ -67,8 +74,6 @@ jobs: python-version: '3.11' - name: Clone VSCode repo - env: - PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }} run: ./get_repo.sh - name: Check PR or cron @@ -85,7 +90,6 @@ jobs: - name: Build env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_USERNAME: ${{ github.repository_owner }} npm_config_arch: ${{ matrix.vscode_arch }} npm_config_target_arch: ${{ matrix.vscode_arch }} run: ./build.sh @@ -129,6 +133,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ env.GITHUB_BRANCH }} - name: Check version run: ./stores/winget/check_version.sh diff --git a/get_pr.sh b/get_pr.sh new file mode 100755 index 00000000000..f3cfe1c766b --- /dev/null +++ b/get_pr.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +if [[ -n "${PULL_REQUEST_ID}" ]]; then + BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD ) + + git config --global user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com" + git config --global user.name "${GITHUB_USERNAME} CI" + git fetch --unshallow + git fetch origin "pull/${PULL_REQUEST_ID}/head" + git checkout FETCH_HEAD + git merge --no-edit "origin/${BRANCH_NAME}" +fi diff --git a/get_repo.sh b/get_repo.sh index 2b2fd4d0a3c..e600bc59daa 100755 --- a/get_repo.sh +++ b/get_repo.sh @@ -8,17 +8,6 @@ if [[ "${CI_BUILD}" != "no" ]]; then git config --global --add safe.directory "/__w/$( echo "${GITHUB_REPOSITORY}" | awk '{print tolower($0)}' )" fi -if [[ -n "${PULL_REQUEST_ID}" ]]; then - BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD ) - - git config --global user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com" - git config --global user.name "${GITHUB_USERNAME} CI" - git fetch --unshallow - git fetch origin "pull/${PULL_REQUEST_ID}/head" - git checkout FETCH_HEAD - git merge --no-edit "origin/${BRANCH_NAME}" -fi - if [[ -z "${RELEASE_VERSION}" ]]; then if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "${VSCODE_QUALITY}.json" ]]; then echo "Retrieve lastest version"