From 78de7db47e8ebb32fee789d0c6e44de99394afff Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Mon, 22 Apr 2024 17:52:14 +0600 Subject: [PATCH] cd: add publish release workflow --- .github/workflows/publish-release.yml | 51 +++++++++++++++++++++++++++ cli/commands/android.dart | 6 +++- cli/commands/ios.dart | 7 +++- cli/commands/linux.dart | 7 +++- cli/commands/macos.dart | 6 +++- cli/commands/windows.dart | 7 +++- cli/mixins/config.dart | 7 ++++ 7 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..d6f5ec7 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -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/ \ No newline at end of file diff --git a/cli/commands/android.dart b/cli/commands/android.dart index 630f0a3..8ab96bf 100644 --- a/cli/commands/android.dart +++ b/cli/commands/android.dart @@ -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); diff --git a/cli/commands/ios.dart b/cli/commands/ios.dart index 8cbc281..cf03b44 100644 --- a/cli/commands/ios.dart +++ b/cli/commands/ios.dart @@ -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 = [ diff --git a/cli/commands/linux.dart b/cli/commands/linux.dart index 77cb0d7..036b82d 100644 --- a/cli/commands/linux.dart +++ b/cli/commands/linux.dart @@ -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); diff --git a/cli/commands/macos.dart b/cli/commands/macos.dart index 5375277..7cc4c5d 100644 --- a/cli/commands/macos.dart +++ b/cli/commands/macos.dart @@ -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"]; diff --git a/cli/commands/windows.dart b/cli/commands/windows.dart index 7e516da..01da0ad 100644 --- a/cli/commands/windows.dart +++ b/cli/commands/windows.dart @@ -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, diff --git a/cli/mixins/config.dart b/cli/mixins/config.dart index f14cd60..dbae92f 100644 --- a/cli/mixins/config.dart +++ b/cli/mixins/config.dart @@ -17,4 +17,11 @@ mixin BuildConfig on Command { } await buildDirectory.create(recursive: true); } + + Future platformDirExists(String project) async { + final projectDir = join(cwd, "packages", project); + final platformDir = join(projectDir, name); + + return await Directory(platformDir).exists(); + } }