Skip to content

Instantly share code, notes, and snippets.

@M97Chahboun
Last active October 16, 2022 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M97Chahboun/e69e46096549f8bc8da558dd9796ed3f to your computer and use it in GitHub Desktop.
Save M97Chahboun/e69e46096549f8bc8da558dd9796ed3f to your computer and use it in GitHub Desktop.
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