Skip to content

Commit f4878ad

Browse files
refactor: Use ci/cd to generate macOS icon
- Remove /macos folder with the macOS icon - update actions/upload-artifact@v3 -> v4 - trackereditor_linux_amd64.zip -> trackereditor_linux_amd64_gtk2.zip
1 parent 3e680a3 commit f4878ad

File tree

6 files changed

+49
-90
lines changed

6 files changed

+49
-90
lines changed

.github/workflows/cicd.yml

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
LAZ_OPT:
3030
- os: ubuntu-latest
3131
LAZBUILD_WITH_PATH: lazbuild
32-
RELEASE_ZIP_FILE: trackereditor_linux_amd64.zip
33-
LAZ_OPT:
32+
RELEASE_ZIP_FILE: trackereditor_linux_amd64_gtk2.zip
33+
LAZ_OPT: --widgetset=gtk2
3434
- os: macos-latest
3535
LAZBUILD_WITH_PATH: /Applications/Lazarus/lazbuild
3636
RELEASE_ZIP_FILE: trackereditor_macOS_amd64.zip
@@ -58,13 +58,13 @@ jobs:
5858

5959
- name: Build Release version
6060
# Build trackereditor project (Release mode)
61-
run: ${{ matrix.LAZBUILD_WITH_PATH }} --build-mode=Release ${{ matrix.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
61+
run: ${{ matrix.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release ${{ matrix.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
6262
shell: bash
6363

6464
- name: Build Unit Test on Windows
6565
if: matrix.os == 'windows-latest'
6666
# Build unit test project (Debug mode)
67-
run: ${{ matrix.LAZBUILD_WITH_PATH }} --build-mode=Debug ${{ matrix.LAZ_OPT }} source/project/unit_test/tracker_editor_test.lpi
67+
run: ${{ matrix.LAZBUILD_WITH_PATH }} --build-all --build-mode=Debug ${{ matrix.LAZ_OPT }} source/project/unit_test/tracker_editor_test.lpi
6868
shell: bash
6969

7070
- name: Run Unit Test on Windows
@@ -98,23 +98,41 @@ jobs:
9898
zip -j ${{ matrix.RELEASE_ZIP_FILE }} enduser/*.txt enduser/trackereditor.exe enduser/*.dll
9999
shell: bash
100100

101-
- name: Move file into macOS .app
101+
- name: Move program and icon into macOS .app
102102
if: matrix.os == 'macos-latest'
103+
env:
104+
ICON_FILE: 'metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.png'
105+
PROGRAM_NAME_WITH_PATH: 'enduser/trackereditor'
103106
run: |
104-
# copy everything into enduser/macos/app folder
105-
#
106-
# Move the executable to the application bundle
107-
mv enduser/trackereditor enduser/macos/app/trackereditor.app/Contents/MacOS
108-
109-
# Move the trackers list to application bundle
110-
mv enduser/add_trackers.txt enduser/macos/app/trackereditor.app/Contents/MacOS
111-
mv enduser/remove_trackers.txt enduser/macos/app/trackereditor.app/Contents/MacOS
112-
113-
# move all the *.txt file
114-
mv enduser/*.txt enduser/macos/app
115-
116-
# zip only the app folder with extra text file.
117-
# /usr/bin/ditto -c -k "enduser/macos/app" "${{ matrix.RELEASE_ZIP_FILE }}"
107+
# remove the path
108+
PROGRAM_NAME_ONLY=$(basename -- "$PROGRAM_NAME_WITH_PATH")
109+
110+
# ------ Move program to app
111+
# remove symbolic link in app. Need real program here.
112+
rm -f "${PROGRAM_NAME_WITH_PATH}.app/Contents/MacOS/${PROGRAM_NAME_ONLY}"
113+
# copy the program to the app version.
114+
mv -f "${PROGRAM_NAME_WITH_PATH}" "${PROGRAM_NAME_WITH_PATH}.app/Contents/MacOS"
115+
116+
# ------ Create icon set and move it into the app
117+
iconset_folder="temp_folder.iconset"
118+
rm -rf "${iconset_folder}"
119+
mkdir -p "${iconset_folder}"
120+
121+
for s in 16 32 128 256 512; do
122+
d=$(($s*2))
123+
sips -Z $s $ICON_FILE --out "${iconset_folder}/icon_${s}x$s.png"
124+
sips -Z $d $ICON_FILE --out "${iconset_folder}/icon_${s}[email protected]"
125+
done
126+
127+
# create .icns icon file
128+
iconutil -c icns "${iconset_folder}" -o "iconfile.icns"
129+
rm -r "${iconset_folder}"
130+
131+
# move icon file to the app
132+
mv -f "iconfile.icns" "${PROGRAM_NAME_WITH_PATH}.app/Contents/Resources"
133+
134+
# add icon to plist xml file CFBundleIconFile = "iconfile"
135+
plutil -insert CFBundleIconFile -string "iconfile" "${PROGRAM_NAME_WITH_PATH}.app/Contents/Info.plist"
118136
shell: bash
119137

120138
- name: Codesign macOS app bundle
@@ -127,6 +145,7 @@ jobs:
127145
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
128146
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
129147
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
148+
MACOS_APP: enduser/trackereditor.app
130149
run: |
131150
# Turn our base64-encoded certificate back to a regular .p12 file
132151
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
@@ -142,14 +161,11 @@ jobs:
142161
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
143162
144163
# We finally codesign our app bundle, specifying the Hardened runtime option.
145-
#/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime enduser/macos/app/trackereditor.app -v
164+
#/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime "$MACOS_APP" -v
146165
147166
# sign the app. -sign is the developer cetificate ID
148-
# entitlements does not work at this moment
149-
#codesign --timestamp --entitlements enduser/macos/entitlements.plist --force --options runtime --deep --sign $CERTIFICATE_ID $FILE_APP
150-
151-
# Please note: this is the same code version used in Travis-CI
152-
/usr/bin/codesign --timestamp --force --options runtime --deep --sign "$MACOS_CERTIFICATE_NAME" enduser/macos/app/trackereditor.app
167+
# Must use --deep to sign all internal content
168+
/usr/bin/codesign --timestamp --force --options runtime --deep --sign "$MACOS_CERTIFICATE_NAME" "$MACOS_APP"
153169
shell: bash
154170

155171
- name: Notarize macOS app bundle
@@ -158,6 +174,7 @@ jobs:
158174
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
159175
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
160176
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
177+
MACOS_APP: enduser/trackereditor.app
161178
run: |
162179
# Store the notarization credentials so that we can prevent a UI password dialog
163180
# from blocking the CI
@@ -170,7 +187,7 @@ jobs:
170187
# notarization service
171188
172189
echo "Creating temp notarization archive"
173-
ditto -c -k --keepParent "enduser/macos/app/trackereditor.app" "notarization.zip"
190+
ditto -c -k --keepParent "$MACOS_APP" "notarization.zip"
174191
175192
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
176193
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
@@ -183,20 +200,22 @@ jobs:
183200
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
184201
# validated by macOS even when an internet connection is not available.
185202
echo "Attach staple"
186-
xcrun stapler staple "enduser/macos/app/trackereditor.app"
203+
xcrun stapler staple "$MACOS_APP"
187204
188205
# Remove notarization.zip, otherwise it will also be 'released' to the end user
189206
rm -f "notarization.zip"
190207
191-
# zip only the app folder with extra text file.
208+
# zip only the app folder.
192209
echo "Zip macOS app file"
193-
/usr/bin/ditto -c -k "enduser/macos/app" "${{ matrix.RELEASE_ZIP_FILE }}"
210+
/usr/bin/ditto -c -k --keepParent "$MACOS_APP" "${{ matrix.RELEASE_ZIP_FILE }}"
194211
shell: bash
195212

196213
- name: Upload Artifact
197-
uses: actions/upload-artifact@v3
214+
uses: actions/upload-artifact@v4
198215
with:
216+
name: artifact-${{ matrix.os }}
199217
path: ${{ matrix.RELEASE_ZIP_FILE }}
218+
compression-level: 0 # no compression. Content is already a zip file
200219
if-no-files-found: error
201220

202221
- name: Zip file release to end user

enduser/macos/app/trackereditor.app/Contents/Info.plist

Lines changed: 0 additions & 47 deletions
This file was deleted.

enduser/macos/app/trackereditor.app/Contents/MacOS/.gitkeep

Whitespace-only changes.

enduser/macos/app/trackereditor.app/Contents/PkgInfo

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

enduser/macos/entitlements.plist

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)