chore: fix multi-version parsing in issue assignment (#44679)
* chore: fix multi-version parsing * chore: tweak for review
This commit is contained in:
parent
36e1a0bf00
commit
58dc990f7a
1 changed files with 28 additions and 22 deletions
50
.github/workflows/issue-opened.yml
vendored
50
.github/workflows/issue-opened.yml
vendored
|
@ -57,34 +57,40 @@ jobs:
|
|||
|
||||
const electronVersion = select('heading:has(> text[value="Electron Version"]) + paragraph > text', tree)?.value.trim();
|
||||
if (electronVersion !== undefined) {
|
||||
const major = semver.parse(electronVersion)?.major;
|
||||
if (major) {
|
||||
const versionLabel = `${major}-x-y`;
|
||||
let labelExists = false;
|
||||
// It's possible for multiple versions to be listed -
|
||||
// for now check for comma or space separated version.
|
||||
const versions = electronVersion.split(/, | /);
|
||||
for (const version of versions) {
|
||||
const major = semver.parse(version)?.major;
|
||||
if (major) {
|
||||
const versionLabel = `${major}-x-y`;
|
||||
let labelExists = false;
|
||||
|
||||
try {
|
||||
await github.rest.issues.getLabel({
|
||||
owner,
|
||||
repo,
|
||||
name: versionLabel,
|
||||
});
|
||||
labelExists = true;
|
||||
} catch {}
|
||||
try {
|
||||
await github.rest.issues.getLabel({
|
||||
owner,
|
||||
repo,
|
||||
name: versionLabel,
|
||||
});
|
||||
labelExists = true;
|
||||
} catch {}
|
||||
|
||||
if (labelExists) {
|
||||
// Check if it's an unsupported major
|
||||
const { ElectronVersions } = await import('${{ github.workspace }}/node_modules/@electron/fiddle-core/dist/index.js');
|
||||
const versions = await ElectronVersions.create(undefined, { ignoreCache: true });
|
||||
if (labelExists) {
|
||||
// Check if it's an unsupported major
|
||||
const { ElectronVersions } = await import('${{ github.workspace }}/node_modules/@electron/fiddle-core/dist/index.js');
|
||||
const versions = await ElectronVersions.create(undefined, { ignoreCache: true });
|
||||
|
||||
const validVersions = [...versions.supportedMajors, ...versions.prereleaseMajors];
|
||||
if (!validVersions.includes(major)) {
|
||||
core.setOutput('unsupportedMajor', true);
|
||||
labels.push('blocked/need-info ❌');
|
||||
const validVersions = [...versions.supportedMajors, ...versions.prereleaseMajors];
|
||||
if (validVersions.includes(major)) {
|
||||
labels.push(versionLabel);
|
||||
}
|
||||
}
|
||||
|
||||
labels.push(versionLabel);
|
||||
}
|
||||
}
|
||||
if (labels.length === 0) {
|
||||
core.setOutput('No supported versions found', true);
|
||||
labels.push('blocked/need-info ❌');
|
||||
}
|
||||
}
|
||||
|
||||
const operatingSystems = select('heading:has(> text[value="What operating system(s) are you using?"]) + paragraph > text', tree)?.value.trim().split(', ');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue