From 6a6364821af71aa2e1d60c6b56167ef4412b3a5f Mon Sep 17 00:00:00 2001 From: Aaron DeRuvo Date: Tue, 21 Nov 2023 15:33:30 +0200 Subject: [PATCH] Fix publish failing due to tag push fail (#10767) * ensure origin master is tracked so pre push script works * Release to npm is only accurate when closing a version packges pr. this is more accurate * clear that it could do 1 of 2 things --- .github/workflows/release.yaml | 2 +- scripts/hooks/pre-push.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9dc05cac14a..f35eca07970 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,7 +11,7 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: - name: Release to NPM + name: Prepare or Publish runs-on: ['self-hosted', 'org', 'npm-publish'] permissions: contents: write diff --git a/scripts/hooks/pre-push.js b/scripts/hooks/pre-push.js index 0c38945c79b..8596ef2de3a 100644 --- a/scripts/hooks/pre-push.js +++ b/scripts/hooks/pre-push.js @@ -60,7 +60,13 @@ function getDateFromFirstCommit(fromSHA, toSHA) { //////////////////////////////////////////////////////////////// // must trim otherwise the name will be 'origin\n' + const remoteName = execSync('git remote').toString().trim() +// create remote tracking branches to ensure we can compare current to origin/master +const remoteTrackingMasterBranches = execSync('git ls-remote --heads origin master') +if (remoteTrackingMasterBranches.toString().trim() === '') { + execSync('git fetch origin') +} const changes = process.env.HUSKY_GIT_STDIN.split('\n') .filter((line) => line !== '') .map((line) => {