Skip to content

Updated build-ios

Updated build-ios #36

Workflow file for this run

name: Kotlin Multiplatform CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# Workflow block for building Android
build-android:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Android
run: ./gradlew assembleRelease --info
- name: Run Unit Tests
run: ./gradlew test
- name: Build iOS shared code
run: ./gradlew :composeApp:compileKotlinIosSimulatorArm64
- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: android-release-apk
path: composeApp/build/outputs/apk/release/*.apk
# Workflow block for building iOS
build-ios:
runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Install Xcode Command Line Tools
run: |
if ! xcode-select --print-path > /dev/null 2>&1; then
echo "Xcode Command Line Tools are not installed. Installing..."
xcode-select --install || echo "Failed to install Xcode Command Line Tools"
else
echo "Xcode Command Line Tools are already installed"
fi
- name: Build iOS
run: |
xcodebuild -allowProvisioningUpdates -workspace iosApp/iosApp.xcodeproj/project.xcworkspace -scheme iosApp -configuration Release -sdk iphoneos -destination 'generic/platform=iOS' build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" DEVELOPMENT_TEAM=""
- name: Archive iOS app
run: |
# Assuming the build product is in the Release-iphoneos directory
cp -R ~/Library/Developer/Xcode/DerivedData/iosApp-*/Build/Products/Release-iphoneos/iosApp.app .
- name: Upload iOS app
uses: actions/upload-artifact@v4
with:
name: ios-app
path: iosApp.app
# Workflow block for building Desktop
build-desktop:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Desktop
run: ./gradlew desktopJar
- name: Upload Desktop artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-jar
path: composeApp/build/libs/*.jar
# Workflow block for building macOS
build-macos:
runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: brew install create-dmg
- name: Build macOS app
run: |
xcodebuild -allowProvisioningUpdates -workspace iosApp/iosApp.xcodeproj/project.xcworkspace -scheme iosApp -configuration Release -sdk iphoneos -destination name='iPhone 14' build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" DEVELOPMENT_TEAM=""
- name: Create DMG
run: |
create-dmg 'path/to/your/app.app' 'path/to/output/directory'
# Adjust paths as needed
- name: Upload DMG
uses: actions/upload-artifact@v3
with:
name: macos-dmg
path: path/to/output/directory/*.dmg
# Workflow block for building Web
build-web:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Web
run: ./gradlew wasmJsBrowserWebpack
- name: Upload Web artifacts
uses: actions/upload-artifact@v4
with:
name: web-app
path: webApp/build/distributions/*.tar.gz
# Workflow block for generating artifact links
generate-artifact-links:
runs-on: ubuntu-latest
needs: [ build-android, build-ios, build-desktop,build-macos, build-web ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Artifact URLs
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
# Get the run ID
RUN_ID=$(echo "${{ github.run_id }}")
REPO=${{ github.repository }}
# Fetch the list of artifacts
ARTIFACTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/artifacts")
# Extract URLs for each artifact
echo "Artifact URLs for download:"
for url in $(echo "$ARTIFACTS" | jq -r '.artifacts[] | "\(.name) - \(.archive_download_url)"'); do
echo "$url"
done