From d0b7858da550a8d615cea1e9249e14712af9ffdb Mon Sep 17 00:00:00 2001 From: uy/sun Date: Tue, 6 Feb 2024 23:31:09 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E4=BC=98=E5=8C=96=20Sentry=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20(#398)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 21 ++++++--------------- CHANGELOG.md | 4 ++++ lib/bootstrap.dart | 6 +++--- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46549c95..4ee6a41b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,13 +69,8 @@ jobs: - name: Set version name run: | sed -ri "s#^version: .+#version: $VERSION#g" pubspec.yaml - sed -ri "s#..dsn = ''#..dsn = '$SENTRY_DSN'#g" ./lib/bootstrap.dart - sed -ri "s#..release = 'release'#..release = '$RELEASE'#g" ./lib/bootstrap.dart env: VERSION: ${{ needs.test.outputs.version }} - ENVIRONMENT: ${{ needs.test.outputs.environment }} - RELEASE: ${{ needs.test.outputs.release }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - name: Decrypt large secret run: ./.github/scripts/decrypt_secret.sh env: @@ -90,6 +85,8 @@ jobs: run: flutter build apk --target-platform android-arm64,android-x64 --split-per-abi -t ./lib/main_$ENVIRONMENT.dart --flavor $ENVIRONMENT env: ENVIRONMENT: ${{ needs.test.outputs.environment }} + SENTRY_RELEASE: ${{ needs.test.outputs.release }} + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - name: Upload split-per-abi apks uses: actions/upload-artifact@v4 if: github.event_name != 'pull_request' @@ -107,13 +104,8 @@ jobs: - name: Set version name run: | sed -ri "s#^version: .+#version: $VERSION#g" pubspec.yaml - sed -ri "s#..dsn = ''#..dsn = '$SENTRY_DSN'#g" ./lib/bootstrap.dart - sed -ri "s#..release = 'release'#..release = '$RELEASE'#g" ./lib/bootstrap.dart env: VERSION: ${{ needs.test.outputs.version }} - ENVIRONMENT: ${{ needs.test.outputs.environment }} - RELEASE: ${{ needs.test.outputs.release }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - name: Setup Flutter uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: @@ -125,6 +117,8 @@ jobs: flutter build web --web-renderer=html --source-maps -t ./lib/main_$ENVIRONMENT.dart env: ENVIRONMENT: ${{ needs.test.outputs.environment }} + SENTRY_RELEASE: ${{ needs.test.outputs.release }} + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - name: Upload web version uses: actions/upload-artifact@v4 if: github.event_name != 'pull_request' @@ -149,13 +143,8 @@ jobs: - name: Set version name run: | sed -ri "s#^version: .+#version: $VERSION#g" pubspec.yaml - sed -ri "s#..dsn = ''#..dsn = '$SENTRY_DSN'#g" .\lib\bootstrap.dart - sed -ri "s#..release = 'release'#..release = '$RELEASE'#g" .\lib\bootstrap.dart env: VERSION: ${{ needs.test.outputs.version }} - ENVIRONMENT: ${{ needs.test.outputs.environment }} - RELEASE: ${{ needs.test.outputs.release }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - name: Setup Flutter uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 with: @@ -167,6 +156,8 @@ jobs: flutter build windows -t ./lib/main_${env:ENVIRONMENT}.dart env: ENVIRONMENT: ${{ needs.test.outputs.environment }} + SENTRY_RELEASE: ${{ needs.test.outputs.release }} + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - name: Upload windows version uses: actions/upload-artifact@v4 if: github.event_name != 'pull_request' diff --git a/CHANGELOG.md b/CHANGELOG.md index 527a523e..4a363eb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/ - 物品管理位置二维码支持完整的网址 +### Changed + +- 优化 Sentry 相关配置的设置方法 + ### Fixed - 修复搜索位置无法显示的问题 diff --git a/lib/bootstrap.dart b/lib/bootstrap.dart index d396a10a..2e31f791 100644 --- a/lib/bootstrap.dart +++ b/lib/bootstrap.dart @@ -37,9 +37,9 @@ Future bootstrap(AppConfig appConfig) async { await SentryFlutter.init( (options) { options - ..dsn = '' - ..environment = 'dev' - ..release = 'release'; + ..dsn = const String.fromEnvironment('SENTRY_DSN', defaultValue: '') + ..environment = appConfig.flavorName + ..release = const String.fromEnvironment('SENTRY_RELEASE'); }, appRunner: () => runApp( MyApp(