Skip to content

Commit 894c25c

Browse files
committed
Add azure devops signing example
1 parent a604379 commit 894c25c

File tree

2 files changed

+127
-7
lines changed

2 files changed

+127
-7
lines changed

docs/packaging/signing.mdx

+123-7
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,32 @@ your `--signAppIdentity` or `--signInstallIdentity` arguments. Your certificate
132132
### Automate signing in CI/CD (Github Actions)
133133
It is also posible to store your certificates and notary credentials as Action Secrets and sign your code during CI builds.
134134

135+
<Tabs groupId="ci" queryString>
136+
<TabItem value="github" label="Github Actions">
135137
1. Launch Keychain Access and open the "My Certificates" pane.
136-
0. Select both certificates, right click and select "Export". Save as a p12 file and make note of the password. You can use the same password for both certificates.
138+
139+
0. Select each certificate (one at a time), right click and select "Export". Save as a p12 file and make note of the password. You can use the same password for both certificates.
140+
:::tip
141+
If you can't see the export option, or exporting as a `.p12` is disabled, you may need to change which keychain or tab you are viewing. You should be on the "My Certificates" tab.
142+
See https://stackoverflow.com/questions/15662377/unable-to-export-apple-production-push-ssl-certificate-in-p12-format for more information.
143+
:::
144+
137145
0. Copy the contents of the certificate to clipboard as base64, example:
138146
```sh
139147
base64 -i CERT.p12 | pbcopy
140148
```
149+
141150
0. Create 7 [Github Secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) for your Actions workflows
142151
- `BUILD_CERTIFICATE_BASE64` (b64 of your app cert)
143152
- `INSTALLER_CERTIFICATE_BASE64` (b64 of your installer cert)
144153
- `P12_PASSWORD` (password for the certificates)
145154
- `APPLE_ID` (your apple username)
146-
- `APPLE_PASSWORD` (your app-specific password from earlier)
147-
- `APPLE_TEAM` (your team id from earlier)
155+
- `APPLE_PASSWORD` (your app-specific password from the notary step above)
156+
- `APPLE_TEAM` (your team id from the notary step above)
148157
- `KEYCHAIN_PASSWORD` (can be any random string, will be used to create a new keychain)
149158

