feat: add GitHub Actions ad-hoc iOS build workflow

- Creates workflow for building without Apple Developer Program
- Uses Apple-Actions for certificate import
- Outputs .app file as artifact for sideloading

See ADHOC_BUILD_GUIDE.md for setup instructions
This commit is contained in:
bananabas 2026-03-28 08:01:08 +00:00
parent 8fc637841f
commit c4bb03ac76
2 changed files with 182 additions and 0 deletions

70
.github/workflows/build-ios-adhoc.yml vendored Normal file
View file

@ -0,0 +1,70 @@
name: Build iOS Ad-Hoc
on:
workflow_dispatch:
push:
branches: [main]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
cd apps/mobile
bun install
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install CocoaPods
run: |
cd apps/mobile/ios
pod install
- name: Import Apple Certificate
uses: Apple-Actions/import-codesign-certificates@v2
with:
p12-file-base64: ${{ secrets.CERTIFICATE_P12 }}
p12-password: ${{ secrets.CERT_P12_PASSWORD }}
- name: Add Provisioning Profile
run: |
PROFILE_NAME=${{ secrets.PROFILE_NAME }}
PROFILE_BASE64=${{ secrets.PROVISIONING_PROFILE }}
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
echo "$PROFILE_BASE64" | base64 -d -o "$HOME/Library/MobileDevice/Provisioning Profiles/$PROFILE_NAME.mobileprovision"
- name: Build iOS
run: |
cd apps/mobile
xcodebuild -workspace ios/Bagsy.xcworkspace \
-scheme Bagsy \
-configuration Debug \
-destination generic/platform=iOS \
CODE_SIGN_IDENTITY="${{ secrets.CERT_NAME }}" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
build
- name: Find and upload app
run: |
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "Bagsy.app" -type d | head -1)
echo "Found app at: $APP_PATH"
zip -r bagsy-app.zip "$APP_PATH"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bagsy-adhoc-build
path: bagsy-app.zip

112
ADHOC_BUILD_GUIDE.md Normal file
View file

@ -0,0 +1,112 @@
# iOS Ad-Hoc Build Setup Guide
This guide walks you through setting up ad-hoc signing for your Bagsy iOS app without an Apple Developer Program membership.
## Prerequisites
1. **Free Apple ID** - Use your personal Apple ID
2. **Your iPhone 16 connected to Mac** via USB
3. **GitHub account** to store secrets
## Step 1: Get Your iPhone UDID
1. Connect iPhone 16 to Mac via USB
2. Open Finder → Click on your iPhone in the sidebar
3. Click the phone icon in the top bar of the Finder window
4. Look for "Serial Number" or click on the info icon (ℹ️)
5. Click on the serial number - it will change to show "UDID"
6. Copy the UDID (it looks like: `00001234-0001234567ABCDEF`)
## Step 2: Create Signing Certificate (Mac)
```bash
# 1. Create a Certificate Signing Request (CSR)
cd ~/Documents
mkdir csr
cd csr
# This will create a public/private key pair
security create-keychain -p "BagsyKeychain" Bagsy.keychain
security set-keychain-settings -t 9600 -l Bagsy.keychain
# Generate the CSR
security keychain default -keychain ~/Library/Keychains/login.keychain
security find-certificate -c "Apple Development" login.keychain
# Use Keychain Access app:
# 1. Open Keychain Access
# 2. Menu: Keychain Access → Certificate Assistant → Request a Certificate Authority...
# 3. Choose "Saved to disk"
# 4. Enter your email and name
# 5. Save as "BagsySigningRequest.certSigningRequest"
```
## Step 3: Get Free Certificate from Apple
1. Go to https://developer.apple.com/account
2. Sign in with your free Apple ID
3. Click "Certificates, Identifiers & Profiles"
4. Click "+" to create a new certificate
5. Select "Apple Development" or "Apple Distribution"
6. Upload your CSR file
7. Download the certificate (`.cer` file)
## Step 4: Convert to P12 (Mac)
```bash
# Open the .cer file by double-clicking to install to Keychain
# Then export as p12:
# Open Keychain Access, find your certificate
# Right click → Export → Save as "Bagsy.p12"
# Set a password (remember this!)
```
## Step 5: Create Ad-Hoc Provisioning Profile (Mac)
1. Go to https://developer.apple.com/account → Certificates
2. Click "+" → Select "Ad Hoc"
3. Choose your App ID (create if needed: `com.barnabas.bagsy`)
4. Select your certificate from Step 3
5. Add your iPhone UDID from Step 1
6. Name it: "Bagsy Ad-Hoc"
7. Download the `.mobileprovision` file
## Step 6: Setup GitHub Secrets
Go to your GitHub repo → Settings → Secrets → Actions and add:
| Secret Name | Value |
| ---------------------- | ----------------------------------------------------------------------------------- |
| `CERTIFICATE` | Base64 of your `.p12` file: `base64 -w0 Bagsy.p12` |
| `KEY_PASSWORD` | Password you set for keychain |
| `P12_PASSWORD` | Password you set when exporting p12 |
| `CERTIFICATE_NAME` | "Apple Distribution: Your Name (TEAMID)" or "Apple Development: Your Name (TEAMID)" |
| `PROVISIONING_PROFILE` | Base64 of mobileprovision: `base64 -w0 Bagsy.mobileprovision` |
| `PROFILE_NAME` | "Bagsy Ad-Hoc" |
## Step 7: Run the Build
1. Push to main branch, or
2. Go to GitHub Actions → Build iOS Ad-Hoc → Run workflow
## Generating Base64 Values
```bash
# Get base64 for certificate (Mac terminal)
base64 -w0 Bagsy.p12
# Copy output as CERTIFICATE secret
# Get base64 for provisioning profile
base64 -w0 Bagsy\ Ad-Hoc.mobileprovision
# Copy output as PROVISIONING_PROFILE secret
```
---
**Note:** This creates an unsigned build that can be installed on YOUR iPhone 16 only (because it's ad-hoc with your UDID embedded). To test, you'll need to either:
- Download the .app from GitHub Actions and sideload via Xcode
- Or use a tool like idevicelocation 管理与配置
Let me also update the workflow to be more correct: