-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use env variable for workflow output (#85)
* Add setOutput method * Use setOutput method for save value * removed unused import
- Loading branch information
1 parent
90ef5e1
commit 263a70a
Showing
5 changed files
with
25 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'dart:io'; | ||
|
||
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); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import 'dart:io'; | ||
|
||
import 'add_to_output.dart'; | ||
|
||
main() async { | ||
final data = File('./pubspec.yaml'); | ||
String text = data.readAsStringSync(); | ||
String currentVersion = text.substring(text.indexOf("version: ") + 9, | ||
text.indexOf("\n", text.indexOf("version: "))); | ||
await Process.run( | ||
'echo "project_version=v${currentVersion.trim()}" >> \$GITHUB_OUTPUT', [], | ||
runInShell: true); | ||
String versionEnvVar = "project_version=v${currentVersion.trim()}"; | ||
await setOutput(versionEnvVar); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import 'dart:io'; | ||
import 'add_to_output.dart'; | ||
|
||
const List<String> options = ["alpha", "beta", "internal"]; | ||
Future<void> main(List<String> labels) async { | ||
List<String> trackLabels = List.from(labels); | ||
trackLabels.removeWhere((e) => !options.contains(e)); | ||
String track = "alpha"; | ||
String track = "track=alpha"; | ||
if (trackLabels.isNotEmpty) { | ||
track = trackLabels.first; | ||
track = "track=${trackLabels.first}"; | ||
} | ||
await Process.run('echo "track=$track" >> \$GITHUB_OUTPUT', [], | ||
runInShell: true); | ||
await setOutput(track); | ||
} |
This file contains 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
Empty file.