Skip to content

Commit

Permalink
Change handling of abs paths in notifications.yml
Browse files Browse the repository at this point in the history
Still having issues, so I am trying a different approach. Make all the
generated paths be relative, but when using them, manually add the
github workspace path to the start to make it an absolute path.
  • Loading branch information
dunkmann00 committed Apr 12, 2024
1 parent b7add49 commit ba821e1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/notifications-artifacts
pattern: ${{ needs.notifications-build.outputs.artifact-project-name }}*
pattern: |
${{ needs.notifications-build.outputs.macos-artifact-name }}
${{ needs.notifications-build.outputs.windows-artifact-name }}
merge-multiple: true
- name: Unzip & move notifications apps
env:
Expand All @@ -50,12 +52,12 @@ jobs:
WINDOWS_BUILD_PATH: ${{ needs.notifications-build.outputs.windows-posix-build-path }}
run: |
# macOS Notifications App
mkdir "$MACOS_BUILD_PATH"
unzip "$ARTIFACTS_PATH/$MACOS_ARTIFACT_NAME.zip" -d "$MACOS_BUILD_PATH"
mkdir "$GITHUB_WORKSPACE/$MACOS_BUILD_PATH"
unzip "$ARTIFACTS_PATH/$MACOS_ARTIFACT_NAME.zip" -d "$GITHUB_WORKSPACE/$MACOS_BUILD_PATH"
# Windows Notifications App
mkdir "$WINDOWS_BUILD_PATH"
unzip "$ARTIFACTS_PATH/$WINDOWS_ARTIFACT_NAME.zip" -d "$WINDOWS_BUILD_PATH"
mkdir "$GITHUB_WORKSPACE/$WINDOWS_BUILD_PATH"
unzip "$ARTIFACTS_PATH/$WINDOWS_ARTIFACT_NAME.zip" -d "$GITHUB_WORKSPACE/$WINDOWS_BUILD_PATH"
- name: Build package sdist & wheel
run: poetry build
- name: Upload package sdist & wheel
Expand All @@ -78,11 +80,11 @@ jobs:
- os: macos-14
notifications:
artifact-name: ${{ needs.notifications-build.outputs.macos-artifact-name }}
build-path: ${{ needs.notifications-build.outputs.macos-build-path }}
build-path: ${{ github.workspace }}/${{ needs.notifications-build.outputs.macos-build-path }}
- os: windows-2022
notifications:
artifact-name: ${{ needs.notifications-build.outputs.windows-artifact-name }}
build-path: ${{ needs.notifications-build.outputs.windows-build-path }}
build-path: ${{ github.workspace }}\${{ needs.notifications-build.outputs.windows-build-path }}
- os: ubuntu-22.04
steps:
- name: Checkout
Expand Down Expand Up @@ -115,7 +117,13 @@ jobs:
NOTFICATION_BUILD: ${{ matrix.notifications.build-path }}
run: |
mkdir "$NOTFICATION_BUILD"
python -c "import shutil; shutil.unpack_archive('$NOTFICATION_BUILD/$NOTIFICATION_NAME.zip', '$NOTFICATION_BUILD')"
python -c "
from pathlib import Path
import shutil
zip_path = Path('$NOTFICATION_BUILD') / '$NOTIFICATION_NAME.zip'
shutil.unpack_archive(zip_path, '$NOTFICATION_BUILD')
"
- name: Build app binary
env:
MACOS_CODESIGN_IDENTITY: ${{ secrets.PROD_MACOS_CERTIFICATE_IDENTITY }}
Expand Down
57 changes: 26 additions & 31 deletions .github/workflows/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ on:
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.
description: Path to the macOS notification app build directory (relative).
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.
description: Path to the Windows notification app build directory (relative).
value: ${{ jobs.windows-notifications.outputs.build-path }}
windows-posix-build-path:
description: Posix path to the Windows notification app build directory.
description: Posix path to the Windows notification app build directory (relative).
value: ${{ jobs.windows-notifications.outputs.posix-build-path }}
windows-artifact-name:
description: The name of the artifact for the Windows build.
Expand All @@ -45,21 +42,21 @@ jobs:
run:
shell: bash
env:
NOTIFICATION_PROJECT_PATH: ./src/drive_backup/core/notifications/mac
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: Checkout
uses: actions/checkout@v4
- 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"
ARTIFACT_NAME="$(echo "$PROJECT_NAME" | tr " " _)-macos"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> "$GITHUB_ENV"
BUILD_PATH="$NOTIFICATION_PROJECT_PATH/build"
Expand All @@ -69,10 +66,7 @@ jobs:
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:
Expand All @@ -84,34 +78,34 @@ jobs:
# 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" \
-project "$GITHUB_WORKSPACE/$NOTIFICATION_PROJECT_PATH/$PROJECT_NAME/$PROJECT_NAME.xcodeproj" \
-scheme "$PROJECT_NAME" \
-sdk macosx \
-destination "generic/platform=macOS" \
-archivePath "$BUILD_PATH/$PROJECT_NAME.xcarchive" \
-archivePath "$GITHUB_WORKSPACE/$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
-archivePath "$GITHUB_WORKSPACE/$BUILD_PATH/$PROJECT_NAME.xcarchive" \
-exportOptionsPlist "$GITHUB_WORKSPACE/$NOTIFICATION_PROJECT_PATH/ExportOptions.plist" \
-exportPath "$GITHUB_WORKSPACE/$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"
ditto -c -k --keepParent "$GITHUB_WORKSPACE/$APP_PATH" "$GITHUB_WORKSPACE/$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" \
xcrun notarytool submit "$GITHUB_WORKSPACE/$ZIP_PATH" \
--apple-id "$MACOS_NOTARIZATION_APPLE_ID" \
--team-id "$MACOS_NOTARIZATION_TEAM_ID" \
--password "$MACOS_NOTARIZATION_PWD" \
Expand All @@ -120,31 +114,32 @@ jobs:
# 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"
xcrun stapler staple "$GITHUB_WORKSPACE/$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"
rm "$GITHUB_WORKSPACE/$ZIP_PATH"
ditto -c -k --keepParent "$GITHUB_WORKSPACE/$APP_PATH" "$GITHUB_WORKSPACE/$ZIP_PATH"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: "${{ env.ZIP_PATH }}"
path: "${{ env.GITHUB_WORKSPACE }}/${{ env.ZIP_PATH }}"

windows-notifications:
name: Build Windows Notification App
runs-on: windows-2022
env:
NOTIFICATION_PROJECT_PATH: .\src\drive_backup\core\notifications\windows
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 MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup Env Variables
id: setup-variables
run: |
Expand All @@ -163,16 +158,16 @@ jobs:
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" `
msbuild "$env:GITHUB_WORKSPACE\$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\"
-property:OutDir="$env:GITHUB_WORKSPACE\$env:BUILD_PATH\"
- name: Zip App
run: Compress-Archive -Path "$env:EXE_PATH" -DestinationPath "$env:ZIP_PATH"
run: Compress-Archive -Path "$env:GITHUB_WORKSPACE\$env:EXE_PATH" -DestinationPath "$env:GITHUB_WORKSPACE\$env:ZIP_PATH"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: "${{ env.ZIP_PATH }}"
path: "${{ env.GITHUB_WORKSPACE }}\\${{ env.ZIP_PATH }}"

0 comments on commit ba821e1

Please sign in to comment.