-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy_project.sh
executable file
·50 lines (40 loc) · 1.88 KB
/
deploy_project.sh
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
#!/bin/bash
set -eo pipefail
# Function to display error message and exit
error_exit() {
echo "$1" >&2
exit 1
}
VERSION_INPUT=${1}
SENTRY_ORG_INPUT=${2}
SENTRY_PROJECT_INPUT=${3}
SENTRY_AUTH_TOKEN_INPUT=${4}
# Build the release bundle
echo "Building the release bundle..."
SENTRY_ORG=$SENTRY_ORG_INPUT SENTRY_PROJECT=$SENTRY_PROJECT_INPUT SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN_INPUT xcodebuild -project EmpowerPlant.xcodeproj -scheme EmpowerPlant -configuration Release -derivedDataPath build -destination "platform=iOS Simulator,OS=latest,name=iPhone 15" -quiet clean build
zip -r EmpowerPlant_release.zip ./build/Build/Products/Release-iphonesimulator/EmpowerPlant.app
ZIP_PATH="./EmpowerPlant_release.zip"
# Check if gh is installed
if ! command -v gh &> /dev/null; then
error_exit "gh is not installed, make sure you run 'make init' (see README.md)."
fi
# Get release version
if [ "$#" -eq 1 ]; then
TAG="$1"
else
echo "Release name not provided as CLI argument, incrementing patch version of latest release in GH then..."
# Fetch the most recent release tag using gh and sort
LATEST_RELEASE=$(gh release list | sort -V | tail -n 1 | awk '{print $1}')
if [ -z "$LATEST_RELEASE" ]; then
error_exit "Could not find any existing releases in GitHub. This is either a bug in the script or this is being run in a new repo with no releases."
fi
# Split the version and increment the last digit
IFS='.' read -ra VERSION_PARTS <<< "$LATEST_RELEASE"
LAST_DIGIT_INCREMENTED=$(( ${VERSION_PARTS[2]} + 1 ))
TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$LAST_DIGIT_INCREMENTED"
fi
TITLE="$TAG"
NOTES="Generated automatically by ios/deploy_project.sh"
# Create the GitHub release with the attached iOS build zip
gh release create $TAG $ZIP_PATH -t "$TITLE" -n "$NOTES" || error_exit "Failed to create GitHub release."
echo "Release created successfully with version $TAG!"