@@ -17,10 +17,11 @@ jobs:
1717 timeout-minutes : 60
1818 env :
1919 LAZBUILD_WITH_PATH : /Applications/Lazarus/lazbuild
20- RELEASE_ZIP_FILE : trackereditor_macOS_amd64.zip
2120 MACOS_APP : enduser/trackereditor.app
22- LAZ_OPT : --widgetset=cocoa
21+ PROGRAM_NAME_WITH_PATH : ' enduser/trackereditor '
2322 BUILD_WITH_CERTIFICATE : ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
23+ PROJECT_LPI : source/project/tracker_editor/trackereditor.lpi
24+ RELEASE_DMG_FILE : trackereditor_macOS_universal.dmg
2425
2526 steps :
2627 - uses : actions/checkout@v4
@@ -30,24 +31,54 @@ jobs:
3031 - name : Install Lazarus IDE
3132 run : brew install --cask lazarus
3233
33- - name : Build Release version
34- # Build trackereditor project (Release mode)
35- run : ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release ${{ env.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
34+ - name : Install Create dmg
35+ run : brew install create-dmg
36+
37+ - name : Build trackereditor app for Apple silicon (aarch64)
38+ run : |
39+ ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release --widgetset=cocoa --cpu=aarch64 ${{ env.PROJECT_LPI }}
40+ cp -a ${{ env.PROGRAM_NAME_WITH_PATH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-aarch64
41+ shell : bash
42+
43+ - name : Build trackereditor app for Intel Mac version (x86_64)
44+ run : |
45+ ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release --widgetset=cocoa --cpu=x86_64 ${{ env.PROJECT_LPI }}
46+ cp -a ${{ env.PROGRAM_NAME_WITH_PATH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-x86_64
47+ shell : bash
48+
49+ - name : Create a Universal macOS binary from aarch64 and x86_64
50+ run : |
51+ # remove the previeus binary build
52+ rm -f ${{ env.PROGRAM_NAME_WITH_PATH }}
53+
54+ # Create a new Universal macOS binary
55+ lipo -create -output ${{ env.PROGRAM_NAME_WITH_PATH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-aarch64 ${{ env.PROGRAM_NAME_WITH_PATH }}-x86_64
56+
57+ # Remove this single binary build. Not needed any more.
58+ rm -f ${{ env.PROGRAM_NAME_WITH_PATH }}-aarch64
59+ rm -f ${{ env.PROGRAM_NAME_WITH_PATH }}-x86_64
60+ shell : bash
61+
62+ - name : Extract latest program version from metainfo and update the Info.plist with it
63+ env :
64+ METAINFO_FILE : metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.metainfo.xml
65+ run : |
66+ TRACKER_EDITOR_VERSION=$(xmllint --xpath "string(/component/releases/release[1]/@version)" $METAINFO_FILE)
67+ echo Program version: $TRACKER_EDITOR_VERSION
68+ plutil -replace CFBundleShortVersionString -string $TRACKER_EDITOR_VERSION ${{ env.MACOS_APP }}/Contents/Info.plist
3669 shell : bash
3770
3871 - name : Move program and icon into macOS .app
3972 env :
4073 ICON_FILE : ' metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.png'
41- PROGRAM_NAME_WITH_PATH : ' enduser/trackereditor'
4274 run : |
43- # remove the path
44- PROGRAM_NAME_ONLY=$(basename -- "$PROGRAM_NAME_WITH_PATH")
75+ PROGRAM_NAME_ONLY=$(basename -- "${{ env.PROGRAM_NAME_WITH_PATH }}")
4576
4677 # ------ Move program to app
47- # remove symbolic link in app. Need real program here.
48- rm -f "${PROGRAM_NAME_WITH_PATH}.app /Contents/MacOS/${PROGRAM_NAME_ONLY}"
78+ # remove the previeus app version
79+ rm -f "${{ env.MACOS_APP }} /Contents/MacOS/${PROGRAM_NAME_ONLY}"
4980 # copy the program to the app version.
50- mv -f "${PROGRAM_NAME_WITH_PATH} " "${PROGRAM_NAME_WITH_PATH}.app /Contents/MacOS"
81+ mv -f "${{ env. PROGRAM_NAME_WITH_PATH }} " "${{ env.MACOS_APP }} /Contents/MacOS"
5182
5283 # ------ Create icon set and move it into the app
5384 iconset_folder="temp_folder.iconset"
@@ -65,17 +96,29 @@ jobs:
6596 rm -r "${iconset_folder}"
6697
6798 # move icon file to the app
68- mv -f "iconfile.icns" "${PROGRAM_NAME_WITH_PATH}.app /Contents/Resources"
99+ mv -f "iconfile.icns" "${{ env.MACOS_APP }} /Contents/Resources"
69100
70101 # add icon to plist xml file CFBundleIconFile = "iconfile"
71- plutil -insert CFBundleIconFile -string "iconfile" "${PROGRAM_NAME_WITH_PATH}.app/Contents/Info.plist"
102+ plutil -insert CFBundleIconFile -string "iconfile" "${{ env.MACOS_APP }}/Contents/Info.plist"
103+ shell : bash
104+
105+ - name : Check CPU type generated by Lazbuild
106+ run : |
107+ lipo -archs "${{ env.MACOS_APP }}"/Contents/MacOS/trackereditor
108+ lipo -archs "${{ env.MACOS_APP }}"/Contents/MacOS/trackereditor | grep -Fq x86_64
109+ lipo -archs "${{ env.MACOS_APP }}"/Contents/MacOS/trackereditor | grep -Fq arm64
110+ shell : bash
111+
112+ - name : Test App SSL connection
113+ run : open "${{ env.MACOS_APP }}" --args -TEST_SSL
72114 shell : bash
73115
74- - name : Codesign macOS app bundle
116+ - name : Codesign macOS app bundle. If certificate is present.
75117 if : ${{ env.BUILD_WITH_CERTIFICATE != '' }}
76118 # This macOS Codesign step is copied from:
77119 # https://federicoterzi.com/blog/automatic-code-signing-and-notarization-for-macos-apps-using-github-actions/
78120 # This is a bit different from the previous version for Travis-CI build system to build bittorrent tracker editor
121+ # More info https://developer.apple.com/forums/thread/128166
79122 env :
80123 MACOS_CERTIFICATE : ${{ secrets.PROD_MACOS_CERTIFICATE }}
81124 MACOS_CERTIFICATE_PWD : ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
@@ -95,15 +138,35 @@ jobs:
95138 security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
96139 security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
97140
98- # We finally codesign our app bundle, specifying the Hardened runtime option.
99- #/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime "${{ env.MACOS_APP }}" -v
100-
101141 # sign the app. -sign is the developer cetificate ID
102- # Must use --deep to sign all internal content
103- /usr/bin/codesign --timestamp --force --options runtime --deep --sign "$MACOS_CERTIFICATE_NAME" "${{ env.MACOS_APP }}"
142+ /usr/bin/codesign --timestamp --force --options runtime --sign "$MACOS_CERTIFICATE_NAME" "${{ env.MACOS_APP }}"
143+ shell : bash
144+
145+ - name : Create dmg file from the enduser/ folder
146+ run : |
147+ # Remove all txt file. There are not needed.
148+ rm -f enduser/*.txt
149+
150+ # Build dmg image. https://github.com/create-dmg/create-dmg
151+ create-dmg \
152+ --volname "bittorrent-tracker-editor" \
153+ --window-pos 200 120 \
154+ --window-size 800 400 \
155+ --icon "trackereditor.app" 200 190 \
156+ --app-drop-link 600 185 \
157+ ${{ env.RELEASE_DMG_FILE }} \
158+ "./enduser"
159+ shell : bash
160+
161+ - name : Codesign dmg file. If certificate is present.
162+ if : ${{ env.BUILD_WITH_CERTIFICATE != '' }}
163+ env :
164+ MACOS_CERTIFICATE_NAME : ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
165+ run : |
166+ /usr/bin/codesign --timestamp --force --options runtime --sign "$MACOS_CERTIFICATE_NAME" "${{ env.RELEASE_DMG_FILE }}"
104167 shell : bash
105168
106- - name : Notarize macOS app bundle
169+ - name : Notarize macOS DMG bundle. If certificate is present.
107170 if : ${{ env.BUILD_WITH_CERTIFICATE != '' }}
108171 env :
109172 PROD_MACOS_NOTARIZATION_APPLE_ID : ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
@@ -121,7 +184,7 @@ jobs:
121184 # notarization service
122185
123186 echo "Creating temp notarization archive"
124- ditto -c -k --keepParent "${{ env.MACOS_APP }}" "notarization.zip"
187+ ditto -c -k --keepParent "${{ env.RELEASE_DMG_FILE }}" "notarization.zip"
125188
126189 # Here we send the notarization request to the Apple's Notarization service, waiting for the result.
127190 # This typically takes a few seconds inside a CI environment, but it might take more depending on the App
@@ -134,25 +197,19 @@ jobs:
134197 # Finally, we need to "attach the staple" to our executable, which will allow our app to be
135198 # validated by macOS even when an internet connection is not available.
136199 echo "Attach staple"
137- xcrun stapler staple "${{ env.MACOS_APP }}"
138- shell : bash
139-
140- - name : Zip only the app folder.
141- run : |
142- echo "Zip macOS app file"
143- /usr/bin/ditto -c -k --keepParent "${{ env.MACOS_APP }}" "${{ env.RELEASE_ZIP_FILE }}"
200+ xcrun stapler staple "${{ env.RELEASE_DMG_FILE }}"
144201 shell : bash
145202
146203 - name : Upload Artifact
147204 uses : actions/upload-artifact@v4
148205 with :
149- name : artifact-${{ runner.os }}
150- path : ${{ env.RELEASE_ZIP_FILE }}
206+ name : artifact-${{ env.RELEASE_DMG_FILE }}
207+ path : ${{ env.RELEASE_DMG_FILE }}
151208 compression-level : 0 # no compression. Content is already a zip file
152209 if-no-files-found : error
153210
154211 - name : File release to end user
155212 uses : softprops/action-gh-release@v2
156213 if : startsWith(github.ref, 'refs/tags/')
157214 with :
158- files : ${{ env.RELEASE_ZIP_FILE }}
215+ files : ${{ env.RELEASE_DMG_FILE }}
0 commit comments