|
| 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 |
0 commit comments