Skip to content

Commit

Permalink
Fix action outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
socheatsok78 committed Jun 3, 2024
1 parent bf488ec commit 686cbed
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 39 deletions.
43 changes: 24 additions & 19 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

43 changes: 24 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ async function main() {
}
}

let __message = "-"
const msg = []

// Check if the release satisfies the version constraint in the pubspec.yaml file
if (release.version) {
if (!semver.satisfies(release.version, Pubspec.environment.flutter)) {
continue
}
matrix.flutter.push(release.version)
__message += ` Flutter SDK version: (v${release.version}, ${release.channel})`
msg.push(`Flutter SDK version: (v${release.version}, ${release.channel})`)
}

// Check if the release satisfies the Dart SDK version constraint in the pubspec.yaml file
Expand All @@ -104,28 +104,29 @@ async function main() {
continue
}
matrix.dart.push(release.dart_sdk_version)
__message += `, Dart SDK version: (v${release.version})`
msg.push(`Dart SDK version: (v${release.version})`)
}

core.info(`${__message} satisfies the constraints in the "pubspec.yaml" file`)
__message = "" // Reset the message
core.info(`- ${msg.join(", ")} satisfies the constraints in the "pubspec.yaml" file`)
}
})

// Remove duplicates and empty matrix
for (const key in matrix) {
await core.group(`Post-processing for ${labelsMap[key]}`, async () => {
const items = matrix[key]
if (items.length === 0) {
core.info(`- Remove the "${key}" from the matrix to avoid empty arrays which will cause the job to fail`)
delete matrix[key]
} else {
core.info("- Removing duplicates and sorting the versions")
matrix[key] = Array
.from(new Set(matrix[key])) // Remove duplicates
.sort(compareVersions) // Sort the versions
}
})
if (Object.hasOwnProperty.call(matrix, key)) {
await core.group(`Post-processing for ${labelsMap[key]}`, async () => {
const items = matrix[key]
if (items.length === 0) {
core.info(`- Remove the "${key}" from the matrix to avoid empty arrays which will cause the job to fail`)
delete matrix[key]
} else {
core.info("- Removing duplicates and sorting the versions")
matrix[key] = Array
.from(new Set(matrix[key])) // Remove duplicates
.sort(compareVersions) // Sort the versions
}
})
}
}


Expand All @@ -134,8 +135,12 @@ async function main() {

// Set the output variables
core.setOutput('matrix', JSON.stringify(matrix))
core.setOutput('dart', JSON.stringify(matrix.dart))
core.setOutput('flutter', JSON.stringify(matrix.flutter))
if ('dart' in matrix) {
core.setOutput('dart', JSON.stringify(matrix.dart))
}
if ('flutter' in matrix) {
core.setOutput('flutter', JSON.stringify(matrix.flutter))
}
}

main()

0 comments on commit 686cbed

Please sign in to comment.