Skip to content

Commit 9c7af7a

Browse files
committed
ci: add GitHub Actions workflows for Xcode build, analyze, and release
- xcode-build.yml: build and analyze on push/PR to main (Xcode 26.3.0) - release.yml: build, package, and publish release on v* tag push
1 parent 26d570a commit 9c7af7a

2 files changed

Lines changed: 134 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Xcode - Build, Package and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # Triggers the workflow only when you push a version tag like v1.0.0
7+
8+
jobs:
9+
release:
10+
name: Build and Create Release
11+
runs-on: macos-latest
12+
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
# Selects Xcode 26.3 to provide Swift 6.2+ compiler tools
21+
- name: Set Xcode Version to 26.3.0
22+
uses: maxim-lobanov/setup-xcode@v1
23+
with:
24+
xcode-version: "26.3.0"
25+
26+
- name: Resolve Package Dependencies
27+
run: |
28+
xcodebuild -resolvePackageDependencies
29+
30+
- name: Set Default Scheme
31+
run: |
32+
scheme_list=$(xcodebuild -list -json | tr -d "\n")
33+
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]")
34+
echo "SCHEME=$default" >> $GITHUB_ENV
35+
36+
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then
37+
echo "FILETYPE_PARAM=workspace" >> $GITHUB_ENV
38+
echo "FILE_TO_BUILD=$(ls -A | grep -i \.xcworkspace\$ | head -n 1)" >> $GITHUB_ENV
39+
else
40+
echo "FILETYPE_PARAM=project" >> $GITHUB_ENV
41+
echo "FILE_TO_BUILD=$(ls -A | grep -i \.xcodeproj\$ | head -n 1)" >> $GITHUB_ENV
42+
fi
43+
44+
# Builds the app to a custom build directory using ad-hoc local signing
45+
- name: Build App Binary
46+
run: |
47+
xcodebuild clean build \
48+
-scheme "${{ env.SCHEME }}" \
49+
-${{ env.FILETYPE_PARAM }} "${{ env.FILE_TO_BUILD }}" \
50+
-sdk macosx \
51+
-destination "platform=macOS,arch=arm64" \
52+
-derivedDataPath ./build \
53+
CODE_SIGN_IDENTITY="" \
54+
CODE_SIGNING_REQUIRED=NO \
55+
CODE_SIGNING_ALLOWED=NO
56+
57+
# Locates the compiled .app file, moves it to a staging folder, and compresses it
58+
- name: Package App into ZIP
59+
run: |
60+
APP_PATH=$(find ./build/Build/Products/Debug -name "*.app" -type d -maxdepth 2 | head -n 1)
61+
if [ -z "$APP_PATH" ]; then
62+
APP_PATH=$(find ./build/Build/Products/Release -name "*.app" -type d -maxdepth 2 | head -n 1)
63+
fi
64+
65+
echo "Found app bundle at: $APP_PATH"
66+
APP_NAME=$(basename "$APP_PATH")
67+
68+
mkdir dist
69+
cp -R "$APP_PATH" dist/
70+
71+
cd dist
72+
zip -r "../${{ env.SCHEME }}.zip" "$APP_NAME"
73+
cd ..
74+
75+
# Generates a GitHub Release draft and attaches the zipped application
76+
- name: Create GitHub Release
77+
uses: softprops/action-gh-release@v2
78+
with:
79+
files: "${{ env.SCHEME }}.zip"
80+
generate_release_notes: true
81+
draft: false
82+
prerelease: false

.github/workflows/xcode-build.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Xcode - Build and Analyze
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
name: Build and analyse default scheme using xcodebuild command
12+
runs-on: macos-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
# Selects Xcode 26.3 to provide Swift 6.2+ compiler tools
19+
- name: Set Xcode Version to 26.3.0
20+
uses: maxim-lobanov/setup-xcode@v1
21+
with:
22+
xcode-version: '26.3.0'
23+
24+
- name: Resolve Package Dependencies
25+
run: |
26+
xcodebuild -resolvePackageDependencies
27+
28+
- name: Set Default Scheme
29+
run: |
30+
scheme_list=$(xcodebuild -list -json | tr -d "\n")
31+
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]")
32+
echo $default | cat >default
33+
echo Using default scheme: $default
34+
35+
- name: Build
36+
env:
37+
scheme: ${{ 'default' }}
38+
run: |
39+
if [ $scheme = default ]; then scheme=$(cat default); fi
40+
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
41+
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
42+
43+
# Overrode code signing requirements for the CI environment using build settings flags
44+
xcodebuild clean build analyze \
45+
-scheme "$scheme" \
46+
-"$filetype_parameter" "$file_to_build" \
47+
-sdk macosx \
48+
-destination "platform=macOS,arch=arm64" \
49+
CODE_SIGN_IDENTITY="" \
50+
CODE_SIGNING_REQUIRED=NO \
51+
CODE_SIGNING_ALLOWED=NO \
52+
| xcpretty && exit ${PIPESTATUS[0]}

0 commit comments

Comments
 (0)