Skip to content

Commit c540bc8

Browse files
add: 3 new GitHub action build files
Each operating system has its own build file. This is a replacement for the previous cicd.yml file.
1 parent 09b2e36 commit c540bc8

File tree

3 files changed

+314
-0
lines changed

3 files changed

+314
-0
lines changed

.github/workflows/cicd_macos.yaml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: CI/CD on macOS systems.
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
pull_request:
9+
workflow_dispatch:
10+
# Automatic cron build every 6 months to check if everything still works.
11+
schedule:
12+
- cron: "0 0 1 1/6 *"
13+
14+
jobs:
15+
build:
16+
runs-on: macos-latest
17+
env:
18+
LAZBUILD_WITH_PATH: /Applications/Lazarus/lazbuild
19+
RELEASE_ZIP_FILE: trackereditor_macOS_amd64.zip
20+
LAZ_OPT: --widgetset=cocoa
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install Lazarus IDE
26+
run: brew install --cask lazarus
27+
28+
- name: Build Release version
29+
# Build trackereditor project (Release mode)
30+
run: ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release ${{ env.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
31+
shell: bash
32+
33+
- name: Move program and icon into macOS .app
34+
env:
35+
ICON_FILE: 'metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.png'
36+
PROGRAM_NAME_WITH_PATH: 'enduser/trackereditor'
37+
run: |
38+
# remove the path
39+
PROGRAM_NAME_ONLY=$(basename -- "$PROGRAM_NAME_WITH_PATH")
40+
41+
# ------ Move program to app
42+
# remove symbolic link in app. Need real program here.
43+
rm -f "${PROGRAM_NAME_WITH_PATH}.app/Contents/MacOS/${PROGRAM_NAME_ONLY}"
44+
# copy the program to the app version.
45+
mv -f "${PROGRAM_NAME_WITH_PATH}" "${PROGRAM_NAME_WITH_PATH}.app/Contents/MacOS"
46+
47+
# ------ Create icon set and move it into the app
48+
iconset_folder="temp_folder.iconset"
49+
rm -rf "${iconset_folder}"
50+
mkdir -p "${iconset_folder}"
51+
52+
for s in 16 32 128 256 512; do
53+
d=$(($s*2))
54+
sips -Z $s $ICON_FILE --out "${iconset_folder}/icon_${s}x$s.png"
55+
sips -Z $d $ICON_FILE --out "${iconset_folder}/icon_${s}[email protected]"
56+
done
57+
58+
# create .icns icon file
59+
iconutil -c icns "${iconset_folder}" -o "iconfile.icns"
60+
rm -r "${iconset_folder}"
61+
62+
# move icon file to the app
63+
mv -f "iconfile.icns" "${PROGRAM_NAME_WITH_PATH}.app/Contents/Resources"
64+
65+
# add icon to plist xml file CFBundleIconFile = "iconfile"
66+
plutil -insert CFBundleIconFile -string "iconfile" "${PROGRAM_NAME_WITH_PATH}.app/Contents/Info.plist"
67+
shell: bash
68+
69+
- name: Codesign macOS app bundle
70+
# This macOS Codesign step is copied from:
71+
# https://federicoterzi.com/blog/automatic-code-signing-and-notarization-for-macos-apps-using-github-actions/
72+
# This is a bit different from the previous version for Travis-CI build system to build bittorrent tracker editor
73+
env:
74+
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
75+
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
76+
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
77+
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
78+
MACOS_APP: enduser/trackereditor.app
79+
run: |
80+
# Turn our base64-encoded certificate back to a regular .p12 file
81+
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
82+
83+
# We need to create a new keychain, otherwise using the certificate will prompt
84+
# with a UI dialog asking for the certificate password, which we can't
85+
# use in a headless CI environment
86+
87+
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
88+
security default-keychain -s build.keychain
89+
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
90+
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
91+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
92+
93+
# We finally codesign our app bundle, specifying the Hardened runtime option.
94+
#/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime "$MACOS_APP" -v
95+
96+
# sign the app. -sign is the developer cetificate ID
97+
# Must use --deep to sign all internal content
98+
/usr/bin/codesign --timestamp --force --options runtime --deep --sign "$MACOS_CERTIFICATE_NAME" "$MACOS_APP"
99+
shell: bash
100+
101+
- name: Notarize macOS app bundle
102+
env:
103+
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
104+
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
105+
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
106+
MACOS_APP: enduser/trackereditor.app
107+
run: |
108+
# Store the notarization credentials so that we can prevent a UI password dialog
109+
# from blocking the CI
110+
111+
echo "Create keychain profile"
112+
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
113+
114+
# We can't notarize an app bundle directly, but we need to compress it as an archive.
115+
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
116+
# notarization service
117+
118+
echo "Creating temp notarization archive"
119+
ditto -c -k --keepParent "$MACOS_APP" "notarization.zip"
120+
121+
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
122+
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
123+
# characteristics. Visit the Notarization docs for more information and strategies on how to optimize it if
124+
# you're curious
125+
126+
echo "Notarize app"
127+
xcrun notarytool submit "notarization.zip" --keychain-profile "notarytool-profile" --wait
128+
129+
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
130+
# validated by macOS even when an internet connection is not available.
131+
echo "Attach staple"
132+
xcrun stapler staple "$MACOS_APP"
133+
134+
# Remove notarization.zip, otherwise it will also be 'released' to the end user
135+
rm -f "notarization.zip"
136+
137+
# zip only the app folder.
138+
echo "Zip macOS app file"
139+
/usr/bin/ditto -c -k --keepParent "$MACOS_APP" "${{ env.RELEASE_ZIP_FILE }}"
140+
shell: bash
141+
142+
- name: Upload Artifact
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: artifact-${{ runner.os }}
146+
path: ${{ env.RELEASE_ZIP_FILE }}
147+
compression-level: 0 # no compression. Content is already a zip file
148+
if-no-files-found: error
149+
150+
- name: File release to end user
151+
uses: softprops/action-gh-release@v2
152+
if: startsWith(github.ref, 'refs/tags/')
153+
with:
154+
files: ${{ env.RELEASE_ZIP_FILE }}

.github/workflows/cicd_ubuntu.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI/CD on Linux systems.
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
pull_request:
9+
workflow_dispatch:
10+
# Automatic cron build every 6 months to check if everything still works.
11+
schedule:
12+
- cron: "0 0 1 1/6 *"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
env:
18+
LAZBUILD_WITH_PATH: lazbuild
19+
RELEASE_FILE_NAME: trackereditor_linux_amd64.AppImage
20+
LAZ_OPT: --widgetset=qt5
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install dependency
26+
run: sudo apt-get install -y lazarus fpc fuse xvfb libqt5pas-dev qt5-qmake qtwayland5 qt5-gtk-platformtheme libqt5svg5
27+
shell: bash
28+
29+
- name: Build Release version
30+
# Build trackereditor project (Release mode)
31+
run: ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release ${{ env.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
32+
shell: bash
33+
34+
- name: Test OpenSSL works on Linux CI
35+
run: xvfb-run --auto-servernum enduser/trackereditor -TEST_SSL
36+
shell: bash
37+
38+
- name: Download linuxdeploy
39+
# Use static versions of AppImage builder. So it won't depend on some specific OS image or library version.
40+
run: |
41+
curl -L -O https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-static-x86_64.AppImage
42+
curl -L -O https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-static-x86_64.AppImage
43+
curl -L -O https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage
44+
chmod +x linuxdeploy-*.AppImage
45+
shell: bash
46+
47+
- name: Create AppImage
48+
# NO_STRIP: true => or else warning: qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
49+
# LDAI_NO_APPSTREAM=1: skip checking AppStream metadata for issues
50+
env:
51+
NO_STRIP: true
52+
LDAI_NO_APPSTREAM: 1
53+
LDAI_OUTPUT: ${{ env.RELEASE_FILE_NAME }}
54+
run: |
55+
./linuxdeploy-static-x86_64.AppImage \
56+
--output appimage \
57+
--appdir temp_appdir \
58+
--plugin qt \
59+
--executable enduser/trackereditor \
60+
--desktop-file metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.desktop \
61+
--icon-file metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.png
62+
shell: bash
63+
64+
- name: Upload Artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: artifact-${{ runner.os }}
68+
path: ${{ env.RELEASE_FILE_NAME }}
69+
compression-level: 0 # no compression. Content is already a compress file
70+
if-no-files-found: error
71+
72+
- name: File release to end user
73+
uses: softprops/action-gh-release@v2
74+
if: startsWith(github.ref, 'refs/tags/')
75+
with:
76+
files: ${{ env.RELEASE_FILE_NAME }}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI/CD on Windows systems.
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
pull_request:
9+
workflow_dispatch:
10+
# Automatic cron build every 6 months to check if everything still works.
11+
schedule:
12+
- cron: "0 0 1 1/6 *"
13+
14+
jobs:
15+
build:
16+
runs-on: windows-2022
17+
env:
18+
LAZBUILD_WITH_PATH: c:/lazarus/lazbuild
19+
RELEASE_ZIP_FILE: trackereditor_windows_amd64.zip
20+
LAZ_OPT:
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install winget
26+
# winget will be included in windows server 2025
27+
uses: Cyberboss/install-winget@v1
28+
with:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Install Lazarus IDE
32+
run: winget install lazarus --disable-interactivity --accept-source-agreements --silent
33+
34+
- name: Download OpenSSL *.dll
35+
run: |
36+
# Need OpenSSL *.dll to download updated trackers from the internet.
37+
# https://wiki.overbyte.eu/wiki/index.php/ICS_Download#Download_OpenSSL_Binaries
38+
curl -L -O --output-dir enduser https://github.com/GerryFerdinandus/bittorrent-tracker-editor/releases/download/V1.32.0/libssl-3-x64.dll
39+
curl -L -O --output-dir enduser https://github.com/GerryFerdinandus/bittorrent-tracker-editor/releases/download/V1.32.0/libcrypto-3-x64.dll
40+
shell: bash
41+
42+
- name: Build Release version
43+
# Build trackereditor project (Release mode)
44+
run: ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Release ${{ env.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
45+
shell: bash
46+
47+
- name: Build Unit Test on Windows
48+
# Build unit test project (Debug mode)
49+
run: ${{ env.LAZBUILD_WITH_PATH }} --build-all --build-mode=Debug ${{ env.LAZ_OPT }} source/project/unit_test/tracker_editor_test.lpi
50+
shell: bash
51+
52+
- name: Run Unit Test on Windows
53+
# Also remove all the extra file created by test.
54+
# We do not what it in the ZIP release files.
55+
# Undo all changes made by testing.
56+
run: |
57+
set -e
58+
enduser/test_trackereditor -a --format=plain
59+
set +e
60+
61+
# remove file created by unit test
62+
rm -f enduser/console_log.txt
63+
rm -f enduser/export_trackers.txt
64+
git reset --hard
65+
shell: bash
66+
67+
- name: Create a zip file for Windows release.
68+
run: |
69+
Compress-Archive -Path enduser\*.txt, enduser\trackereditor.exe, enduser\*.dll -DestinationPath $Env:RELEASE_ZIP_FILE
70+
shell: pwsh
71+
72+
- name: Upload Artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: artifact-${{ runner.os }}
76+
path: ${{ env.RELEASE_ZIP_FILE }}
77+
compression-level: 0 # no compression. Content is already a zip file
78+
if-no-files-found: error
79+
80+
- name: File release to end user
81+
uses: softprops/action-gh-release@v2
82+
if: startsWith(github.ref, 'refs/tags/')
83+
with:
84+
files: ${{ env.RELEASE_ZIP_FILE }}

0 commit comments

Comments
 (0)