From 28e198f412433af46ba0f991f7e6bcf9faefa310 Mon Sep 17 00:00:00 2001 From: Ankit Karna Date: Thu, 11 Jun 2026 18:19:28 +0545 Subject: [PATCH] Fix Flutter package release workflow --- .github/workflows/build-deploy.yml | 74 ++++++++++++++++++----------- example/android/settings.gradle.kts | 2 +- example/ios/Podfile | 3 +- example/ios/Podfile.lock | 12 ++--- example/pubspec.lock | 7 ++- lib/src/models/uxoverlay.dart | 11 +++-- lib/src/uxoverlay.dart | 11 +++-- 7 files changed, 73 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index f7a8fde6..477dd6b8 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -2,12 +2,9 @@ name: Publish Flutter Package on: workflow_dispatch: - inputs: - publish: - description: Publish flutter package to pub.dev - type: boolean - default: false - required: true + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' permissions: {} @@ -36,12 +33,12 @@ jobs: with: persist-credentials: false - - name: Install Flutter 🎯 + - name: Install Flutter uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 with: channel: stable - - name: Install dependencies 📚 + - name: Install dependencies run: flutter pub get - name: Read package version @@ -51,19 +48,19 @@ jobs: echo "version=$version" >> "$GITHUB_OUTPUT" echo "Resolved version: v$version" - - name: Verify package (dry run) + - name: Verify package run: dart pub publish --dry-run publish: name: Publish to pub.dev needs: validate - if: ${{ inputs.publish }} + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-24.04 timeout-minutes: 20 - environment: "pub.dev" + environment: pub.dev permissions: - contents: write # create tag + GitHub Release - id-token: write # pub.dev OIDC publishing + contents: write + id-token: write steps: - name: Harden runner uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 @@ -77,27 +74,41 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Install Flutter 🎯 + - name: Configure pub.dev publishing credentials + uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 # v1 + + - name: Install Flutter uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 with: channel: stable - - name: Install dependencies 📚 + - name: Install dependencies run: flutter pub get - - name: Publish to pub.dev 🚀 + - name: Verify tag matches pubspec + run: | + expected_tag="v${{ needs.validate.outputs.version }}" + if [ "$GITHUB_REF_NAME" != "$expected_tag" ]; then + echo "Tag $GITHUB_REF_NAME does not match pubspec version $expected_tag" + exit 1 + fi + + - name: Publish to pub.dev run: dart pub publish --force - name: Generate changelog id: changelog run: | - previous_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo '')" - range="HEAD" - [ -n "$previous_tag" ] && range="${previous_tag}..HEAD" + current_commit="$(git rev-list -n 1 "$GITHUB_REF_NAME")" + previous_tag="$(git describe --tags --abbrev=0 "${current_commit}^" 2>/dev/null || true)" + range="$current_commit" + if [ -n "$previous_tag" ]; then + range="${previous_tag}..${current_commit}" + fi logs="$(git log "$range" --no-merges --pretty=format:'%s' -i \ --grep='^feat.*:' --grep='^fix.*:' \ - | awk -F ':' '{ sub(/^ */, "", $2); print "- " $2 }')" + | awk -F ':' 'NF > 1 { sub(/^ */, "", $2); print "- " $2 }')" { echo "logs<> "$GITHUB_OUTPUT" echo "$logs" - - name: Create tag and GitHub Release + - name: Create GitHub Release id: release env: - VERSION: ${{ needs.validate.outputs.version }} BODY: ${{ steps.changelog.outputs.logs }} GH_TOKEN: ${{ github.token }} run: | - url="$(gh release create "v$VERSION" \ - --target "$GITHUB_SHA" \ - --title "v$VERSION" \ - --notes "$BODY" \ - --latest)" + if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then + url="$(gh release view "$GITHUB_REF_NAME" --json url -q .url)" + else + url="$(gh release create "$GITHUB_REF_NAME" \ + --verify-tag \ + --title "$GITHUB_REF_NAME" \ + --notes "$BODY" \ + --latest)" + fi echo "url=$url" >> "$GITHUB_OUTPUT" - name: Notify Slack + continue-on-error: true uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 env: - PKG_VERSION: v${{ needs.validate.outputs.version }} + PKG_VERSION: ${{ github.ref_name }} CHANGELOG: ${{ steps.changelog.outputs.logs }} RELEASE_URL: ${{ steps.release.outputs.url }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} with: webhook: ${{ secrets.SLACK_WEBHOOK_URL }} webhook-type: incoming-webhook @@ -136,7 +152,7 @@ jobs: - type: section text: type: mrkdwn - text: " UXCam Flutter Plugin *{{ env.PKG_VERSION }}* has been released. :rocket:" + text: " UXCam Flutter Plugin *{{ env.PKG_VERSION }}* has been released." - type: section fields: - type: mrkdwn diff --git a/example/android/settings.gradle.kts b/example/android/settings.gradle.kts index a439442c..11662c30 100644 --- a/example/android/settings.gradle.kts +++ b/example/android/settings.gradle.kts @@ -19,7 +19,7 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" id("com.android.application") version "8.7.0" apply false - id("org.jetbrains.kotlin.android") version "1.8.22" apply false + id("org.jetbrains.kotlin.android") version "2.1.0" apply false } include(":app") diff --git a/example/ios/Podfile b/example/ios/Podfile index 6eafd7e2..547bfad8 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,4 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '13.0' +platform :ios, '13.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7c8a7871..52ce9373 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - Flutter (1.0.0) - - flutter_uxcam (2.7.6): + - flutter_uxcam (2.8.3): - Flutter - - UXCam (~> 3.7.6) - - UXCam (3.7.6) + - UXCam (~> 3.8.3) + - UXCam (3.8.3) DEPENDENCIES: - Flutter (from `Flutter`) @@ -21,9 +21,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 - flutter_uxcam: c38cf6c3eced71c537ff75340678d6ea8cb7164e - UXCam: 47c2b1a152b1914b3eec06b39b0c3523d71ad8ad + flutter_uxcam: edadcf35f8da6bef6962324d9e56cd7849ed1f5f + UXCam: 7cc67adb0297303376037170d2d468452422e803 -PODFILE CHECKSUM: a3b6f034f0d79a209652621b979bc9d6707da7a1 +PODFILE CHECKSUM: 3c41d3a6488201d7e0d12c3265a22101f620ec8e COCOAPODS: 1.16.2 diff --git a/example/pubspec.lock b/example/pubspec.lock index a4bd66b8..930521f1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -73,7 +73,12 @@ packages: path: ".." relative: true source: path - version: "2.7.6" + version: "2.8.3" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" leak_tracker: dependency: transitive description: diff --git a/lib/src/models/uxoverlay.dart b/lib/src/models/uxoverlay.dart index aab98a20..5348a6bb 100644 --- a/lib/src/models/uxoverlay.dart +++ b/lib/src/models/uxoverlay.dart @@ -10,6 +10,9 @@ class FlutterUXOverlay extends FlutterUXOcclusion { Color color = Colors.red; bool hideGestures = true; + int _colorChannel(double value) => + (value * 255.0).round().clamp(0, 255).toInt(); + @override String get name => 'UXOcclusionTypeOverlay'; // not used.. only to make it compatible with blur @@ -20,10 +23,10 @@ class FlutterUXOverlay extends FlutterUXOcclusion { @override Map? get configuration => { FlutterUxOverlayKeys.color: [ - color.red * 255.round().clamp(0, 255), - color.green * 255.round().clamp(0, 255), - color.blue * 255.round().clamp(0, 255), - color.alpha * 255.round().clamp(0, 255) + _colorChannel(color.r), + _colorChannel(color.g), + _colorChannel(color.b), + _colorChannel(color.a) ], FlutterUxOverlayKeys.hideGestures: hideGestures }; diff --git a/lib/src/uxoverlay.dart b/lib/src/uxoverlay.dart index d575f1dd..5348a6bb 100644 --- a/lib/src/uxoverlay.dart +++ b/lib/src/uxoverlay.dart @@ -10,6 +10,9 @@ class FlutterUXOverlay extends FlutterUXOcclusion { Color color = Colors.red; bool hideGestures = true; + int _colorChannel(double value) => + (value * 255.0).round().clamp(0, 255).toInt(); + @override String get name => 'UXOcclusionTypeOverlay'; // not used.. only to make it compatible with blur @@ -20,10 +23,10 @@ class FlutterUXOverlay extends FlutterUXOcclusion { @override Map? get configuration => { FlutterUxOverlayKeys.color: [ - color.red, - color.green, - color.blue, - color.alpha + _colorChannel(color.r), + _colorChannel(color.g), + _colorChannel(color.b), + _colorChannel(color.a) ], FlutterUxOverlayKeys.hideGestures: hideGestures };