-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Infer version from tags/branches instead of Versions.props #37985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||
| # This workflow automatically labels issues with the preview/RC version when their fixing PR | ||||||||||||
| # is merged into main or a release branch, and sets their milestone to the current version. | ||||||||||||
| # All version information is read from eng/Versions.props at the merge commit. | ||||||||||||
| # The version is inferred from tags and branches in the repo, with the major/minor on main taken from eng/Versions.props. | ||||||||||||
|
|
||||||||||||
| name: Label and milestone closed issues | ||||||||||||
|
|
||||||||||||
|
|
@@ -28,7 +28,6 @@ jobs: | |||||||||||
| const owner = context.repo.owner; | ||||||||||||
| const repo = context.repo.repo; | ||||||||||||
| const prNumber = context.payload.pull_request.number; | ||||||||||||
| const mergeCommitSha = context.payload.pull_request.merge_commit_sha; | ||||||||||||
|
|
||||||||||||
| // Find issues closed by this PR using GraphQL (include current milestone) | ||||||||||||
| const query = ` | ||||||||||||
|
|
@@ -56,30 +55,98 @@ jobs: | |||||||||||
| return; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Read version info from eng/Versions.props at the actual merge commit | ||||||||||||
| const { data: versionFileData } = await github.rest.repos.getContent({ | ||||||||||||
| owner, | ||||||||||||
| repo, | ||||||||||||
| path: 'eng/Versions.props', | ||||||||||||
| ref: mergeCommitSha | ||||||||||||
| }); | ||||||||||||
| const versionFileContent = Buffer.from(versionFileData.content, 'base64').toString('utf-8'); | ||||||||||||
|
|
||||||||||||
| const versionPrefixMatch = versionFileContent.match(/<VersionPrefix>(\d+\.\d+\.\d+)<\/VersionPrefix>/); | ||||||||||||
| if (!versionPrefixMatch) { | ||||||||||||
| throw new Error('Could not parse VersionPrefix from eng/Versions.props'); | ||||||||||||
| } | ||||||||||||
| const versionPrefix = versionPrefixMatch[1]; | ||||||||||||
| // Detect version and label from tags/branches based on the target branch | ||||||||||||
| const targetBranch = context.payload.pull_request.base.ref; | ||||||||||||
| let targetMilestoneName; | ||||||||||||
| let label; | ||||||||||||
|
|
||||||||||||
| const preReleaseLabelMatch = versionFileContent.match(/<PreReleaseVersionLabel>(preview|rc)<\/PreReleaseVersionLabel>/); | ||||||||||||
| const preReleaseIterationMatch = versionFileContent.match(/<PreReleaseVersionIteration>(\d+)<\/PreReleaseVersionIteration>/); | ||||||||||||
| const releaseBranchMatch = targetBranch.match(/^release\/(\d+)\.(\d+)$/); | ||||||||||||
| if (releaseBranchMatch) { | ||||||||||||
| // Servicing branch (e.g. release/10.0): find the next patch version from tags | ||||||||||||
| const major = releaseBranchMatch[1]; | ||||||||||||
| const minor = releaseBranchMatch[2]; | ||||||||||||
|
|
||||||||||||
| let label; | ||||||||||||
| if (preReleaseLabelMatch && preReleaseIterationMatch) { | ||||||||||||
| label = `${preReleaseLabelMatch[1]}-${preReleaseIterationMatch[1]}`; | ||||||||||||
| const tagRefs = await github.paginate( | ||||||||||||
| github.rest.git.listMatchingRefs, | ||||||||||||
| { | ||||||||||||
| owner, | ||||||||||||
| repo, | ||||||||||||
| ref: `tags/v${major}.${minor}.`, | ||||||||||||
| per_page: 100 | ||||||||||||
| } | ||||||||||||
| ); | ||||||||||||
|
|
||||||||||||
| let highestPatch = -1; | ||||||||||||
| for (const ref of tagRefs) { | ||||||||||||
| const m = ref.ref.match(/^refs\/tags\/v\d+\.\d+\.(\d+)$/); | ||||||||||||
| if (m) { | ||||||||||||
| const patch = parseInt(m[1]); | ||||||||||||
| if (patch < 100 && patch > highestPatch) { | ||||||||||||
| highestPatch = patch; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| if (highestPatch === -1) { | |
| throw new Error(`No GA v${major}.${minor}.Z tags found for servicing branch ${targetBranch}`); | |
| } |
Uh oh!
There was an error while loading. Please reload this page.