-
Notifications
You must be signed in to change notification settings - Fork 4
173 lines (159 loc) · 7.74 KB
/
notifications.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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 }}
macos-build-path:
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 (relative).
value: ${{ jobs.windows-notifications.outputs.build-path }}
windows-posix-build-path:
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.
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 }}
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_NAME="$(echo "$PROJECT_NAME" | tr " " _)-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_NAME=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
- 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 "$GITHUB_WORKSPACE/$NOTIFICATION_PROJECT_PATH/$PROJECT_NAME/$PROJECT_NAME.xcodeproj" \
-scheme "$PROJECT_NAME" \
-sdk macosx \
-destination "generic/platform=macOS" \
-archivePath "$GITHUB_WORKSPACE/$BUILD_PATH/$PROJECT_NAME.xcarchive" \
clean archive
- name: Export Xcode Archive
run: |
xcodebuild -exportArchive \
-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 "$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 "$GITHUB_WORKSPACE/$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 "$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 "$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: "${{ 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
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: Checkout
uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- 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\$ARTIFACT_NAME.zip" >> "$env:GITHUB_ENV"
$POSIX_BUILD_PATH=python -c "import pathlib; print( pathlib.Path(r'$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: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:GITHUB_WORKSPACE\$env:BUILD_PATH\"
- name: Zip App
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: "${{ github.workspace }}\\${{ env.ZIP_PATH }}"