Skip to content

Instantly share code, notes, and snippets.

@praeclarum
Last active January 29, 2022 15:35
Show Gist options
  • Save praeclarum/fee7b470fc7b1365ac6c07155b0c06f9 to your computer and use it in GitHub Desktop.
Save praeclarum/fee7b470fc7b1365ac6c07155b0c06f9 to your computer and use it in GitHub Desktop.
GitHub jobs to build and deploy .NET 6 apps multi-targeting iOS and macOS
name: Build and Test
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '13 13 * * *'
jobs:
check_deploy:
runs-on: ubuntu-latest
name: Check if Nightly Deployment
outputs:
should_deploy: ${{ github.event_name == 'schedule' && github.ref == 'refs/heads/main' && fromJSON(steps.get_num_commits.outputs.num_commits) > 0 }}
steps:
- uses: actions/checkout@v2
with:
ref: main
- id: get_num_commits
name: Get the number of commits in the last 24h
run: echo "::set-output name=num_commits::$(git rev-list --max-count=1 --after='24 hours' HEAD | wc -l)"
- name: Show num commits
run: echo ${{ fromJSON(steps.get_num_commits.outputs.num_commits) }}
test:
name: Build and Test
if: github.event_name != 'schedule'
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Update Version
run: bash version.sh ${{github.run_number}}
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Install iOS and Mac Catalyst Support
run: dotnet workload install ios maccatalyst
- name: Restore Dependencies
run: dotnet restore
- name: Build FbxSharp
run: cd FbxSharp && make CONFIG=Release
- name: Test FbxSharp
run: cd FbxSharp && make CONFIG=Release test
- name: Build Tests
run: dotnet build -c Release Tests/Tests.fsproj
- name: Test
run: Tests/bin/Release/net6.0-maccatalyst/maccatalyst-x64/Tests.app/Contents/MacOS/Tests
deployios:
name: iOS Build and Deploy
needs: check_deploy
if: ${{ needs.check_deploy.outputs.should_deploy != 'false' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Update Version
run: bash version.sh ${{github.run_number}}
- name: Import Certificate
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
- name: Download Provisioning Profile
id: provisioning
uses: apple-actions/download-provisioning-profiles@v1
with:
bundle-id: 'com.kruegersystems.meshcaster'
profile-type: 'IOS_APP_STORE'
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_PRIVATE_KEY }}
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Install iOS and Mac Catalyst Support
run: dotnet workload install ios maccatalyst
- name: Restore Dependencies
run: dotnet restore
- name: Build FbxSharp
run: cd FbxSharp && make CONFIG=Release
- name: Build iOS
run: |
sed -E -i .bak "s:<TargetFrameworks>[^<]+</TargetFrameworks>:<TargetFrameworks>net6.0-ios</TargetFrameworks>:g" MeshCaster/MeshCaster.fsproj
dotnet build -c Release -f net6.0-ios "/p:BuildIpa=true" "/p:CodesignKey=Apple Distribution" "/p:CodesignProvision=Mesh Caster iOS Distribution" MeshCaster/MeshCaster.fsproj
- name: Upload to TestFlight
uses: apple-actions/upload-testflight-build@v1
with:
app-type: ios
app-path: 'MeshCaster/bin/Release/net6.0-ios/ios-arm64/MeshCaster.ipa'
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_PRIVATE_KEY }}
deploymac:
name: macOS Build and Deploy
needs: check_deploy
if: ${{ needs.check_deploy.outputs.should_deploy != 'false' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Update Version
run: bash version.sh ${{github.run_number}}
- name: Import Certificate
uses: apple-actions/import-codesign-certs@v1
with:
create-keychain: true
keychain-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
- name: Import Installer Certificate
uses: apple-actions/import-codesign-certs@v1
with:
create-keychain: false
keychain-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
p12-file-base64: ${{ secrets.INSTALLER_CERTIFICATE_P12 }}
p12-password: ${{ secrets.INSTALLER_CERTIFICATE_P12_PASSWORD }}
- name: Download Provisioning Profile
id: provisioning
uses: apple-actions/download-provisioning-profiles@v1
with:
bundle-id: 'com.kruegersystems.meshcaster'
profile-type: 'MAC_APP_STORE'
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_PRIVATE_KEY }}
- name: Fix Provisioning Profile Extension
shell: bash
run: |
for f in $HOME/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision; do
mv -- "$f" "${f%.mobileprovision}.provisionprofile"
done
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Install iOS and Mac Catalyst Support
run: dotnet workload install ios maccatalyst
- name: Restore Dependencies
run: dotnet restore
- name: Build FbxSharp
run: cd FbxSharp && make CONFIG=Release
- name: Remove iPhone from Info.plist
run: /usr/libexec/PlistBuddy -x -c "Delete :UIDeviceFamily:0" MeshCaster/Info.plist
- name: Build Mac Catalyst
run: |
sed -E -i .bak "s:<TargetFrameworks>[^<]+</TargetFrameworks>:<TargetFrameworks>net6.0-maccatalyst</TargetFrameworks>:g" MeshCaster/MeshCaster.fsproj
dotnet build -c Release -f net6.0-maccatalyst "/p:CreatePackage=true" "/p:EnablePackageSigning=true" "/p:EnableCodeSigning=true" "/p:CodeSignEntitlements=Entitlements.plist" "/p:CodesignKey=Apple Distribution" "/p:CodesignProvision=Mesh Caster Mac Distribution" MeshCaster/MeshCaster.fsproj
- name: Upload to TestFlight
uses: apple-actions/upload-testflight-build@v1
with:
app-type: macos
app-path: 'MeshCaster/bin/Release/net6.0-maccatalyst/maccatalyst-x64/MeshCaster-1.0.pkg'
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_PRIVATE_KEY }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment