-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kevin T. Coughlin <[email protected]>
- Loading branch information
1 parent
10df3e0
commit 862036b
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Xcode - Build and Analyze | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
name: Build and analyze default scheme using xcodebuild | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Determine Default Scheme | ||
run: | | ||
# Get the default scheme from the target list | ||
scheme=$(xcodebuild -list -json | jq -r '.project.targets[0]') | ||
echo "Default scheme detected: $scheme" | ||
echo "scheme=$scheme" >> $GITHUB_ENV | ||
- name: Identify Xcode Project or Workspace | ||
run: | | ||
# Check if workspace or project exists, and set the build target | ||
if [[ -n "$(ls *.xcworkspace 2>/dev/null)" ]]; then | ||
filetype="workspace" | ||
file_to_build=$(ls *.xcworkspace | head -n 1) | ||
elif [[ -n "$(ls *.xcodeproj 2>/dev/null)" ]]; then | ||
filetype="project" | ||
file_to_build=$(ls *.xcodeproj | head -n 1) | ||
else | ||
echo "No .xcworkspace or .xcodeproj found." >&2 | ||
exit 1 | ||
fi | ||
echo "Detected Xcode $filetype: $file_to_build" | ||
echo "filetype=$filetype" >> $GITHUB_ENV | ||
echo "file_to_build=$file_to_build" >> $GITHUB_ENV | ||
- name: Build and Analyze | ||
env: | ||
scheme: ${{ env.scheme }} | ||
filetype: ${{ env.filetype }} | ||
file_to_build: ${{ env.file_to_build }} | ||
run: | | ||
# Clean, build, and analyze the project | ||
xcodebuild clean build analyze -scheme "$scheme" -"$filetype" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} |