|
24 | 24 | description: 'The branch, tag, or SHA to release from.' |
25 | 25 | required: true |
26 | 26 | type: 'string' |
| 27 | + original_pr: |
| 28 | + description: 'The original PR number to comment back on.' |
| 29 | + required: false |
| 30 | + type: 'string' |
27 | 31 |
|
28 | 32 | jobs: |
29 | 33 | release: |
|
82 | 86 | echo "NPM_TAG=${NPM_TAG}" >> "${GITHUB_OUTPUT}" |
83 | 87 | echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> "${GITHUB_OUTPUT}" |
84 | 88 |
|
| 89 | + - name: 'Verify Version Consistency' |
| 90 | + env: |
| 91 | + GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 92 | + CHANNEL: '${{ github.event.inputs.type }}' |
| 93 | + run: | |
| 94 | + echo "🔍 Verifying no concurrent patch releases have occurred..." |
| 95 | +
|
| 96 | + # Store original calculation for comparison |
| 97 | + ORIGINAL_RELEASE_VERSION="${{ steps.patch_version.outputs.RELEASE_VERSION }}" |
| 98 | + ORIGINAL_RELEASE_TAG="${{ steps.patch_version.outputs.RELEASE_TAG }}" |
| 99 | + ORIGINAL_PREVIOUS_TAG="${{ steps.patch_version.outputs.PREVIOUS_TAG }}" |
| 100 | +
|
| 101 | + echo "Original calculation:" |
| 102 | + echo " Release version: ${ORIGINAL_RELEASE_VERSION}" |
| 103 | + echo " Release tag: ${ORIGINAL_RELEASE_TAG}" |
| 104 | + echo " Previous tag: ${ORIGINAL_PREVIOUS_TAG}" |
| 105 | +
|
| 106 | + # Re-run the same version calculation script |
| 107 | + echo "Re-calculating version to check for changes..." |
| 108 | + CURRENT_PATCH_JSON=$(node scripts/get-release-version.js --type=patch --patch-from="${CHANNEL}") |
| 109 | + CURRENT_RELEASE_VERSION=$(echo "${CURRENT_PATCH_JSON}" | jq -r .releaseVersion) |
| 110 | + CURRENT_RELEASE_TAG=$(echo "${CURRENT_PATCH_JSON}" | jq -r .releaseTag) |
| 111 | + CURRENT_PREVIOUS_TAG=$(echo "${CURRENT_PATCH_JSON}" | jq -r .previousReleaseTag) |
| 112 | +
|
| 113 | + echo "Current calculation:" |
| 114 | + echo " Release version: ${CURRENT_RELEASE_VERSION}" |
| 115 | + echo " Release tag: ${CURRENT_RELEASE_TAG}" |
| 116 | + echo " Previous tag: ${CURRENT_PREVIOUS_TAG}" |
| 117 | +
|
| 118 | + # Compare calculations |
| 119 | + if [[ "${ORIGINAL_RELEASE_VERSION}" != "${CURRENT_RELEASE_VERSION}" ]] || \ |
| 120 | + [[ "${ORIGINAL_RELEASE_TAG}" != "${CURRENT_RELEASE_TAG}" ]] || \ |
| 121 | + [[ "${ORIGINAL_PREVIOUS_TAG}" != "${CURRENT_PREVIOUS_TAG}" ]]; then |
| 122 | + echo "❌ RACE CONDITION DETECTED: Version calculations have changed!" |
| 123 | + echo "This indicates another patch release completed while this one was in progress." |
| 124 | + echo "" |
| 125 | + echo "Originally planned: ${ORIGINAL_RELEASE_VERSION} (from ${ORIGINAL_PREVIOUS_TAG})" |
| 126 | + echo "Should now build: ${CURRENT_RELEASE_VERSION} (from ${CURRENT_PREVIOUS_TAG})" |
| 127 | + echo "" |
| 128 | + echo "# Setting outputs for failure comment" |
| 129 | + echo "CURRENT_RELEASE_VERSION=${CURRENT_RELEASE_VERSION}" >> "${GITHUB_ENV}" |
| 130 | + echo "CURRENT_RELEASE_TAG=${CURRENT_RELEASE_TAG}" >> "${GITHUB_ENV}" |
| 131 | + echo "CURRENT_PREVIOUS_TAG=${CURRENT_PREVIOUS_TAG}" >> "${GITHUB_ENV}" |
| 132 | + echo "The patch release must be restarted to use the correct version numbers." |
| 133 | + exit 1 |
| 134 | + fi |
| 135 | +
|
| 136 | + echo "✅ Version calculations unchanged - proceeding with release" |
| 137 | +
|
85 | 138 | - name: 'Print Calculated Version' |
86 | 139 | run: |- |
87 | 140 | echo "Patch Release Summary:" |
@@ -121,3 +174,46 @@ jobs: |
121 | 174 | --title 'Patch Release Failed for ${RELEASE_TAG} on $(date +'%Y-%m-%d')' \ |
122 | 175 | --body 'The patch-release workflow failed. See the full run for details: ${DETAILS_URL}' \ |
123 | 176 | --label 'kind/bug,release-failure,priority/p0' |
| 177 | +
|
| 178 | + - name: 'Comment Success on Original PR' |
| 179 | + if: '${{ success() && github.event.inputs.original_pr }}' |
| 180 | + env: |
| 181 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 182 | + ORIGINAL_PR: '${{ github.event.inputs.original_pr }}' |
| 183 | + SUCCESS: 'true' |
| 184 | + RELEASE_VERSION: '${{ steps.patch_version.outputs.RELEASE_VERSION }}' |
| 185 | + RELEASE_TAG: '${{ steps.patch_version.outputs.RELEASE_TAG }}' |
| 186 | + NPM_TAG: '${{ steps.patch_version.outputs.NPM_TAG }}' |
| 187 | + CHANNEL: '${{ github.event.inputs.type }}' |
| 188 | + DRY_RUN: '${{ github.event.inputs.dry_run }}' |
| 189 | + GITHUB_RUN_ID: '${{ github.run_id }}' |
| 190 | + GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}' |
| 191 | + GITHUB_REPOSITORY_NAME: '${{ github.event.repository.name }}' |
| 192 | + run: | |
| 193 | + node scripts/releasing/patch-comment.js |
| 194 | +
|
| 195 | + - name: 'Comment Failure on Original PR' |
| 196 | + if: '${{ failure() && github.event.inputs.original_pr }}' |
| 197 | + env: |
| 198 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 199 | + ORIGINAL_PR: '${{ github.event.inputs.original_pr }}' |
| 200 | + SUCCESS: 'false' |
| 201 | + RELEASE_VERSION: '${{ steps.patch_version.outputs.RELEASE_VERSION }}' |
| 202 | + RELEASE_TAG: '${{ steps.patch_version.outputs.RELEASE_TAG }}' |
| 203 | + NPM_TAG: '${{ steps.patch_version.outputs.NPM_TAG }}' |
| 204 | + CHANNEL: '${{ github.event.inputs.type }}' |
| 205 | + DRY_RUN: '${{ github.event.inputs.dry_run }}' |
| 206 | + GITHUB_RUN_ID: '${{ github.run_id }}' |
| 207 | + GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}' |
| 208 | + GITHUB_REPOSITORY_NAME: '${{ github.event.repository.name }}' |
| 209 | + # Pass current version info for race condition failures |
| 210 | + CURRENT_RELEASE_VERSION: '${{ env.CURRENT_RELEASE_VERSION }}' |
| 211 | + CURRENT_RELEASE_TAG: '${{ env.CURRENT_RELEASE_TAG }}' |
| 212 | + CURRENT_PREVIOUS_TAG: '${{ env.CURRENT_PREVIOUS_TAG }}' |
| 213 | + run: | |
| 214 | + # Check if this was a version consistency failure |
| 215 | + if [[ -n "${CURRENT_RELEASE_VERSION}" ]]; then |
| 216 | + echo "Detected version race condition failure - posting specific comment with current version info" |
| 217 | + export RACE_CONDITION_FAILURE=true |
| 218 | + fi |
| 219 | + node scripts/releasing/patch-comment.js |
0 commit comments