Skip to content

Fix notification buidl path outputs #41

Fix notification buidl path outputs

Fix notification buidl path outputs #41

Workflow file for this run

name: Notifications Build
on:
push:
paths:
- 'src/drive_backup/core/notifications/*/Drive Backup Notifications/**'
- '.github/workflows/notifications.yml'
# Allows this workflow to be called from another workflow
workflow_call:
outputs:
project-name:
description: Name of the notification apps (they both use the same name).
value: ${{ jobs.mac-notifications.outputs.project-name }}
artifact-project-name:
description: Artifact name of the notification apps without the platform.
value: ${{ jobs.mac-notifications.outputs.artifact-project-name }}
macos-build-path:
description: Path to the macOS notification app build directory.
value: ${{ jobs.mac-notifications.outputs.build-path }}
macos-artifact-name:
description: The name of the artifact for the macOS build.
value: ${{ jobs.mac-notifications.outputs.artifact-name }}
windows-build-path:
description: Path to the Windows notification app build directory.
value: ${{ jobs.windows-notifications.outputs.build-path }}
windows-posix-build-path:
description: Posix path to the Windows notification app build directory.
value: ${{ jobs.windows-notifications.outputs.posix-build-path }}
windows-artifact-name:
description: The name of the artifact for the Windows build.
value: ${{ jobs.windows-notifications.outputs.artifact-name }}
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
PROJECT_NAME: Drive Backup Notifications
jobs:
mac-notifications:
name: Build macOS Notification App
runs-on: macos-14
defaults:
run:
shell: bash
env:
NOTIFICATION_PROJECT_PATH: ./src/drive_backup/core/notifications/mac
outputs:
project-name: ${{ steps.setup-variables.outputs.PROJECT_NAME }}
artifact-project-name: ${{ steps.setup-variables.outputs.ARTIFACT_PROJECT_NAME }}
build-path: ${{ steps.setup-variables.outputs.BUILD_PATH }}
artifact-name: ${{ steps.setup-variables.outputs.ARTIFACT_NAME }}
steps:
- name: Setup Xcode
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: Setup Env Variables
id: setup-variables
run: |
ARTIFACT_PROJECT_NAME="$(echo "$PROJECT_NAME" | tr " " _)"
ARTIFACT_NAME="$ARTIFACT_PROJECT_NAME-macos"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$GITHUB_ENV"
BUILD_PATH="$NOTIFICATION_PROJECT_PATH/build"
echo "BUILD_PATH=$BUILD_PATH" >> "$GITHUB_ENV"
echo "APP_PATH=$BUILD_PATH/$PROJECT_NAME.app" >> "$GITHUB_ENV"
echo "ZIP_PATH=$BUILD_PATH/$ARTIFACT_NAME.zip" >> "$GITHUB_ENV"
echo "PROJECT_NAME=$PROJECT_NAME" >> "$GITHUB_OUTPUT"
echo "BUILD_PATH=$BUILD_PATH" >> "$GITHUB_OUTPUT"
echo "ARTIFACT_PROJECT_NAME=$ARTIFACT_PROJECT_NAME" >> "$GITHUB_OUTPUT"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Setup keychain
uses: ./.github/actions/setup-keychain
with:
macos-certificate: ${{ secrets.PROD_MACOS_CERTIFICATE }}
macos-certificate-pwd: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
macos-ci-keychain-pwd: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
- name: Build Xcode Archive
# This was helpful for this step:
# https://www.andrewhoog.com/post/how-to-build-an-ios-app-with-github-actions-2023/
run: |
xcodebuild -disableAutomaticPackageResolution \
-project "$NOTIFICATION_PROJECT_PATH/$PROJECT_NAME/$PROJECT_NAME.xcodeproj" \
-scheme "$PROJECT_NAME" \
-sdk macosx \
-destination "generic/platform=macOS" \
-archivePath "$BUILD_PATH/$PROJECT_NAME.xcarchive" \
clean archive
- name: Export Xcode Archive
run: |
xcodebuild -exportArchive \
-archivePath "$BUILD_PATH/$PROJECT_NAME.xcarchive" \
-exportOptionsPlist "$NOTIFICATION_PROJECT_PATH/ExportOptions.plist" \
-exportPath $BUILD_PATH
- name: Notarize App
env:
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
run: |
echo "Create Zip Archive"
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
# Here we send the notarization request to Apple's Notarization service, waiting for the result.
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
# characteristics. We pass in all the credentials, including the password so that we can prevent a
# UI password dialog from blocking the CI
echo "Notarize app"
xcrun notarytool submit "$ZIP_PATH" \
--apple-id "$MACOS_NOTARIZATION_APPLE_ID" \
--team-id "$MACOS_NOTARIZATION_TEAM_ID" \
--password "$MACOS_NOTARIZATION_PWD" \
--wait
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
# validated by macOS even when an internet connection is not available.
echo "Attach staple"
xcrun stapler staple "$APP_PATH"
- name: Zip App Bundle
run: |
# We need to Zip the app again to upload the stapled version as an artifact.
rm "$ZIP_PATH"
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: "${{ env.ZIP_PATH }}"
windows-notifications:
name: Build Windows Notification App
runs-on: windows-2022
env:
NOTIFICATION_PROJECT_PATH: .\src\drive_backup\core\notifications\windows
outputs:
build-path: ${{ steps.setup-variables.outputs.BUILD_PATH }}
posix-build-path: ${{ steps.setup-variables.outputs.POSIX_BUILD_PATH }}
artifact-name: ${{ steps.setup-variables.outputs.ARTIFACT_NAME }}
steps:
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Checkout
uses: actions/checkout@v4
- name: Setup Env Variables
id: setup-variables
run: |
$ARTIFACT_NAME=$env:PROJECT_NAME.Replace(" ","_") + "-windows"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$env:GITHUB_ENV"
$BUILD_PATH="$env:NOTIFICATION_PROJECT_PATH\build"
echo "BUILD_PATH=$BUILD_PATH" >> "$env:GITHUB_ENV"
echo "EXE_PATH=$BUILD_PATH\$env:PROJECT_NAME.exe" >> "$env:GITHUB_ENV"
echo "ZIP_PATH=$BUILD_PATH\$env:ARTIFACT_NAME.zip" >> "$env:GITHUB_ENV"
$POSIX_BUILD_PATH=python -c "import pathlib; print( pathlib.Path('$BUILD_PATH').as_posix() )"
echo "BUILD_PATH=$BUILD_PATH" >> "$env:GITHUB_OUTPUT"
echo "POSIX_BUILD_PATH=$POSIX_BUILD_PATH" >> "$env:GITHUB_OUTPUT"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$env:GITHUB_OUTPUT"
- name: Build VS Project
run: |
msbuild "$env:NOTIFICATION_PROJECT_PATH\$env:PROJECT_NAME\$env:PROJECT_NAME.vcxproj" `
-t:rebuild `
-verbosity:diag `
-property:Configuration=Release `
-property:Platform=x64 `
-property:OutDir="$env:BUILD_PATH\"
- name: Zip App
run: Compress-Archive -Path "$env:EXE_PATH" -DestinationPath "$env:ZIP_PATH"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: "${{ env.ZIP_PATH }}"