Last active
October 16, 2022 14:00
-
-
Save M97Chahboun/e69e46096549f8bc8da558dd9796ed3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
const List<String> options = ["major", "minor", "patch"]; | |
Future<void> main(List<String> labels) async { | |
List<String> versionParts = List.from(labels); | |
versionParts.removeWhere((e) => !options.contains(e)); | |
String parts = ""; | |
if (versionParts.isNotEmpty) { | |
parts = versionParts.join(","); | |
parts = "parts=bump:$parts"; | |
} | |
await setOutput(parts); | |
} | |
Future<void> setOutput(String item) async { | |
Map<String, String> envVars = Platform.environment; | |
String? envPath = envVars["GITHUB_OUTPUT"]; | |
File ghEnv = File(envPath!); | |
String currentContent = await ghEnv.readAsString(); | |
if (currentContent.isNotEmpty) { | |
currentContent += "\n" "$item"; | |
} else { | |
currentContent = item; | |
} | |
ghEnv.writeAsString(currentContent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment