Skip to content

Commit

Permalink
Merge pull request #144 from Crossbell-Box/develop
Browse files Browse the repository at this point in the history
chore: Upload sourcemaps after updates published.
  • Loading branch information
dohooo authored Jun 24, 2023
2 parents b0f8a0f + 3209303 commit ebc567f
Show file tree
Hide file tree
Showing 10 changed files with 423 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-bats-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"xlog": patch
---

Upload sourcemaps after updates published.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"crossbell",
"haptics",
"jsbundle",
"prebuild",
"Roadmap",
"SIWE",
Expand Down
14 changes: 11 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
import { QueryClient } from "@tanstack/react-query";
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
import WalletConnectProvider from "@walletconnect/react-native-dapp";
import ExpoConstants from "expo-constants";
import { resolveScheme } from "expo-linking";
import { updateId } from "expo-updates";
import * as Sentry from "sentry-expo";
import type { SentryExpoNativeOptions } from "sentry-expo";
import { TamaguiProvider } from "tamagui";

import { ErrorBoundary } from "@/components/ErrorBoundary";
import ProviderComposer from "@/components/ProviderComposer";
import { StatusBar } from "@/components/StatusBar";
import { IS_DEV } from "@/constants";
import { IS_IOS } from "@/constants";
import { ENV, SENTRY_DSN } from "@/constants/env";
import { ConnectKitProvider } from "@/providers/connect-kit-provider";
import { DrawerProvider } from "@/providers/drawer-provider";
Expand All @@ -44,16 +46,22 @@ import { RootNavigator } from "./src/navigation/root";
import { createAsyncStoragePersister } from "./src/utils/persister";
import config from "./tamagui.config";

const bundleIdentifier = ExpoConstants.expoConfig.scheme;

const versionNumber = IS_IOS ? ExpoConstants.expoConfig.ios.buildNumber : ExpoConstants.expoConfig.android.versionCode;

enableScreens(true);
enableFreeze(true);

if (!IS_DEV) {
if (!__DEV__) {
const SENTRY_CONFIG: SentryExpoNativeOptions = {
dsn: SENTRY_DSN,
enableInExpoDevelopment: true,
debug: IS_DEV,
debug: __DEV__,
attachScreenshot: true,
environment: ENV,
dist: updateId,
release: `${bundleIdentifier}@${version}+${versionNumber}`,
};

Sentry.init(SENTRY_CONFIG);
Expand Down
61 changes: 6 additions & 55 deletions app.config.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,19 @@
/* eslint-disable no-console */
import * as dotenv from "dotenv";
import type { ExpoConfig, ConfigContext } from "expo/config";

import { version as _version } from "./package.json";
import { appConfig, environment, decreasedVersion } from "./scripts/set-app-config-env.js";

const ENV = process.env.NODE_ENV ?? "production";

if (process.env.EAS_BUILD === "true") {
dotenv.config({ path: process.env.ENV_FILE_COMMON });
dotenv.config({ path: process.env[`ENV_FILE_${ENV.toUpperCase()}`] });
}
else {
dotenv.config({ path: ".env.common" });
dotenv.config({ path: `.env.${ENV}` });
}

console.log("ENV:", ENV);

const SCHEME = process.env.APP_SCHEME;
const HOST = process.env.APP_HOST;

const envConfig = {
development: {
name: "xLog-dev",
host: HOST,
scheme: `${SCHEME}.development`,
icon: "./assets/icon.development.png",
},
staging: {
name: "xLog-preview",
host: HOST,
scheme: `${SCHEME}.staging`,
icon: "./assets/icon.staging.png",
},
production: {
name: "xLog",
host: HOST,
scheme: SCHEME,
icon: "./assets/icon.png",
},
};

const config = envConfig[ENV] as typeof envConfig[keyof typeof envConfig];
const config = appConfig;

console.log(JSON.stringify(config, null, 4));

/**
* Ignoring patch version
* @example 1.1.1 -> 1.1.0 / 4.2.1 -> 4.2.0
* */
function decrementVersion(version: string) {
const parts = version.split(".");
parts[parts.length - 1] = "0";
return parts.join(".");
}

const version = decrementVersion(_version);

const postPublish = [];

if (ENV !== "development") {
if (environment !== "development") {
postPublish.push({
file: "sentry-expo/upload-sourcemaps",
config: {
setCommit: true,
organization: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
Expand All @@ -75,7 +26,7 @@ export default (_: ConfigContext): ExpoConfig => {
name: config.name,
description: "The first on-chain and open-source blogging platform for everyone",
slug: "xlog",
version,
version: decreasedVersion,
scheme: config.scheme,
orientation: "portrait",
icon: config.icon,
Expand Down Expand Up @@ -161,7 +112,7 @@ export default (_: ConfigContext): ExpoConfig => {
CSB_XCHAR: process.env.CSB_XCHAR,
SENTRY_DSN: process.env.SENTRY_DSN,
APP_HOST: config.host,
ENV,
ENV: environment,
eas: {
projectId: process.env.EXPO_PROJECT_ID,
},
Expand Down
3 changes: 2 additions & 1 deletion eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"ios": {
"resourceClass": "large"
},
"channel": "preview"
"channel": "preview",
"autoIncrement": true
},
"production": {
"env": {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"web": "NODE_ENV=development expo start --web",
"release:version": "changeset status & changeset version",
"release:publish": "changeset tag",
"update:production": "NODE_ENV=production eas update --non-interactive --channel production --auto",
"update:preview": "NODE_ENV=staging eas update --non-interactive --channel preview --auto",
"update:production": "NODE_ENV=production npx node scripts/eas-update.js npx eas update --non-interactive --channel preview --auto",
"update:preview": "NODE_ENV=staging npx node scripts/eas-update.js npx eas update --non-interactive --channel preview --auto",
"build:development": "NODE_ENV=development eas build --non-interactive --profile development",
"build:preview": "NODE_ENV=staging eas build --non-interactive --profile preview",
"build:production": "eas build --non-interactive --profile production --auto-submit",
Expand Down Expand Up @@ -59,6 +59,7 @@
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"@react-navigation/stack": "^6.3.16",
"@sentry/cli": "^2.19.1",
"@sentry/react-native": "4.15.2",
"@shopify/flash-list": "1.4.0",
"@showtime-xyz/tab-view": "^0.1.7",
Expand Down
Loading

0 comments on commit ebc567f

Please sign in to comment.