@@ -48,17 +48,138 @@ jobs:
48
48
if-no-files-found : error
49
49
name : ${{ env.ARTIFACT_NAME }}
50
50
path : ${{ env.DIST_DIR }}
51
+
52
+ notarize-macos :
53
+ name : Notarize ${{ matrix.artifact.name }}
54
+ runs-on : macos-latest
55
+ needs : create-release-artifacts
56
+ outputs :
57
+ checksum-darwin_amd64 : ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
58
+ checksum-darwin_arm64 : ${{ steps.re-package.outputs.checksum-darwin_arm64 }}
59
+
60
+ env :
61
+ GON_CONFIG_PATH : gon.config.hcl
62
+
63
+ strategy :
64
+ matrix :
65
+ artifact :
66
+ - name : darwin_amd64
67
+ path : " macOS_64bit.tar.gz"
68
+ - name : darwin_arm64
69
+ path : " macOS_ARM64.tar.gz"
70
+
71
+ steps :
72
+ - name : Checkout repository
73
+ uses : actions/checkout@v3
74
+
75
+ - name : Download artifacts
76
+ uses : actions/download-artifact@v3
77
+ with :
78
+ name : ${{ env.ARTIFACT_NAME }}
79
+ path : ${{ env.DIST_DIR }}
80
+
81
+ - name : Import Code-Signing Certificates
82
+ env :
83
+ KEYCHAIN : " sign.keychain"
84
+ INSTALLER_CERT_MAC_PATH : " /tmp/ArduinoCerts2020.p12"
85
+ KEYCHAIN_PASSWORD : keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
86
+ run : |
87
+ echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
88
+ security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
89
+ security default-keychain -s "${{ env.KEYCHAIN }}"
90
+ security unlock-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
91
+ security import \
92
+ "${{ env.INSTALLER_CERT_MAC_PATH }}" \
93
+ -k "${{ env.KEYCHAIN }}" \
94
+ -f pkcs12 \
95
+ -A \
96
+ -T "/usr/bin/codesign" \
97
+ -P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
98
+ security set-key-partition-list \
99
+ -S apple-tool:,apple: \
100
+ -s \
101
+ -k "${{ env.KEYCHAIN_PASSWORD }}" \
102
+ "${{ env.KEYCHAIN }}"
103
+
104
+ - name : Install gon for code signing and app notarization
105
+ run : |
106
+ wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
107
+ unzip gon_macos.zip -d /usr/local/bin
108
+
109
+ - name : Write gon config to file
110
+ # gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
111
+ run : |
112
+ cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
113
+ # See: https://github.com/mitchellh/gon#configuration-file
114
+ source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
115
+ bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
116
+
117
+ sign {
118
+ application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
119
+ }
120
+
121
+ # Ask Gon for zip output to force notarization process to take place.
122
+ # The CI will ignore the zip output, using the signed binary only.
123
+ zip {
124
+ output_path = "unused.zip"
125
+ }
126
+ EOF
127
+
128
+ - name : Sign and notarize binary
129
+ env :
130
+ AC_USERNAME : ${{ secrets.AC_USERNAME }}
131
+ AC_PASSWORD : ${{ secrets.AC_PASSWORD }}
132
+ run : |
133
+ gon "${{ env.GON_CONFIG_PATH }}"
134
+
135
+ - name : Re-package binary and output checksum
136
+ id : re-package
137
+ working-directory : ${{ env.DIST_DIR }}
138
+ # This step performs the following:
139
+ # 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
140
+ # 2. Recalculate package checksum
141
+ # 3. Output the new checksum to include in the nnnnnn-checksums.txt file
142
+ # (it cannot be done there because of workflow job parallelization)
143
+ run : |
144
+ # GitHub's upload/download-artifact actions don't preserve file permissions,
145
+ # so we need to add execution permission back until the action is made to do this.
146
+ chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
147
+ TAG="${GITHUB_REF/refs\/tags\//}"
148
+ PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
149
+ tar -czvf "$PACKAGE_FILENAME" \
150
+ -C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
151
+ -C ../../ LICENSE.txt
152
+ CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
153
+ echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
154
+ echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
155
+
156
+ - name : Upload artifacts
157
+ uses : actions/upload-artifact@v3
158
+ with :
159
+ if-no-files-found : error
160
+ name : ${{ env.ARTIFACT_NAME }}
161
+ path : ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
51
162
52
163
create-release :
53
164
runs-on : ubuntu-latest
54
- needs : create-release-artifacts
165
+ needs : notarize-macos
55
166
56
167
steps :
57
168
- name : Download artifact
58
169
uses : actions/download-artifact@v3
59
170
with :
60
171
name : ${{ env.ARTIFACT_NAME }}
61
172
path : ${{ env.DIST_DIR }}
173
+
174
+ - name : Update checksum
175
+ run : |
176
+ declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
177
+ for checksum_line in "${checksum_lines[@]}"
178
+ do
179
+ CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
180
+ PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
181
+ perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
182
+ done
62
183
63
184
- name : Identify Prerelease
64
185
# This is a workaround while waiting for create-release action
0 commit comments