diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 7a51bc89..4508a84d 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -292,7 +292,7 @@ create_release_pr() { create_changelog_pr() { local platform="$1" local new_version="$2" - local previous_version="$3" + local previous_release_branch_name="$3" local release_branch_name="$4" local changelog_branch_name="$5" @@ -313,7 +313,7 @@ create_changelog_pr() { yarn --cwd install echo "Generating test plan csv.." - yarn run gen:commits "${platform}" "${previous_version}" "${release_branch_name}" "${PROJECT_GIT_DIR}" + yarn run gen:commits "${platform}" "${previous_release_branch_name}" "${release_branch_name}" "${PROJECT_GIT_DIR}" if [[ "${TEST_ONLY:-false}" == 'false' ]]; then echo "Updating release sheet.." @@ -420,7 +420,8 @@ main() { next_version=$(get_next_version "$NEW_VERSION") # Initialize branch names - local release_branch_name changelog_branch_name version_bump_branch_name + local previous_release_branch_name release_branch_name changelog_branch_name version_bump_branch_name + previous_release_branch_name=$(get_release_branch_name "$PLATFORM" "$PREVIOUS_VERSION") release_branch_name=$(get_release_branch_name "$PLATFORM" "$NEW_VERSION") changelog_branch_name="chore/${NEW_VERSION}-Changelog" version_bump_branch_name=$(get_version_bump_branch_name "$next_version") # Execute main workflow @@ -433,7 +434,7 @@ main() { if [ "$TEST_ONLY" == "true" ]; then echo "Skipping changelog generation in test mode" else - create_changelog_pr "$PLATFORM" "$NEW_VERSION" "$PREVIOUS_VERSION" "$release_branch_name" "$changelog_branch_name" + create_changelog_pr "$PLATFORM" "$NEW_VERSION" "$previous_release_branch_name" "$release_branch_name" "$changelog_branch_name" fi # Step 3: Create version bump PR for main branch diff --git a/.github/scripts/generate-rc-commits.mjs b/.github/scripts/generate-rc-commits.mjs index 0be37e28..ed7d2126 100644 --- a/.github/scripts/generate-rc-commits.mjs +++ b/.github/scripts/generate-rc-commits.mjs @@ -80,6 +80,31 @@ async function filterCommitsByTeam(platform, branchA, branchB) { try { const git = simpleGit(); + // Fetch all branches and tags to ensure references exist + await git.fetch(['--all', '--tags', '--prune']); + + // Check if branchA exists + let branchAExists = true; + try { + await git.revparse([branchA]); + } catch (e) { + branchAExists = false; + } + + // Check if branchB exists + let branchBExists = true; + try { + await git.revparse([branchB]); + } catch (e) { + branchBExists = false; + } + + if (!branchAExists || !branchBExists) { + throw new Error( + `Cannot find reference(s):${!branchAExists ? ` ${branchA}` : ''}${!branchBExists ? ` ${branchB}` : ''}.` + ); + } + const logOptions = { from: branchB, to: branchA, @@ -223,7 +248,7 @@ async function main() { `Generating CSV file for commits between ${branchA} and ${branchB} on ${platform} platform...`, ); - const commitsByTeam = await filterCommitsByTeam(platform, branchA, branchB); + const commitsByTeam = await filterCommitsByTeam(platform, `origin/${branchA}`, `origin/${branchB}`); if (Object.keys(commitsByTeam).length === 0) { console.log('No commits found.'); diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index d8af016d..acc5adfb 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -15,10 +15,10 @@ on: required: false type: string description: 'The build version for the mobile platform.' - previous-version-tag: + previous-semver-version: required: true type: string - description: 'Previous release version tag. eg: v7.7.0' + description: 'A semantic version. eg: x.x.x' # Flag to indicate if the release is a test release for development purposes only mobile-template-sheet-id: required: false @@ -103,7 +103,7 @@ jobs: echo "Platform: ${{ inputs.platform }}" echo "Base Branch: ${{ inputs.base-branch }}" echo "Semver Version: ${{ inputs.semver-version }}" - echo "Previous Version Tag: ${{ inputs.previous-version-tag }}" + echo "Previous Semver Version: ${{ inputs.previous-semver-version }}" echo "Test Only Mode: ${{ inputs.test-only }}" if [[ "${{ inputs.platform }}" == "mobile" ]]; then echo "Mobile Build Version: ${{ inputs.mobile-build-version }}" @@ -135,7 +135,7 @@ jobs: # Execute the script from github-tools ./github-tools/.github/scripts/create-platform-release-pr.sh \ ${{ inputs.platform }} \ - ${{ inputs.previous-version-tag }} \ + ${{ inputs.previous-semver-version }} \ ${{ inputs.semver-version }} \ ${{ inputs.mobile-build-version }} \ ${{ inputs.git-user-name }} \