44 workflow_call :
55 inputs :
66 is_release :
7- required : true
7+ default : false
8+ description : ' Is this a release?'
89 type : boolean
9-
10+ required : false
1011jobs :
1112 build :
1213 strategy :
@@ -20,49 +21,70 @@ jobs:
2021 sha_command : pwsh -c "Get-FileHash -Algorithm SHA1 dist\mangotango_windows.exe | Format-Table Hash -HideTableHeaders > dist\mangotango_windows.exe.sha1"
2122 list_command : dir dist
2223 check_command : dist\mangotango_windows.exe --noop
23- - platform_name : MacOS 14
24- artifact_name : macos-14
25- os : macos-14
26- move_command : mv dist/mangotango dist/mangotango_macos_14
27- sha_command : shasum -a 1 dist/mangotango_macos_14 > dist/mangotango_macos_14.sha1
24+ - platform_name : MacOS (x86)
25+ artifact_name : macos-x86
26+ os : macos-13
27+ move_command : mv dist/mangotango dist/mangotango_macos-x86
28+ sha_command : shasum -a 1 dist/mangotango_macos-x86 > dist/mangotango_macos-x86.sha1
29+ sha_command_pkg : shasum -a 1 dist/mangotango_macos-x86.pkg > dist/mangotango_macos-x86.pkg.sha1
2830 list_command : ls -ll dist
29- check_command : dist/mangotango_macos_14 --noop
30- - platform_name : MacOS 15
31- artifact_name : macos-15
31+ check_command : dist/mangotango_macos-x86 --noop
32+ - platform_name : MacOS (arm64)
33+ artifact_name : macos-arm64
3234 os : macos-15
33- move_command : mv dist/mangotango dist/mangotango_macos_15
34- sha_command : shasum -a 1 dist/mangotango_macos_15 > dist/mangotango_macos_15.sha1
35+ move_command : mv dist/mangotango dist/mangotango_macos-arm64
36+ sha_command : shasum -a 1 dist/mangotango_macos-arm64 > dist/mangotango_macos-arm64.sha1
37+ sha_command_pkg : shasum -a 1 dist/mangotango_macos-arm64.pkg > dist/mangotango_macos-arm64.pkg.sha1
3538 list_command : ls -ll dist
36- check_command : dist/mangotango_macos_15 --noop
39+ check_command : dist/mangotango_macos-arm64 --noop
3740
3841 name : Build ${{ matrix.platform_name }}
3942 runs-on : ${{ matrix.os }}
4043 steps :
4144 - name : Checkout code
42- uses : actions/checkout@v2
45+ uses : actions/checkout@v4
4346
4447 - name : Set up Python
4548 uses : actions/setup-python@v4
4649 with :
4750 python-version : 3.12
48-
49- - name : Cache dependencies
50- uses : actions/cache@v3
51- with :
52- path : |
53- ~/.cache/pip
54- key : ${{ matrix.os }}-pip-${{ hashFiles('requirements.txt') }}
55- restore-keys : |
56- ${{ matrix.os }}-pip-
51+ cache : ' pip'
52+ cache-dependency-path : ' **/requirements*.txt'
5753
5854 - name : Install dependencies
5955 run : |
6056 python -m pip install --upgrade pip
6157 pip install -r requirements.txt
6258
6359 - name : Install PyInstaller
64- run : pip install pyinstaller
65-
60+ run : |
61+ pip install pyinstaller
62+ echo "PYINST_BIN=\"$(which pyinstaller)\"" >> "$GITHUB_ENV"
63+ - name : Create macOS keychain
64+ id : keychain
65+ if : runner.os == 'macOS'
66+ env :
67+ APPLE_DEV_EMAIL : ${{secrets.APPLE_DEV_EMAIL}}
68+ APP_SPEC_PASS : ${{secrets.APP_SPEC_PASS}}
69+ APPLE_APP_CERTIFICATE : ${{secrets.DEV_APP_CERT}}
70+ APPLE_APP_CERT_PASSWORD : ${{secrets.DEV_APP_CERT_PASS}}
71+ APPLE_INST_CERTIFICATE : ${{secrets.DEV_INST_CERT}}
72+ APPLE_INST_CERT_PASSWORD : ${{secrets.DEV_INST_CERT_PASS}}
73+ APPLE_KEYCHAIN_PASS : ${{secrets.APPLE_KEY_PASS}}
74+ run : |
75+ echo "$APPLE_APP_CERTIFICATE" | base64 --decode > app_certificate.p12
76+ echo "$APPLE_INST_CERTIFICATE" | base64 --decode > inst_certificate.p12
77+ security create-keychain -p $APPLE_KEYCHAIN_PASS build.keychain
78+ security default-keychain -s build.keychain
79+ security set-keychain-settings -lut 21600 build.keychain
80+ security unlock-keychain -p $APPLE_KEYCHAIN_PASS build.keychain
81+ security import app_certificate.p12 -k build.keychain -P $APPLE_APP_CERT_PASSWORD -A
82+ security import inst_certificate.p12 \
83+ -k build.keychain \
84+ -P "$APPLE_INST_CERT_PASSWORD" \
85+ -A
86+ security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $APPLE_KEYCHAIN_PASS build.keychain
87+ security find-identity -v -p codesigning -p macappstore
6688 - name : Print version string (for tag)
6789 id : get_version_tag
6890 if : ${{ github.ref_type == 'tag' }}
@@ -80,25 +102,60 @@ jobs:
80102 run : ${{ matrix.version_command }}
81103
82104 - name : Build the executable
83- run : |
84- pyinstaller pyinstaller.spec
105+ env :
106+ APPLE_APP_CERT_ID : ${{secrets.APPLE_APP_CERT_ID}}
107+ run : pyinstaller pyinstaller.spec
85108
86109 - name : Rename the executable to include platform suffix
87110 run : ${{ matrix.move_command }}
88111
89112 - name : Compute the SHA1 hashsum
90113 run : ${{ matrix.sha_command }}
91114
115+ - name : Create and sign mac package
116+ if : runner.os == 'macOS'
117+ env :
118+ APPLE_INST_CERT_ID : ${{secrets.APPLE_INST_CERT_ID}}
119+ APPLE_KEYCHAIN_PASS : ${{secrets.APPLE_KEY_PASS}}
120+ run : |
121+ mkdir -p /tmp/mangotango/
122+ ditto dist/mangotango_${{matrix.artifact_name}} /tmp/mangotango/mangotango
123+ chmod +x /tmp/mangotango/mangotango
124+ security unlock-keychain -p $APPLE_KEYCHAIN_PASS build.keychain
125+ security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$APPLE_KEYCHAIN_PASS" build.keychain
126+ security find-identity -v -p codesigning build.keychain
127+ pkgbuild --identifier "org.mangotango.cli" --timestamp --root /tmp/mangotango --install-location /Applications "./dist/mangotango_${{matrix.artifact_name}}_signed.pkg" --sign "$APPLE_INST_CERT_ID"
128+
129+ - name : Notarize Mac package
130+ if : runner.os == 'macOS'
131+ env :
132+ APPLE_DEV_EMAIL : ${{secrets.APPLE_DEV_EMAIL}}
133+ APPLE_TEAM_ID : ${{secrets.TEAM_ID}}
134+ APP_SPEC_PASS : ${{secrets.APP_SPEC_PASS}}
135+ run : xcrun notarytool submit dist/mangotango_${{matrix.artifact_name}}_signed.pkg --apple-id $APPLE_DEV_EMAIL --team-id $APPLE_TEAM_ID --password $APP_SPEC_PASS --wait > notarization_output.txt
136+
137+ - name : Staple the notarization ticket
138+ if : runner.os == 'macOS'
139+ run : xcrun stapler staple dist/mangotango_${{matrix.artifact_name}}_signed.pkg
140+
141+ - name : Clean up macOS Artifacts
142+ if : runner.os == 'macOS'
143+ run : |
144+ rm -rf /tmp/mangotango
145+ rm -rf dist/mangotango_${{matrix.artifact_name}}
146+ rm -rf dist/mangotango_${{matrix.artifact_name}}.pkg
147+ mv dist/mangotango_${{matrix.artifact_name}}_signed.pkg dist/mangotango_${{matrix.artifact_name}}.pkg
148+
149+ - name : Compute the SHA1 hashsum for macOS .pkg
150+ if : runner.os == 'macOS'
151+ run : ${{ matrix.sha_command_pkg }}
152+
92153 - name : Inspect the dist/ directory before uploading artifacts
93154 run : ${{ matrix.list_command }}
94155
95- - name : Check that the executable runs
96- if : inputs.is_release == false
97- run : ${{ matrix.check_command}}
98-
99156 - name : Upload artifacts
100- if : inputs.is_release
101157 uses : actions/upload-artifact@v4
158+ if : inputs.is_release
102159 with :
103160 name : ${{ matrix.artifact_name }}
104161 path : |
0 commit comments