Skip to content

Commit

Permalink
build: 优化 Sentry 相关配置的设置方法 (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 authored Feb 6, 2024
1 parent e2a7c72 commit d0b7858
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'
Expand All @@ -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:
Expand All @@ -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'
Expand All @@ -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:
Expand All @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/

- 物品管理位置二维码支持完整的网址

### Changed

- 优化 Sentry 相关配置的设置方法

### Fixed

- 修复搜索位置无法显示的问题
Expand Down
6 changes: 3 additions & 3 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Future<void> 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(
Expand Down

0 comments on commit d0b7858

Please sign in to comment.