Skip to content

iOS

iOS #413

Workflow file for this run

name: iOS
on:
# workflow_run:
# workflows: ["CreateRelease"]
# types:
# - completed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
vt_ver:
description: "VESC Tool Version"
required: true
default: "master"
type: string
fw_ver:
description: "Firmware Version"
required: true
default: "master"
type: string
prerelease:
description: "Release as Prerelease"
required: true
default: true
type: boolean
jobs:
notify:
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
strategy:
matrix:
os: [macos-latest]
qt_ver: [5.15.2]
qt_target: [ios]
steps:
- name: Version2Ref
run: |
if [[ "${{ inputs.vt_ver }}" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
echo "VT_REF=release_${BASH_REMATCH[1]}_${BASH_REMATCH[2]}" >> $GITHUB_ENV
elif [[ "${{ inputs.vt_ver }}" == "master" ]]; then
echo "VT_REF=master" >> $GITHUB_ENV
else
echo "VT_REF=${{ inputs.vt_ver }}" >> $GITHUB_ENV
fi
shell: bash
- uses: actions/checkout@v4
with:
ref: ${{ env.VT_REF }}
- name: Setup
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
id: GetVersion
run: |
VT_VERSION=$(grep -m1 VT_VERSION vesc_tool.pro | awk -F= '{ print $2 }' | sed 's/[ ",]//g')
echo "VERSION=${VT_VERSION}" >> $GITHUB_OUTPUT
echo "PACKAGE_VERSION=${VT_VERSION}" >> $GITHUB_ENV
if [ "${{ inputs.prerelease }}" = "true" ]; then
echo "RELEASE_NOTES=**VESC Tool Nightly Build ${VT_VERSION}**" >> $GITHUB_OUTPUT
else
echo "RELEASE_NOTES=**VESC Tool Release Build ${VT_VERSION}**" >> $GITHUB_OUTPUT
fi
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: check Xcode version
run: /usr/bin/xcodebuild -version
- name: Install Qt
# if: steps.cacheqt.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.qt_ver }}
host: mac
target: ${{ matrix.qt_target }}
setup-python: 'true'
cache: 'true'
cache-key-prefix: 'install-qt-action'
- name: Create TMP Dir
id: mktemp
run: echo "FW_TMP_DIR=$(mktemp -d)" >> $GITHUB_ENV
shell: bash
- name: Download FW Artifact
uses: dawidd6/action-download-artifact@v3
with:
name: firmware-${{ inputs.fw_ver }}
path: ${{ env.FW_TMP_DIR }}
github_token: ${{secrets.GITHUB_TOKEN}}
repo: darwinbeing/bldc
workflow: firmware.yml
workflow_conclusion: success
search_artifacts: true
# - 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 -o $CERTIFICATE_PATH
# echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $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: Apply Patch
run: |
if [[ "${{ inputs.vt_ver }}" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
PATCH_VERSION="${{ inputs.vt_ver }}"
elif [[ "${{ inputs.vt_ver }}" == "master" ]]; then
PATCH_VERSION="master"
else
PATCH_VERSION=${{ env.PACKAGE_VERSION }}
fi
URL=https://raw.githubusercontent.com/darwinbeing/vesc_tool/ci/patches/"${PATCH_VERSION}"/vesc_tool.patch
curl "$URL" -o ${{ env.FW_TMP_DIR }}/vesc_tool.patch
git apply "${{ env.FW_TMP_DIR }}/vesc_tool.patch"
shell: bash
- name: Compile APP
run: |
PROJECT_NAME=vesc_tool
SCHEME_NAME=vesc_tool
EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist
echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode -o $EXPORT_OPTS_PATH
mkdir -p res/firmwares
cp -rv ${{ env.FW_TMP_DIR }}/* res/firmwares/
qmake CONFIG+=WarningsAsErrorsOn CONFIG-=debug_and_release CONFIG+=release CONFIG+=ForAppStore "CONFIG += iphoneos device release_ios build_mobile" -spec macx-ios-clang
make -f vesc_tool.xcodeproj/qt_preprocess.mak
xcodebuild build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
# sed -i .bak 's/com.yourcompany.${PRODUCT_NAME:rfc1034identifier}/com.vedder.vesc/' ${PROJECT_NAME}.xcodeproj/project.pbxproj
# xcodebuild -configuration Release -xcconfig ios/"${PROJECT_NAME}"_appstore.xcconfig -allowProvisioningUpdates
# xcodebuild archive -project ${PROJECT_NAME}.xcodeproj \
# -xcconfig ios/vesc_tool_appstore.xcconfig \
# -scheme ${SCHEME_NAME} \
# -destination generic/platform=iOS \
# -archivePath build/ios/${PROJECT_NAME}.xcarchive \
# -allowProvisioningUpdates
# xcodebuild -exportArchive -archivePath build/ios/${PROJECT_NAME}.xcarchive \
# -exportPath build/ios/${PROJECT_NAME}.ipa \
# -exportOptionsPlist ios/APPStoreExportOptions.plist \
# -allowProvisioningUpdates
# - name: Upload Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: VESC_Tool-iOS.ipa
# path: Release-iphoneos/vesc_tool.app
- name: Zip files
run: |
cd Release-iphoneos
zip -rv VESC_Tool-iOS.zip vesc_tool.app
- name: Upload Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.GetVersion.outputs.VERSION }}
release_name: Release ${{ steps.GetVersion.outputs.VERSION }}
body: ${{ steps.GetVersion.outputs.RELEASE_NOTES }}
file: Release-iphoneos/VESC_Tool-iOS.zip
asset_name: VESC_Tool-iOS.zip
overwrite: true
prerelease: ${{ inputs.prerelease }}
target_commit: ${{ env.VT_REF }}