50
50
path : ${{ env.DIST_DIR }}
51
51
52
52
notarize-macos :
53
+ name : notarize-${{ matrix.artifact.name }}
53
54
runs-on : macos-latest
54
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
+ strategy :
61
+ matrix :
62
+ artifact :
63
+ - name : darwin_amd64
64
+ path : " macOS_64bit.tar.gz"
65
+ - name : darwin_arm64
66
+ path : " macOS_ARM64.tar.gz"
55
67
56
68
steps :
57
69
- name : Checkout repository
@@ -91,27 +103,49 @@ jobs:
91
103
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
92
104
unzip gon_macos.zip -d /usr/local/bin
93
105
106
+ - name : Write gon config to file
107
+ # gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
108
+ run : |
109
+ cat > gon.config.hcl <<EOF
110
+ # See: https://github.com/mitchellh/gon#configuration-file
111
+ source = ["dist/arduino-cli_osx_${{ matrix.artifact.name }}/arduino-cli"]
112
+ bundle_id = "cc.arduino.arduino-cli"
113
+
114
+ sign {
115
+ application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
116
+ }
117
+
118
+ # Ask Gon for zip output to force notarization process to take place.
119
+ # The CI will ignore the zip output, using the signed binary only.
120
+ zip {
121
+ output_path = "unused.zip"
122
+ }
123
+ EOF
124
+
94
125
- name : Sign and notarize binary
95
126
env :
96
127
AC_USERNAME : ${{ secrets.AC_USERNAME }}
97
128
AC_PASSWORD : ${{ secrets.AC_PASSWORD }}
98
129
run : |
99
130
gon gon.config.hcl
100
131
101
- - name : Re-package binary and update checksum
132
+ - name : Re-package binary and output checksum
133
+ id : re-package
102
134
# This step performs the following:
103
135
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
104
- # 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
136
+ # 2. Recalculate package checksum
137
+ # 3. Output the new checksum to include in the nnnnnn-checksums.txt file(it cannot be done there because of parallelization)
105
138
run : |
106
139
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
107
140
# so we need to add execution permission back until the action is made to do this.
108
- chmod +x ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64 /${{ env.PROJECT_NAME }}
141
+ chmod +x " ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }} /${{ env.PROJECT_NAME }}"
109
142
TAG="${GITHUB_REF/refs\/tags\//}"
110
- tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
111
- -C ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/ ${{ env.PROJECT_NAME }} \
143
+ PACKAGE_FILENAME="$(basename ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }})"
144
+ tar -czvf "${{ env.DIST_DIR }}/$PACKAGE_FILENAME" \
145
+ -C "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
112
146
-C ../../ LICENSE.txt
113
- CHECKSUM ="$(shasum -a 256 ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1 )"
114
- perl -pi -w -e "s/.* ${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/${CHECKSUM} ${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/g;" ${{ env.DIST_DIR }}/*-checksums.txt
147
+ CHECKSUM_LINE ="$(shasum -a 256 ${{ env.DIST_DIR }}/$PACKAGE_FILENAME )"
148
+ echo "::set-output name=checksum- ${{ matrix.artifact.name }}::$CHECKSUM_LINE"
115
149
116
150
- name : Upload artifacts
117
151
uses : actions/upload-artifact@v3
@@ -131,6 +165,16 @@ jobs:
131
165
name : ${{ env.ARTIFACT_NAME }}
132
166
path : ${{ env.DIST_DIR }}
133
167
168
+ - name : Update checksum
169
+ run : |
170
+ declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}", "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
171
+ for checksum_line in "${checksum_lines[@]}"
172
+ do
173
+ CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
174
+ PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
175
+ perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
176
+ done
177
+
134
178
- name : Identify Prerelease
135
179
# This is a workaround while waiting for create-release action
136
180
# to implement auto pre-release based on tag
0 commit comments