150159
0. Add a step to your workflow which installs the certificates and keychain profile. Here is an example:
151-
```yml
160+
```txt
152161
name: App build & sign
153162
on: push
154163
jobs:
@@ -190,15 +199,122 @@ It is also posible to store your certificates and notary credentials as Action S
190199
# create notarytool profile
191200
xcrun notarytool store-credentials --apple-id "$APPLE_ID" --team-id "$APPLE_TEAM" --password "$APPLE_PASSWORD" velopack-profile
192201
193-
- name: Build app
202+
- name: Compile your app
194203
...
195204
196205
- name: Create Velopack Release
197206
run: |
198207
dotnet tool install -g vpk
199-
vpk ... --signAppIdentity "Developer ID Application: Your Name" --signInstallIdentity "Developer ID Installer: Your Name" --notaryProfile "velopack-profile"
208+
vpk pack ... \
209+
--signAppIdentity "Developer ID Application: Your Name" \
210+
--signInstallIdentity "Developer ID Installer: Your Name" \
211+
--notaryProfile "velopack-profile" \
212+
--keychain $RUNNER_TEMP/app-signing.keychain-db
200213
201214
- name: Clean up keychain
202215
if: ${{ always() }}
203216
run: security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
204-
```
217+
```
218+
219+
</TabItem>
220+
221+
<TabItem value="azure" label="Azure DevOps">
222+
:::warning
223+
The documentation here for Azure DevOps is provided by the community and is not verified by the Velopack team.
224+
:::
225+
1. Launch Keychain Access and open the "My Certificates" pane.
226+
227+
0. Select each certificate (one at a time), right click and select "Export". Save as a p12 file and make note of the password. You can use the same password for both certificates.
228+
:::tip
229+
If you can't see the export option, or exporting as a `.p12` is disabled, you may need to change which keychain or tab you are viewing. You should be on the "My Certificates" tab.
230+
See https://stackoverflow.com/questions/15662377/unable-to-export-apple-production-push-ssl-certificate-in-p12-format for more information.
231+
:::
232+
233+
0. Copy the contents of the certificate to clipboard as base64, example:
234+
```sh
235+
base64 -i CERT.p12 | pbcopy
236+
```
237+
238+
0. Create 5 [Azure Pipeline Secret Variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables?view=azure-devops&tabs=yaml%2Cbash) for your Pipelines
239+
- `P12_PASSWORD` (password for the certificates)
240+
- `APPLE_ID` (your apple username)
241+
- `APPLE_PASSWORD` (your app-specific password from the notary step above)
242+
- `APPLE_TEAM` (your team id from the notary step above)
243+
- `KEYCHAIN_PASSWORD` (can be any random string, will be used to create a new keychain)
244+
245+
0. Import your two certificates into Azure Key Vault [and make it available to DevOps](https://learn.microsoft.com/en-us/azure/devops/pipelines/release/azure-key-vault?view=azure-devops&tabs=classic)
246+
- `BUILD-CERTIFICATE-BASE64`
247+
- `INSTALLER-CERTIFICATE-BASE64`
248+
249+
0. Add steps to your pipeline to load the secrets, sign, and teardown:
250+
251+
The YAML to set things up:
252+
```
253+
variables:
254+
- group: Apple signing
255+
steps:
256+
- bash: |
257+
# create variables for file paths
258+
CERT_BUILD_PATH=$AGENT_TEMPDIRECTORY/build_certificate.p12
259+
CERT_INSTALLER_PATH=$AGENT_TEMPDIRECTORY/installer_certificate.p12
260+
KEYCHAIN_PATH=$AGENT_TEMPDIRECTORY/app-signing.keychain-db
261+
262+
# import certificates from secrets
263+
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERT_BUILD_PATH
264+
echo -n "$INSTALLER_CERTIFICATE_BASE64" | base64 --decode -o $CERT_INSTALLER_PATH
265+
266+
# create temporary keychain
267+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
268+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
269+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
270+
271+
# import certificates to keychain
272+
security import $CERT_BUILD_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
273+
security import $CERT_INSTALLER_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
274+
security list-keychain -d user -s $KEYCHAIN_PATH
275+
276+
# create notarytool profile
277+
xcrun notarytool store-credentials --apple-id "$APPLE_ID" --team-id "$APPLE_TEAM" --password "$APPLE_PASSWORD" --keychain $KEYCHAIN_PATH velopack-profile
278+
env:
279+
BUILD_CERTIFICATE_BASE64: $(BUILD-CERTIFICATE-BASE64)
280+
INSTALLER_CERTIFICATE_BASE64: $(INSTALLER-CERTIFICATE-BASE64)
281+
P12_PASSWORD: $(P12-PASSWORD)
282+
APPLE_ID: $(APPLE-ID)
283+
APPLE_PASSWORD: $(APPLE-PASSWORD)
284+
APPLE_TEAM: $(APPLE-TEAM)
285+
KEYCHAIN_PASSWORD: $(KEYCHAIN-PASSWORD)
286+
displayName: 🛠️ Install Apple certs and notary profile
287+
```
288+
289+
Tear it down:
290+
```
291+
- bash: security delete-keychain $AGENT_TEMPDIRECTORY/app-signing.keychain-db
292+
displayName: 🧹 Clean up keychain
293+
condition: always()
294+
Sign on mac (assuming a powershell script):
295+
# Add signing parameters
296+
if ($IsMacOS) {
297+
$vpkCommand += @(
298+
'--signAppIdentity','Developer ID Application: Andrew Arnott',
299+
'--signInstallIdentity','Developer ID Installer: Andrew Arnott',
300+
'--notaryProfile','velopack-profile',
301+
'--keychain','$(Agent.TempDirectory)/app-signing.keychain-db'
302+
)
303+
}
304+
```
305+
306+
Sign on mac (assuming a powershell script):
307+
```
308+
# Add signing parameters
309+
if ($IsMacOS) {
310+
$vpkCommand += @(
311+
'--signAppIdentity','Developer ID Application: Andrew Arnott',
312+
'--signInstallIdentity','Developer ID Installer: Andrew Arnott',
313+
'--notaryProfile','velopack-profile',
314+
'--keychain','$(Agent.TempDirectory)/app-signing.keychain-db'
315+
)
316+
}
317+
```
318+
</TabItem>
319+
320+
</Tabs>

src/theme/MDXComponents.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import MDXComponents from '@theme-original/MDXComponents';
2+
import Tabs from '@theme/Tabs';
3+
import TabItem from '@theme/TabItem';
24
import AppliesTo from '@site/src/components/AppliesTo';
35
import FancyStep from '@site/src/components/FancyStep';
46

57
export default {
68
...MDXComponents,
79
AppliesTo,
810
FancyStep,
11+
Tabs,
12+
TabItem,
913
};

0 commit comments

Comments
 (0)