Skip to content

Commit 051d636

Browse files
committed
release.yml: add signing for MacOS artifacts
Add a step to set up the signing keychain for signing the MacOS package contents with the Apple Developer certificates, and enable signing/notarization in the 'make package' build that generates the artifacts. In order to make the signing process more secure, the MacOS packaging jobs are performed in a 'release' environment. Note that it is possible to run the workflow with no signing/notarization, signing-only (no notarization), or both signing & notarization; the behavior depends on which workflow secrets are set. This ensures that artifacts can be successfully built in a variety of environments, making it easier for forks to test the release build should they want to. Signed-off-by: Victoria Dye <[email protected]>
1 parent d627d34 commit 051d636

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

.github/workflows/release.yml

+78-1
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ jobs:
3131
goarch: amd64
3232
pool: macos-latest
3333
artifact: _dist/*.pkg
34+
environment: release
3435
- jobname: Create MacOS .pkg (ARM64)
3536
goarch: arm64
3637
pool: macos-latest
3738
artifact: _dist/*.pkg
39+
environment: release
3840
- jobname: Create binary Debian package (x86_64)
3941
goarch: amd64
4042
pool: ubuntu-latest
4143
artifact: _dist/*.deb
4244
env:
4345
GOARCH: ${{matrix.jobs.goarch}}
46+
environment: ${{matrix.jobs.environment}}
4447
runs-on: ${{matrix.jobs.pool}}
4548
steps:
4649
- name: Setup Go
@@ -53,8 +56,82 @@ jobs:
5356
- run: gem install asciidoctor
5457
- name: Clone repository
5558
uses: actions/checkout@v3
59+
- name: Configure MacOS signing
60+
if: ${{ matrix.jobs.pool == 'macos-latest' }}
61+
env:
62+
A1: ${{ secrets.APPLICATION_CERTIFICATE_BASE64 }}
63+
A2: ${{ secrets.APPLICATION_CERTIFICATE_PASSWORD }}
64+
A3: ${{ secrets.APPLE_APPLICATION_SIGNING_IDENTITY }}
65+
I1: ${{ secrets.INSTALLER_CERTIFICATE_BASE64 }}
66+
I2: ${{ secrets.INSTALLER_CERTIFICATE_PASSWORD }}
67+
I3: ${{ secrets.APPLE_INSTALLER_SIGNING_IDENTITY }}
68+
N1: ${{ secrets.APPLE_TEAM_ID }}
69+
N2: ${{ secrets.APPLE_DEVELOPER_ID }}
70+
N3: ${{ secrets.APPLE_DEVELOPER_PASSWORD }}
71+
N4: ${{ secrets.APPLE_KEYCHAIN_PROFILE }}
72+
run: |
73+
# Environment configured for signing?
74+
if [[ -n "$A1" && -n "$A2" && -n "$A3" && -n "$I1" && -n "$I2" && -n "$I3" ]]
75+
then
76+
echo "DO_SIGN=1" >> $GITHUB_ENV
77+
else
78+
echo "::warning::MacOS signing environment is not fully specified. Skipping configuration."
79+
exit 0
80+
fi
81+
82+
# Signing
83+
echo "Setting up signing certificates"
84+
security create-keychain -p pwd $RUNNER_TEMP/buildagent.keychain
85+
security default-keychain -s $RUNNER_TEMP/buildagent.keychain
86+
security unlock-keychain -p pwd $RUNNER_TEMP/buildagent.keychain
87+
88+
echo $A1 | base64 -D > $RUNNER_TEMP/cert.p12
89+
security import $RUNNER_TEMP/cert.p12 \
90+
-k $RUNNER_TEMP/buildagent.keychain \
91+
-P $A2 \
92+
-T /usr/bin/codesign
93+
security set-key-partition-list \
94+
-S apple-tool:,apple:,codesign: \
95+
-s -k pwd \
96+
$RUNNER_TEMP/buildagent.keychain
97+
98+
echo $I1 | base64 -D > $RUNNER_TEMP/cert.p12
99+
security import $RUNNER_TEMP/cert.p12 \
100+
-k $RUNNER_TEMP/buildagent.keychain \
101+
-P $I2 \
102+
-T /usr/bin/productbuild
103+
security set-key-partition-list \
104+
-S apple-tool:,apple:,productbuild: \
105+
-s -k pwd \
106+
$RUNNER_TEMP/buildagent.keychain
107+
108+
# Environment configured for notarization?
109+
if [[ -n "$N1" && -n "$N2" && -n "$N3" && -n "$N4" ]]
110+
then
111+
echo "DO_NOTARIZE=1" >> $GITHUB_ENV
112+
else
113+
echo "::warning::Successfully configured MacOS signing, but cannot set up notarization. Skipping configuration."
114+
exit 0
115+
fi
116+
117+
# Notarizing
118+
echo "Setting up notarytool"
119+
xcrun notarytool store-credentials \
120+
--team-id $N1 \
121+
--apple-id $N2 \
122+
--password $N3 \
123+
"$N4"
56124
- name: Build the release artifact
57-
run: make package VERSION=${{ needs.prereqs.outputs.tag_version }}
125+
env:
126+
A3: ${{ secrets.APPLE_APPLICATION_SIGNING_IDENTITY }}
127+
I3: ${{ secrets.APPLE_INSTALLER_SIGNING_IDENTITY }}
128+
N4: ${{ secrets.APPLE_KEYCHAIN_PROFILE }}
129+
shell: bash
130+
run: |
131+
make package VERSION=${{ needs.prereqs.outputs.tag_version }} \
132+
APPLE_APP_IDENTITY="$([[ -n "$DO_SIGN" ]] && echo "$A3" || echo '')" \
133+
APPLE_INST_IDENTITY="$([[ -n "$DO_SIGN" ]] && echo "$I3" || echo '')" \
134+
APPLE_KEYCHAIN_PROFILE="$([[ -n "$DO_NOTARIZE" ]] && echo "$N4" || echo '')"
58135
- name: Get the release artifact
59136
shell: bash
60137
run: |

0 commit comments

Comments
 (0)