From c4e70e2cf7be8a452913709174ff07d239f848b1 Mon Sep 17 00:00:00 2001 From: Varadarajan V <109586712+varadarajan-tw@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:46:48 +0530 Subject: [PATCH] Update hotfix release scripts (#2611) --- .github/workflows/publish.yml | 19 ------------------- scripts/generate-release-tags.sh | 7 ------- .../github-action/create-github-release.js | 16 ++++++++++++---- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 189851a879..b890236cb9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -81,22 +81,3 @@ jobs: script: | const script = require('./scripts/github-action/create-github-release.js') await script({github, context, core, exec}) - - # When hotfix is merged back to main, we tag all the packages that were changed in the hotfix commit. - tag-hotfix: - if: startsWith(github.event.head_commit.message, 'Hotfix:') == true && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure git - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - - name: Generate Package Specific Tags - id: get-release-tag - run: ./scripts/generate-package-tags.sh diff --git a/scripts/generate-release-tags.sh b/scripts/generate-release-tags.sh index a08c2c2642..2818cd4fff 100755 --- a/scripts/generate-release-tags.sh +++ b/scripts/generate-release-tags.sh @@ -52,13 +52,6 @@ else fi -# For hotfix, we don't tag each package version and we do it when hotfix changes are merged to main branch. -if [[ $branch == hotfix/* ]]; -then - echo "Skipping package tag generation for hotfix branch" - exit 0 -fi; - # Generate and push package tags. curr_path=$(pwd) dir_name=$(dirname $0) diff --git a/scripts/github-action/create-github-release.js b/scripts/github-action/create-github-release.js index f26a6dfee7..058f026506 100644 --- a/scripts/github-action/create-github-release.js +++ b/scripts/github-action/create-github-release.js @@ -1,14 +1,22 @@ // This is a github action script and can be run only from github actions. To run this script locally, you need to mock the github object and context object. module.exports = async ({ github, context, core, exec }) => { - let { GITHUB_SHA, DRY_RUN } = process.env + let { GITHUB_SHA, DRY_RUN, GITHUB_REF } = process.env + + // Get the branch name from the GITHUB_REF + const branchName = GITHUB_REF.replace('refs/heads/', '') + const isHotfixBranch = branchName.startsWith('hotfix/') if (Boolean(DRY_RUN)) { core.info('Running in dry-run mode') } - // Get the last two commits that have the word "Publish" in the commit message along with the date - const [newPublish, previousPublish] = await getPreviousTwoPublishCommits(core, exec) - const prs = await getPRsBetweenCommits(github, context, core, previousPublish, newPublish) + let prs = [] + // Retrieve PRs merged between the last two publish commits only for normal releases + if (!isHotfixBranch) { + // Get the last two commits that have the word "Publish" in the commit message along with the date + const [newPublish, previousPublish] = await getPreviousTwoPublishCommits(core, exec) + prs = await getPRsBetweenCommits(github, context, core, previousPublish, newPublish) + } // Get tag for the current release from the git repository const newReleaseTag = await getReleaseTag(core, exec)