7.5 KiB
Environment Variables Setup Guide
Copy .env.example to .env and fill in the values below. This guide walks you through getting every single one.
cp .env.example .env
BACKEND_PORT
The port the backend server runs on. The default is fine — only change it if something else is already using port 8324.
BACKEND_PORT=8324
GOOGLE_OAUTH_CLIENT_ID & GOOGLE_OAUTH_CLIENT_SECRET
These let users sign in with their Google account.
Step 1 — Go to Google Cloud Console
- Open https://console.cloud.google.com/
- Sign in with your Google account (or create one).
Step 2 — Create a project
- Click the project dropdown at the very top of the page (it says "Select a project" or shows your current project name).
- Click New Project in the top-right of the popup.
- Name it something like
OpenSwarm. - Click Create.
- Wait a few seconds, then click the project dropdown again and select your new
OpenSwarmproject.
Step 3 — Enable the Google+ API (required for OAuth)
- In the left sidebar, click APIs & Services > Library.
- Search for
Google+ API(orGoogle Identity). - Click on it, then click Enable.
Step 4 — Configure the OAuth consent screen
- In the left sidebar, click APIs & Services > OAuth consent screen.
- Select External (unless you're inside a Google Workspace org and only want internal users).
- Click Create.
- Fill in the required fields:
- App name:
OpenSwarm - User support email: your email
- Developer contact email: your email
- App name:
- Click Save and Continue.
- On the Scopes page, click Add or Remove Scopes.
- Check
emailandprofile(theopenidscope is added automatically). - Click Update, then Save and Continue.
- Check
- On the Test users page, click Add Users, enter your own email, click Add, then Save and Continue.
- Click Back to Dashboard.
Step 5 — Create OAuth credentials
- In the left sidebar, click APIs & Services > Credentials.
- Click + Create Credentials at the top.
- Select OAuth client ID.
- For Application type, select Web application.
- Name:
OpenSwarm(or anything you want). - Under Authorized redirect URIs, click + Add URI and add:
(Replace
http://localhost:8324/api/auth/google/callback8324with yourBACKEND_PORTif you changed it.) - Click Create.
Step 6 — Copy the values
A popup appears with your credentials:
- Client ID — copy this into
GOOGLE_OAUTH_CLIENT_ID - Client Secret — copy this into
GOOGLE_OAUTH_CLIENT_SECRET
GOOGLE_OAUTH_CLIENT_ID=123456789-xxxxxxxxx.apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxx
APPLE_ID
This is the email address you use to sign in to your Apple Developer account.
- If you don't have one, go to https://developer.apple.com/programs/ and click Enroll. It costs $99/year.
- Once enrolled, your
APPLE_IDis just the email you signed up with.
APPLE_ID=you@example.com
APPLE_TEAM_ID
Your 10-character Apple Developer team identifier.
- Go to https://developer.apple.com/account
- Sign in.
- Look at the top-right — your name is shown. Click it, or scroll down.
- Under Membership Details (or at https://developer.apple.com/account#MembershipDetailsCard), you'll see Team ID.
- It looks like
ABCDE12345. Copy it.
APPLE_TEAM_ID=ABCDE12345
APPLE_APP_SPECIFIC_PASSWORD
Apple doesn't let you use your regular password for automated tools. You need to generate a special one-time password.
Step 1 — Turn on two-factor authentication (if you haven't already)
- On your Mac, go to System Settings > [your name] > Sign-In & Security > Two-Factor Authentication.
- Turn it on and follow the prompts.
Step 2 — Generate the app-specific password
- Go to https://account.apple.com/
- Sign in with your Apple ID.
- In the Sign-In and Security section, click App-Specific Passwords.
- Click Generate an app-specific password (or the + button).
- Enter a label like
OpenSwarm Notarization. - Click Create.
- Apple shows you a password in the format
xxxx-xxxx-xxxx-xxxx. Copy it now — you can't see it again.
APPLE_APP_SPECIFIC_PASSWORD=abcd-efgh-ijkl-mnop
macOS Signing Certificate (no env var, but required)
Before you can sign and notarize, you need a Developer ID Application certificate installed in your macOS Keychain. This is what Apple uses to verify that the app was built by you.
Step 1 — Open Xcode
- Open Xcode on your Mac (install it from the Mac App Store if you don't have it).
- Go to Xcode menu > Settings (or Preferences on older versions).
- Click the Accounts tab.
- Click + in the bottom-left and sign in with your Apple ID.
Step 2 — Create the certificate
- Select your account in the list, then click Manage Certificates... in the bottom-right.
- Click the + in the bottom-left of the popup.
- Select Developer ID Application.
- Click Create.
That's it — the certificate is now in your macOS Keychain. electron-builder will auto-discover it during builds. You don't need to set any env var for this.
Alternative — manual method (without Xcode)
- Go to https://developer.apple.com/account/resources/certificates/list
- Click the + button.
- Select Developer ID Application, click Continue.
- You'll be asked to upload a Certificate Signing Request (CSR):
- Open Keychain Access on your Mac.
- In the menu bar: Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority.
- Enter your email, leave CA Email blank, select Saved to disk, click Continue.
- Save the
.certSigningRequestfile.
- Upload that file on the Apple Developer page, click Continue.
- Download the
.cerfile. - Double-click it — it installs into your Keychain.
GH_TOKEN
A GitHub Personal Access Token that lets the build script upload release artifacts to GitHub Releases.
Step 1 — Go to GitHub token settings
- Go to https://github.com/settings/tokens
- Sign in if needed.
Step 2 — Create a token
- Click Generate new token > Generate new token (classic).
- Note:
OpenSwarm Releases(or whatever you want). - Expiration: pick a duration (90 days, or "No expiration" if you don't want to rotate it).
- Scopes: check the
repocheckbox (this gives full access to your repositories, which is needed to create releases and upload assets). - Click Generate token at the bottom.
- Copy the token now — it starts with
ghp_and you won't be able to see it again.
GH_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Final .env example
BACKEND_PORT=8324
GOOGLE_OAUTH_CLIENT_ID=123456789-xxxxxxxxx.apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxx
APPLE_ID=you@example.com
APPLE_APP_SPECIFIC_PASSWORD=abcd-efgh-ijkl-mnop
APPLE_TEAM_ID=ABCDE12345
GH_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Running a production build
Once your .env is filled in, just run:
./scripts/build-app.sh --publish
The build script automatically loads backend/.env, so you don't need to source it yourself. This will build the app, sign it with your certificate, notarize it with Apple, and upload the .dmg and .zip to a GitHub Release.