From 73d69248320e9333970fec2d10823c059ef6a59c Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 16 Feb 2025 00:19:10 +0100 Subject: [PATCH] feat: setup CI files for deployment --- .github/ci.yaml | 0 .github/workflows/ci.yaml | 27 +++++++++++++++ .github/workflows/create_build.yaml | 52 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) delete mode 100644 .github/ci.yaml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/create_build.yaml diff --git a/.github/ci.yaml b/.github/ci.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..62b9537 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,27 @@ +name: CI +on: + pull_request: + branches: + - main + +jobs: + flutter_test: + name: Run flutter test and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: "12.x" + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + + - name: 📦 Install Dependencies + run: flutter pub get + + - name: 🩺 Analyze Formatting + run: flutter analyze + + - name: 📕 Analyze Formatting + run: dart format --line-length 120 . diff --git a/.github/workflows/create_build.yaml b/.github/workflows/create_build.yaml new file mode 100644 index 0000000..64342ce --- /dev/null +++ b/.github/workflows/create_build.yaml @@ -0,0 +1,52 @@ +name: Build and Deploy to Cloudflare R2 + +on: + push: + branches: + - main + +jobs: + build-and-upload: + runs-on: ubuntu-latest # For macOS, use 'macos-latest' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: stable + + - name: Install dependencies + run: flutter pub get + + - name: Build macOS app + run: flutter build macos + + - name: Build Windows app + run: flutter build windows + + - name: Upload macOS build to Cloudflare R2 + run: | + sudo apt install awscli + aws configure set aws_access_key_id ${{ secrets.R2_ACCESS_KEY_ID }} + aws configure set aws_secret_access_key ${{ secrets.R2_SECRET_ACCESS_KEY }} + aws configure set default.region auto + + aws s3 cp --endpoint-url=https://$R2_ACCOUNT_ID.r2.cloudflarestorage.com \ + build/macos/Build/Products/Release/MyApp.dmg s3://${{ secrets.R2_BUCKET_NAME }}/macos/MyApp.dmg --acl public-read + + echo "✅ macOS build uploaded!" + + - name: Upload Windows build to Cloudflare R2 + run: | + aws s3 cp --endpoint-url=https://$R2_ACCOUNT_ID.r2.cloudflarestorage.com \ + build/windows/runner/Release/MyApp.exe s3://${{ secrets.R2_BUCKET_NAME }}/windows/MyApp.exe --acl public-read + + echo "✅ Windows build uploaded!" + + - name: Generate Public Links + run: | + echo "Download macOS App: https://${{ secrets.R2_ACCOUNT_ID }}.r2.dev/${{ secrets.R2_BUCKET_NAME }}/macos/MyApp.dmg" + echo "Download Windows App: https://${{ secrets.R2_ACCOUNT_ID }}.r2.dev/${{ secrets.R2_BUCKET_NAME }}/windows/MyApp.exe"