Skip to content

Commit

Permalink
cd: add publish release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Apr 22, 2024
1 parent 073d064 commit 78de7db
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 5 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish Release

on:
push:
tags:
- "*"

jobs:
publish_github_release:
# macOS because we can cross-compile to all other platforms from it
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@v2
- uses: goto-bus-stop/setup-zig@v2
- uses: KyleMayes/install-llvm-action@v1
with:
version: "15"
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: nttld/setup-ndk@v1
with:
ndk-version: r25b

- name: Extract project name
id: extract
run: |
PROJECT_NAME=$(echo ${{ github.ref_name }} | rev | cut -d '-' -f 2- | rev)
echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_ENV
- name: Build all library binaries
run: |
dart cli/main.dart android -p=${{ env.PROJECT_NAME }}
dart cli/main.dart ios -p=${{ env.PROJECT_NAME }}
dart cli/main.dart macos -p=${{ env.PROJECT_NAME }}
dart cli/main.dart windows -p=${{ env.PROJECT_NAME }}
dart cli/main.dart linux -p=${{ env.PROJECT_NAME }}
# - name: Create GitHub release
# uses: softprops/action-gh-release@v1
# with:
# files: platform-build/${{ env.PROJECT_NAME }}/**/*

- name: Artifacts
uses: actions/upload-artifact@v2
with:
name: Libraries
path: platform-build/
6 changes: 5 additions & 1 deletion cli/commands/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ class AndroidBuildCommand extends Command with BuildConfig {
stderr.writeln("Project $project not found");
return;
}
if (!await platformDirExists(project!)) {
stdout.writeln("Platform $name is not enabled for $project");
return;
}

await ensureBuildDirectoryExists(project!);
await ensureBuildDirectoryExists(project);

final shell = Shell(workingDirectory: buildDir);

Expand Down
7 changes: 6 additions & 1 deletion cli/commands/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class IOSBuildCommand extends Command with BuildConfig {
stderr.writeln("Project $project not found");
return;
}
await ensureBuildDirectoryExists(project!);

if (!await platformDirExists(project!)) {
stdout.writeln("Platform $name is not enabled for $project");
return;
}
await ensureBuildDirectoryExists(project);

final shell = Shell(workingDirectory: buildDir);
final arch = [
Expand Down
7 changes: 6 additions & 1 deletion cli/commands/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class LinuxBuildCommand extends Command with BuildConfig {
stderr.writeln("Project $project not found");
return;
}
await ensureBuildDirectoryExists(project!);
if (!await platformDirExists(project!)) {
stdout.writeln("Platform $name is not enabled for $project");
return;
}

await ensureBuildDirectoryExists(project);

final shell = Shell(workingDirectory: buildDir);

Expand Down
6 changes: 5 additions & 1 deletion cli/commands/macos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class MacOSBuildCommand extends Command with BuildConfig {
stderr.writeln("Project $project not found");
return;
}
await ensureBuildDirectoryExists(project!);
if (!await platformDirExists(project!)) {
stdout.writeln("Platform $name is not enabled for $project");
return;
}
await ensureBuildDirectoryExists(project);

final shell = Shell(workingDirectory: buildDir);
final arch = ["x86_64-apple-darwin", "aarch64-apple-darwin"];
Expand Down
7 changes: 6 additions & 1 deletion cli/commands/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class WindowsBuildCommand extends Command with BuildConfig {
stderr.writeln("Project $project not found");
return;
}
await ensureBuildDirectoryExists(project!);
if (!await platformDirExists(project!)) {
stdout.writeln("Platform $name is not enabled for $project");
return;
}

await ensureBuildDirectoryExists(project);

final shell = Shell(
workingDirectory: buildDir,
Expand Down
7 changes: 7 additions & 0 deletions cli/mixins/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ mixin BuildConfig on Command {
}
await buildDirectory.create(recursive: true);
}

Future<bool> platformDirExists(String project) async {
final projectDir = join(cwd, "packages", project);
final platformDir = join(projectDir, name);

return await Directory(platformDir).exists();
}
}

0 comments on commit 78de7db

Please sign in to comment.