Skip to content

GitHub. Upload artifact #10

GitHub. Upload artifact

GitHub. Upload artifact #10

Workflow file for this run

name: Xcode - Build and Test
on: [push]
jobs:
build:
name: Build and test
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode version
run: |
ls /Applications
sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
xcode-select -p
- name: Install the Apple certificate
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_P12 }}
P12_PASSWORD: ${{ secrets.PASSWORD_P12 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 -d -o $CERTIFICATE_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
- name: Build and analyze
run:
xcodebuild build analyze
-scheme ${{ github.event.repository.name }}
-destination platform=macOS
-showBuildTimingSummary |
xcpretty && exit ${PIPESTATUS[0]}
- name: Archive
run:
xcodebuild archive
-project "${{ github.event.repository.name }}.xcodeproj"
-scheme ${{ github.event.repository.name }}
-archivePath "dist/${{ github.event.repository.name }}.xcarchive"
- name: Export options
run: |
echo '
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>mac-application</string>
</dict>
</plist>
' > ExportOptions.plist
- name: Export
run:
xcodebuild -exportArchive
-archivePath "dist/${{ github.event.repository.name }}.xcarchive"
-exportOptionsPlist ExportOptions.plist
-exportPath dist/
-allowProvisioningUpdates
- name: Create Disk Image
run: |
brew install create-dmg
rm -r "dist/${{ github.event.repository.name }}.xcarchive"
ln -s /Applications dist/
create-dmg "${{ github.event.repository.name }}.dmg" dist
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: "${{ github.event.repository.name }}.dmg"
path: "${{ github.event.repository.name }}.dmg"
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true