diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c21580a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,114 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-macos: + name: Build macOS (M-Series) + runs-on: macos-14 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Build macOS + run: | + flutter clean + flutter build macos --release + + - name: Create DMG + run: | + APP_NAME="caption_trans" + BUILD_PATH="build/macos/Build/Products/Release/${APP_NAME}.app" + DMG_NAME="${APP_NAME}-macos-arm64.dmg" + + # Create temporary folder for DMG content + mkdir -p dmg_content + cp -R "$BUILD_PATH" dmg_content/ + ln -s /Applications dmg_content/Applications + + # Create DMG + hdiutil create -volname "$APP_NAME" -srcfolder dmg_content -ov -format UDZO "$DMG_NAME" + + # Clean up + rm -rf dmg_content + + - name: Upload macOS Artifact + uses: actions/upload-artifact@v4 + with: + name: macos-dmg + path: caption_trans-macos-arm64.dmg + + build-windows: + name: Build Windows + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Build Windows + run: | + flutter clean + flutter build windows --release + + - name: Package Windows + shell: pwsh + run: | + $APP_NAME = "caption_trans" + $RELEASE_DIR = "build/windows/x64/runner/Release" + $ZIP_NAME = "${APP_NAME}-windows-x64.zip" + Compress-Archive -Path "$RELEASE_DIR/*" -DestinationPath "$ZIP_NAME" + + - name: Upload Windows Artifact + uses: actions/upload-artifact@v4 + with: + name: windows-zip + path: caption_trans-windows-x64.zip + + create-release: + name: Create GitHub Release + needs: [build-macos, build-windows] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: | + artifacts/*.dmg + artifacts/*.zip + draft: false + prerelease: false + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}