Skip to content

Commit

Permalink
feat: use secrets for keys (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
Canny authored Nov 23, 2022
1 parent b0c4567 commit 6ea055d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/debug-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
- name: Set environment variables
run: echo $SECRETS | base64 -d > lib/utils/environment.dart
env:
SECRETS: ${{ secrets.SECRETS }}
- name: Set up Flutter
run: flutter pub get
- name: Generate files with Builder
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
- name: Set environment variables
run: echo $SECRETS | base64 -d > lib/utils/environment.dart
env:
SECRETS: ${{ secrets.SECRETS }}
- name: Set up Flutter
run: flutter pub get
- name: Generate files with Builder
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,4 @@ app.*.map.json
!/dev/ci/**/Gemfile.lock

Firebase related
.firebase
/lib/utils/environment.dart
.firebase
48 changes: 24 additions & 24 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:revanced_manager/utils/environment.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:stacked_themes/stacked_themes.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Expand All @@ -23,35 +24,34 @@ Future main() async {
String apiUrl = locator<ManagerAPI>().getApiUrl();
await locator<RevancedAPI>().initialize(apiUrl);
await locator<CrowdinAPI>().initialize();
// bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
locator<GithubAPI>().initialize();
await locator<PatcherAPI>().initialize();
tz.initializeTimeZones();
prefs = await SharedPreferences.getInstance();

// Remove this section if you are building from source and don't have sentry configured
// await SentryFlutter.init(
// (options) {
// options
// ..dsn = isSentryEnabled ? '' : ''
// ..environment = 'alpha'
// ..release = '0.1'
// ..tracesSampleRate = 1.0
// ..anrEnabled = true
// ..enableOutOfMemoryTracking = true
// ..sampleRate = isSentryEnabled ? 1.0 : 0.0
// ..beforeSend = (event, hint) {
// if (isSentryEnabled) {
// return event;
// } else {
// return null;
// }
// } as BeforeSendCallback?;
// },
// appRunner: () {
// runApp(const MyApp());
// },
// );
await SentryFlutter.init(
(options) {
options
..dsn = isSentryEnabled ? Environment.sentryDSN : ''
..environment = 'alpha'
..release = '0.1'
..tracesSampleRate = 1.0
..anrEnabled = true
..enableOutOfMemoryTracking = true
..sampleRate = isSentryEnabled ? 1.0 : 0.0
..beforeSend = (event, hint) {
if (isSentryEnabled) {
return event;
} else {
return null;
}
} as BeforeSendCallback?;
},
appRunner: () {
runApp(const MyApp());
},
);
runApp(const MyApp());
}

Expand Down
5 changes: 5 additions & 0 deletions lib/utils/environment.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Dummy environment variables used for building the app locally. These automatically get set with correct values during workflow builds.
class Environment {
static const sentryDSN = '';
static const crowdinKEY = '';
}

0 comments on commit 6ea055d

Please sign in to comment.