Skip to content

Commit

Permalink
Fixed build workflow issue & Added create tag based on app version st…
Browse files Browse the repository at this point in the history
…ep (#4)

* Fixed build desktop workflow issue

* create tag based on app version

* Renamed workflows utils folder

* revert master branch
  • Loading branch information
M97Chahboun authored Dec 12, 2023
1 parent aa58736 commit c228a83
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/desktop_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master

# Enable manual run
# workflow_dispatch:
# inputs:
Expand All @@ -22,13 +23,19 @@ jobs:
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Dart Language
uses: dart-lang/[email protected]
- name: Get Project Version
run: "dart workflows_utils/get_project_version.dart"
- name: Draft release with release notes
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: v0.0.1-beta
tag_name: ${{ env.version_name }}
draft: true
prerelease: false
generate_release_notes: true
Expand Down Expand Up @@ -105,7 +112,7 @@ jobs:
working-directory: ${{ matrix.build_path }}
- name: Compress build for macOS
if: matrix.target == 'macOS'
run: ditto -c -k --sequesterRsrc --keepParent eyes_care.app $GITHUB_WORKSPACE/EyesCare${{ matrix.target }}.zip
run: ditto -c -k --sequesterRsrc --keepParent Eyes\ Care.app $GITHUB_WORKSPACE/EyesCare${{ matrix.target }}.zip
working-directory: ${{ matrix.build_path }}
- name: Compress build for Windows
if: matrix.target == 'Windows'
Expand Down
14 changes: 14 additions & 0 deletions workflows_utils/add_to_output.dart
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_ENV"];
File ghEnv = File(envPath!);
String currentContent = await ghEnv.readAsString();
if (currentContent.isNotEmpty) {
currentContent += "\n" "$item";
} else {
currentContent = item;
}
ghEnv.writeAsString(currentContent);
}
19 changes: 19 additions & 0 deletions workflows_utils/get_project_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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: ")));
String versionName = currentVersion;
String versionCode = '1';
if (currentVersion.contains('+')) {
versionName = currentVersion.split('+').first;
versionCode = currentVersion.split('+').last;
}
String versionEnvVar =
"version_name=${versionName.trim()}\nversion_code=${versionCode.trim()}";
await setOutput(versionEnvVar);
}

0 comments on commit c228a83

Please sign in to comment.