Skip to content

Instantly share code, notes, and snippets.

@micheltlutz
Last active November 6, 2022 14:15
Show Gist options
  • Save micheltlutz/0059178bf95d4fd15e5888cc78a0fd43 to your computer and use it in GitHub Desktop.
Save micheltlutz/0059178bf95d4fd15e5888cc78a0fd43 to your computer and use it in GitHub Desktop.
Workflow file that generates ipa artifact for project. following this tutorial:
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
name: Build and Archive
on:
pull_request:
branches: [ "release" ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Build
run: |
xcodebuild clean build -workspace MeuProjeto.xcworkspace -scheme "MeuProjeto"
- name: Archive
run: |
xcodebuild -workspace MeuProjeto.xcworkspace -scheme "MeuProjeto" -archivePath $PWD/build/MeuProjeto.xcarchive clean archive | xcpretty -c
- name: Generate ipa
run: |
xcodebuild -exportArchive -exportOptionsPlist ./distribution-files/production-ci.plist -archivePath $PWD'/build/MeuProjeto.xcarchive' -exportPath build | xcpretty -c
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: MeuProjeto.ipa
path: build/MeuProjeto.ipa
retention-days: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment