Created
January 1, 2025 21:59
-
-
Save hu553in/4e1bf7167e0364409a41f203d6402a38 to your computer and use it in GitHub Desktop.
GitHub Actions to build iOS app
This file contains hidden or 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
variables: | |
APP_NAME: AlarmClock | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v*.*.* | |
jobs: | |
main: | |
runs-on: macos-latest | |
steps: | |
- name: Check Xcode version | |
run: /usr/bin/xcodebuild -version | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build project | |
working-directory: ${{ github.workspace }} | |
run: | | |
xcodebuild \ | |
-project ./$APP_NAME.xcodeproj \ | |
-scheme $APP_NAME \ | |
-sdk iphoneos \ | |
-configuration Release \ | |
CODE_SIGN_IDENTITY="" \ | |
CODE_SIGNING_REQUIRED=NO | |
- name: Install Homebrew | |
run: | | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
- name: Install SwiftLint | |
run: brew install swiftlint | |
- name: Run SwiftLint | |
working-directory: ${{ github.workspace }} | |
run: swiftlint --strict | |
- name: Construct IPA | |
run: | | |
cd ~/Library/Developer/Xcode/DerivedData/$APP_NAME-*/Build/Products/Release-iphoneos | |
mkdir ./Payload | |
mv ./$APP_NAME.app ./Payload/ | |
ditto -c -k --sequesterRsrc --keepParent ./Payload $APP_NAME.zip | |
mv ./$APP_NAME.zip ${{ github.workspace }}/$APP_NAME.ipa | |
- name: Wait for IPA construction | |
run: sleep 5 | |
- name: Set variables to output | |
id: variables | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Upload IPA as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: $APP_NAME-${{ steps.variables.outputs.sha_short }}.ipa | |
path: ${{ github.workspace }}/$APP_NAME.ipa | |
retention-days: 3 | |
if-no-files-found: error | |
- name: Rename IPA | |
if: github.ref_type == 'tag' | |
working-directory: ${{ github.workspace }} | |
run: | | |
mv ./$APP_NAME.ipa ./$APP_NAME-${{ github.ref_name }}.ipa | |
- name: Release IPA | |
uses: softprops/action-gh-release@v2 | |
if: github.ref_type == 'tag' | |
with: | |
files: ${{ github.workspace }}/$APP_NAME-${{ github.ref_name }}.ipa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment