forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-ios.sh
More file actions
executable file
路69 lines (60 loc) 路 2.28 KB
/
Copy pathbuild-ios.sh
File metadata and controls
executable file
路69 lines (60 loc) 路 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -euo pipefail
COMMAND="${1:-build}"
BUMP_TYPE="${2:-patch}"
bump_version() {
local type="$1"
agvtool what-marketing-version -terse1 | read current_version || current_version="1.0.0"
node -e "
let [major, minor, patch] = '${current_version:-1.0.0}'.split('.').map(Number);
if ('$type' === 'major') { major++; minor = 0; patch = 0; }
else if ('$type' === 'minor') { minor++; patch = 0; }
else { patch++; }
const newVersion = \`\${major}.\${minor}.\${patch}\`;
const { execSync } = require('child_process');
execSync(\`agvtool new-marketing-version \${newVersion}\`);
execSync('agvtool next-version -all');
console.log('iOS version bumped to', newVersion);
"
}
build_ios() {
# Install certificate
echo "$IOS_CERTIFICATE_BASE64" | base64 -d > /tmp/certificate.p12
security create-keychain -p "" build.keychain
security import /tmp/certificate.p12 -k build.keychain -P "$IOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security list-keychains -s build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "" build.keychain
security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain
# Install provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
echo "$IOS_PROVISIONING_PROFILE_BASE64" | base64 -d > ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision
# Build
xcodebuild -workspace ios/GistPin.xcworkspace \
-scheme GistPin \
-configuration Release \
-archivePath ios/build/GistPin.xcarchive \
DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \
archive
xcodebuild -exportArchive \
-archivePath ios/build/GistPin.xcarchive \
-exportPath ios/build \
-exportOptionsPlist ios/ExportOptions.plist
echo "iOS IPA built successfully."
}
upload_testflight() {
echo "$APPLE_API_KEY_BASE64" | base64 -d > /tmp/AuthKey.p8
xcrun altool --upload-app \
--type ios \
--file ios/build/GistPin.ipa \
--apiKey "$APPLE_API_KEY_ID" \
--apiIssuer "$APPLE_API_ISSUER_ID" \
--private-key /tmp/AuthKey.p8
echo "Uploaded to TestFlight."
}
case "$COMMAND" in
bump) bump_version "$BUMP_TYPE" ;;
build) build_ios ;;
upload) upload_testflight ;;
*) echo "Usage: $0 [bump|build|upload] [patch|minor|major]"; exit 1 ;;
esac