Skip to content

Commit

Permalink
Merge pull request #5 from dolthub/liuliu/app-publish
Browse files Browse the repository at this point in the history
publish app
  • Loading branch information
liuliu-dev authored Oct 18, 2024
2 parents 16d9eb1 + 12b9433 commit d75969a
Show file tree
Hide file tree
Showing 28 changed files with 519 additions and 360 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ dist
.yarn/*

.env

/build/mac/*.provisionprofile
109 changes: 109 additions & 0 deletions README.publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Release and update for Mac:

### Prerequisite

- You need a developer account and contact tim for access.
- Download the provision profiles and install the certificates from Apple connect, instructions in this blog: https://www.dolthub.com/blog/2024-10-02-how-to-submit-an-electron-app-to-mac-app-store/#generate-provisioning-profiles

### Build the package

1. Fetch the changes from [workbench repo](https://github.com/dolthub/dolt-workbench), merge the changes into your local [desktop repo](https://github.com/dolthub/dolt-workbench-desktop)

2. Install dependencies and build in the `graphql-server` directory:

```bash
# in `graphql-server`
yarn
yarn build
```

3. Install dependencies in root:

```bash
# in the root directory of the repo
yarn
```

4. Build the package

```bash
# in the root directory of the repo
yarn build
```

The builds will show up in `dist` folder, including a `Dolt Workbench-mac-arm64.dmg` file, a `mac-arm64` folder and a `mas-universal` folder. Inside the `mac-arm64` folder is the app that you can run locally.

### Submit to MAC store

We will only use `mas-universal` folder for submitting to MAC store. There will be a `Dolt Workbench.app` application file and a `Dolt Workbench-mac-universal.pkg` installer file inside it. These files could not be used locally, they are for MAC store submission, when double clicking on them, it will show as "could not be opened", this is expected because they are packed in sandbox and need to be signed by Apple before distribution.

The preferred tool to submit is the [Transporter app](https://apps.apple.com/us/app/transporter/id1450874784) which can be downloaded free from the Mac App Store.It will check for errors. Open the Transporter app > Drag and drop `Dolt Workbench-mac-universal.pkg` file into the Transporter app. If no errors found click the Deliver button to send the app to your developer account.

Go to appstoreconnect.apple.com and click Apps > Dolt Workbench, Click the `+` sign in the left panel to add a new version. Enter the new version number that matches the version in the package.json file. Fill out: What's New in This Version. In the Build section select the build you just submitted (this will take a few minutes to be available after delivered through Transporter) and click Submit for Review.

### Code sign for distributing outside MAC store

We can code sign the `Dolt Workbench-mac-arm64.dmg` file and allow people to download it from the release page on Github.

Sign the DMG file using your Developer ID Application certificate:

```bash
cd dist
codesign --force --verify --verbose --sign "Developer ID Application: Your Name (Team ID)" Dolt\ Workbench-mac-arm64.dmg
```

To ensure it’s properly signed, run:

```bash
codesign -vvv Dolt\ Workbench-mac-arm64.dmg
```

You should see after running the command:

```bash
Dolt Workbench-mac-arm64.dmg: valid on disk
Dolt Workbench-mac-arm64.dmg: satisfies its Designated Requirement
```

You will need "App Specific Passwords" in this step. Go to [Apple ID](https://account.apple.com/account/manage), in Sign-in and Security section, find `App-Specific Password`. Create one app-specific password for your app.

![App specific password](../images/app-specific-password.png)

Submit the app to Apple’s notarization service.

```bash
xcrun notarytool submit Dolt\ Workbench-mac-arm64.dmg --apple-id "your-apple-id" --password "your-app-specific-password" --team-id "your-team-id" --wait
```

This step will take some time, you will see `Accepted` if all goes well.

```bash
Conducting pre-submission checks for Dolt\ Workbench-mac-arm64.dmg and initiating connection to the Apple notary service...
Submission ID received
id: your-app-submission-id
Upload progress: 100.00% (176 MB of 176 MB)
Successfully uploaded file
id: your-app-submission-id
path: /path/to/Dolt Workbench-mac-arm64.dmg
Waiting for processing to complete.
Current status: Accepted...........................................
Processing complete
id: your-app-submission-id
status: Accepted
```

Once the notarization process is successful, staple the notarization ticket to the app:

```bash
xcrun stapler staple Dolt\ Workbench-mac-arm64.dmg
```

The output should be:

```bash
Processing: /path/to/Dolt Workbench-mac-arm64.dmg
Processing: /path/to/Dolt Workbench-mac-arm64.dmg
The staple and validate action worked!
```

The app is now fully signed and notarized, ready for distribution.
File renamed without changes.
File renamed without changes
Binary file removed build/icon.icns
Binary file not shown.
Binary file added build/mac/AppIcon.icns
Binary file not shown.
Binary file added build/mac/Assets.car
Binary file not shown.
12 changes: 12 additions & 0 deletions build/mac/entitlements.inherit.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
11 changes: 11 additions & 0 deletions build/mac/entitlements.mas.inherit.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>

</dict>
</plist>
18 changes: 18 additions & 0 deletions build/mac/entitlements.mas.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>FK9YU86WZ5.com.dolthub.dolt-workbench</string>
</array>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
18 changes: 18 additions & 0 deletions build/mac/entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
Binary file added build/mac/icon.iconset/icon_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 0 additions & 48 deletions builder-config.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion graphql-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@
"@typescript-eslint/parser": "^7.8.0",
"eslint": "^8.52.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"jest": "^29.7.0",
"prettier": "^3.1.1",
Expand Down
14 changes: 10 additions & 4 deletions graphql-server/src/fileStore/fileStore.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Injectable } from "@nestjs/common";
import * as fs from "fs";
import { resolve } from "path";
import path, { resolve } from "path";
import { DatabaseConnection } from "../databases/database.model";

const storePath = resolve(__dirname, "../../store/store.json");
const storePath =
process.env.NEXT_PUBLIC_FOR_ELECTRON === "true"
? path.join(process.env.NEXT_PUBLIC_USER_DATA_PATH || "", "store.json")
: resolve(__dirname, "../../store/store.json");

@Injectable()
export class FileStoreService {
Expand Down Expand Up @@ -37,8 +40,11 @@ export class FileStoreService {
}

store.push(item);

if (!fs.existsSync(resolve(__dirname, "../../store"))) {
if (process.env.NEXT_PUBLIC_FOR_ELECTRON === "true") {
if (!fs.existsSync(process.env.NEXT_PUBLIC_USER_DATA_PATH || "")) {
fs.mkdirSync(process.env.NEXT_PUBLIC_USER_DATA_PATH || "");
}
} else if (!fs.existsSync(resolve(__dirname, "../../store"))) {
fs.mkdirSync(resolve(__dirname, "../../store"));
}

Expand Down
5 changes: 3 additions & 2 deletions graphql-server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,10 @@ __metadata:
cors: "npm:^2.8.5"
eslint: "npm:^8.52.0"
eslint-config-airbnb: "npm:^19.0.4"
eslint-config-airbnb-base: "npm:^15.0.0"
eslint-config-airbnb-typescript: "npm:^18.0.0"
eslint-config-prettier: "npm:^9.0.0"
eslint-plugin-import: "npm:^2.30.0"
eslint-plugin-import: "npm:^2.31.0"
eslint-plugin-jest: "npm:^28.8.3"
graphql: "npm:^16.9.0"
graphql-upload: "npm:15.0.0"
Expand Down Expand Up @@ -4220,7 +4221,7 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-import@npm:^2.30.0":
"eslint-plugin-import@npm:^2.31.0":
version: 2.31.0
resolution: "eslint-plugin-import@npm:2.31.0"
dependencies:
Expand Down
6 changes: 2 additions & 4 deletions main/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const schemaPath = isProd
: "graphql-server/schema.gql";
process.env.SCHEMA_PATH = schemaPath;
process.env.NEXT_PUBLIC_FOR_ELECTRON = "true";
process.env.NEXT_PUBLIC_USER_DATA_PATH = userDataPath;

if (isProd) {
serve({ directory: "app" });
Expand Down Expand Up @@ -148,10 +149,7 @@ app.on("before-quit", () => {
});

app.on("window-all-closed", () => {
// On macOS, closing all windows shouldn't exit the process
if (process.platform !== "darwin") {
app.quit();
}
app.quit();
});

// This does not work
Expand Down
Loading

0 comments on commit d75969a

Please sign in to comment.