Skip to content

Commit 982629e

Browse files
feat: refactor CI/CD workflows
To use the composite action to install Lazarus
1 parent 771550b commit 982629e

File tree

3 files changed

+77
-177
lines changed

3 files changed

+77
-177
lines changed

.github/workflows/cicd_macos.yaml

Lines changed: 69 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -37,169 +37,75 @@ env:
3737
BUILD_WITH_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
3838
PROJECT_LPI: source/project/tracker_editor/trackereditor.lpi
3939
RELEASE_DMG_FILE: trackereditor_macOS_notarized_universal_binary.dmg
40-
# Copied the latest Lazarus source code from: https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/
41-
LAZARUS_URL_TAR_GZ: "https://github.com/GerryFerdinandus/bittorrent-tracker-editor/releases/download/V1.32.0/lazarus.tar.gz"
4240

4341
jobs:
44-
build_aarch64: # Build for Apple silicon Mac architecture
45-
runs-on: macos-latest
42+
build:
4643
timeout-minutes: 60
44+
45+
strategy:
46+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
47+
fail-fast: false
48+
49+
# Set up an include to perform the following build configurations.
50+
matrix:
51+
include:
52+
- BUILD_TARGET: build_aarch64
53+
ARCH: aarch64
54+
RUNS_ON: macos-latest
55+
56+
- BUILD_TARGET: build_x86_64
57+
ARCH: x86_64
58+
RUNS_ON: macos-15-intel
59+
60+
name: ${{ matrix.BUILD_TARGET }}
61+
runs-on: ${{ matrix.RUNS_ON }}
62+
4763
steps:
4864
- uses: actions/checkout@v6
4965
with:
5066
submodules: true
5167

52-
- name: Install Free Pascal Compiler (FPC) multi arch version for macOS x86_64 and aarch64
53-
run: brew install fpc
54-
shell: bash
68+
- name: Install Lazarus IDE
69+
uses: ./.github/actions/install_lazarus
5570

56-
- name: Download Lazarus source code into temp folder
71+
- name: Build trackereditor app for Apple (${{ matrix.ARCH }})
5772
run: |
58-
#Download lazarus source code. Directory 'lazarus' will be created in the temp folder.
59-
cd ${RUNNER_TEMP}
60-
curl -L -O ${{ env.LAZARUS_URL_TAR_GZ }}
61-
tar -xzf *.tar.gz
62-
shell: bash
63-
64-
- name: Build lazbuild from Lazarus source code
65-
run: |
66-
# make lazbuild and put the link with extra parameter in the temp folder.
67-
LAZARUS_DIR=${RUNNER_TEMP}/lazarus
68-
cd "$LAZARUS_DIR"
69-
make lazbuild
70-
echo "$LAZARUS_DIR/lazbuild --primary-config-path=$LAZARUS_DIR --lazarusdir=$LAZARUS_DIR \$*" > ${RUNNER_TEMP}/lazbuild
71-
chmod +x ${RUNNER_TEMP}/lazbuild
72-
# Add lazbuild to the PATH variable. So it can be used in the next steps.
73-
echo ${RUNNER_TEMP} >> $GITHUB_PATH
74-
shell: bash
75-
76-
- name: Build trackereditor app for Apple silicon (aarch64)
77-
run: |
78-
lazbuild --build-all --build-mode=Release --widgetset=cocoa --cpu=aarch64 ${{ env.PROJECT_LPI }}
73+
lazbuild --build-all --build-mode=Release --widgetset=cocoa --cpu=${{ matrix.ARCH }} ${{ env.PROJECT_LPI }}
7974
shell: bash
8075

8176
- name: Test App SSL connection
8277
run: open "${{ env.PROGRAM_NAME_WITH_PATH }}" --args -TEST_SSL
8378
shell: bash
8479

85-
- name: Set correct version number in macOS .app bundle Info.plist from metainfo xml file
86-
env:
87-
METAINFO_FILE: metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.metainfo.xml
88-
run: |
89-
TRACKER_EDITOR_VERSION=$(xmllint --xpath "string(/component/releases/release[1]/@version)" $METAINFO_FILE)
90-
echo Program version: $TRACKER_EDITOR_VERSION
91-
plutil -replace CFBundleShortVersionString -string $TRACKER_EDITOR_VERSION ${{ env.MACOS_APP }}/Contents/Info.plist
92-
shell: bash
93-
94-
- name: Create and set app icon in macOS .app bundle
95-
env:
96-
ICON_FILE: 'metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.png'
97-
run: |
98-
99-
# ------ Create icon set and move it into the app
100-
iconset_folder="temp_folder.iconset"
101-
rm -rf "${iconset_folder}"
102-
mkdir -p "${iconset_folder}"
103-
104-
for s in 16 32 128 256 512; do
105-
d=$(($s*2))
106-
sips -Z $s $ICON_FILE --out "${iconset_folder}/icon_${s}x$s.png"
107-
sips -Z $d $ICON_FILE --out "${iconset_folder}/icon_${s}[email protected]"
108-
done
109-
110-
# create .icns icon file
111-
iconutil -c icns "${iconset_folder}" -o "iconfile.icns"
112-
rm -r "${iconset_folder}"
113-
114-
# move icon file to the app
115-
mv -f "iconfile.icns" "${{ env.MACOS_APP }}/Contents/Resources"
116-
117-
# add icon to plist xml file CFBundleIconFile = "iconfile"
118-
plutil -insert CFBundleIconFile -string "iconfile" "${{ env.MACOS_APP }}/Contents/Info.plist"
119-
shell: bash
120-
12180
- name: Zip the macOS .app bundle for artifact upload
81+
if: matrix.ARCH == 'aarch64'
12282
run: ditto -c -k enduser/trackereditor.app enduser/trackereditor_app.zip
12383
shell: bash
12484

12585
- name: Rename built -aarch64 binary for artifact upload
12686
run: |
127-
mv ${{ env.PROGRAM_NAME_WITH_PATH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-aarch64
128-
ditto -c -k ${{ env.PROGRAM_NAME_WITH_PATH }}-aarch64 ${{ env.PROGRAM_NAME_WITH_PATH }}-aarch64.zip
87+
mv ${{ env.PROGRAM_NAME_WITH_PATH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-${{ matrix.ARCH }}
88+
ditto -c -k ${{ env.PROGRAM_NAME_WITH_PATH }}-${{ matrix.ARCH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-${{ matrix.ARCH }}.zip
12989
shell: bash
13090

13191
- name: Upload Artifact.
13292
uses: actions/upload-artifact@v6
13393
with:
134-
name: artifact-aarch64
94+
name: artifact-${{ matrix.ARCH }}
13595
# Include both the zipped universal app bundle and the aarch64 binary zip
13696
path: enduser/*.zip
13797
if-no-files-found: error
13898

139-
build_x86_64: # Build for Intel Mac architecture
140-
runs-on: macos-15-intel
141-
timeout-minutes: 60
142-
steps:
143-
- uses: actions/checkout@v6
144-
with:
145-
submodules: true
146-
147-
- name: Install Free Pascal Compiler (FPC) multi arch version for macOS x86_64 and aarch64
148-
run: brew install fpc
149-
shell: bash
150-
151-
- name: Download Lazarus source code into temp folder
152-
run: |
153-
#Download lazarus source code. Directory 'lazarus' will be created in the temp folder.
154-
cd ${RUNNER_TEMP}
155-
curl -L -O ${{ env.LAZARUS_URL_TAR_GZ }}
156-
tar -xzf *.tar.gz
157-
shell: bash
158-
159-
- name: Build lazbuild from Lazarus source code
160-
run: |
161-
# make lazbuild and put the link with extra parameter in the temp folder.
162-
LAZARUS_DIR=${RUNNER_TEMP}/lazarus
163-
cd "$LAZARUS_DIR"
164-
make lazbuild
165-
echo "$LAZARUS_DIR/lazbuild --primary-config-path=$LAZARUS_DIR --lazarusdir=$LAZARUS_DIR \$*" > ${RUNNER_TEMP}/lazbuild
166-
chmod +x ${RUNNER_TEMP}/lazbuild
167-
# Add lazbuild to the PATH variable. So it can be used in the next steps.
168-
echo ${RUNNER_TEMP} >> $GITHUB_PATH
169-
shell: bash
170-
171-
- name: Build trackereditor app for Intel Mac version (x86_64)
172-
run: |
173-
lazbuild --build-all --build-mode=Release --widgetset=cocoa --cpu=x86_64 ${{ env.PROJECT_LPI }}
174-
shell: bash
175-
176-
- name: Test App SSL connection
177-
run: open "${{ env.PROGRAM_NAME_WITH_PATH }}" --args -TEST_SSL
178-
shell: bash
179-
180-
- name: Rename built -x86_64 binary for artifact upload
181-
run: |
182-
mv ${{ env.PROGRAM_NAME_WITH_PATH }} ${{ env.PROGRAM_NAME_WITH_PATH }}-x86_64
183-
ditto -c -k ${{ env.PROGRAM_NAME_WITH_PATH }}-x86_64 ${{ env.PROGRAM_NAME_WITH_PATH }}-x86_64.zip
184-
shell: bash
185-
186-
- name: Upload Artifact.
187-
uses: actions/upload-artifact@v6
188-
with:
189-
name: artifact-x86_64
190-
path: enduser/*.zip
191-
if-no-files-found: error
192-
193-
19499
create_universal_macOS_binary: # Create Universal binary from aarch64 and x86_64 builds
100+
needs: build
195101
runs-on: macos-latest
196102
timeout-minutes: 60
197103

198-
needs:
199-
- build_aarch64
200-
- build_x86_64
201-
202104
steps:
105+
- uses: actions/checkout@v6
106+
with:
107+
sparse-checkout: metainfo
108+
203109
- name: Install create-dmg tool
204110
run: brew install create-dmg
205111
shell: bash
@@ -227,6 +133,42 @@ jobs:
227133
run: ls -R enduser/
228134
shell: bash
229135

136+
- name: Set correct version number in macOS .app bundle Info.plist from metainfo xml file
137+
env:
138+
METAINFO_FILE: metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.metainfo.xml
139+
run: |
140+
TRACKER_EDITOR_VERSION=$(xmllint --xpath "string(/component/releases/release[1]/@version)" $METAINFO_FILE)
141+
echo Program version: $TRACKER_EDITOR_VERSION
142+
plutil -replace CFBundleShortVersionString -string $TRACKER_EDITOR_VERSION ${{ env.MACOS_APP }}/Contents/Info.plist
143+
shell: bash
144+
145+
- name: Create and set app icon in macOS .app bundle
146+
env:
147+
ICON_FILE: 'metainfo/io.github.gerryferdinandus.bittorrent-tracker-editor.png'
148+
run: |
149+
150+
# ------ Create icon set and move it into the app
151+
iconset_folder="temp_folder.iconset"
152+
rm -rf "${iconset_folder}"
153+
mkdir -p "${iconset_folder}"
154+
155+
for s in 16 32 128 256 512; do
156+
d=$(($s*2))
157+
sips -Z $s $ICON_FILE --out "${iconset_folder}/icon_${s}x$s.png"
158+
sips -Z $d $ICON_FILE --out "${iconset_folder}/icon_${s}[email protected]"
159+
done
160+
161+
# create .icns icon file
162+
iconutil -c icns "${iconset_folder}" -o "iconfile.icns"
163+
rm -r "${iconset_folder}"
164+
165+
# move icon file to the app
166+
mv -f "iconfile.icns" "${{ env.MACOS_APP }}/Contents/Resources"
167+
168+
# add icon to plist xml file CFBundleIconFile = "iconfile"
169+
plutil -insert CFBundleIconFile -string "iconfile" "${{ env.MACOS_APP }}/Contents/Info.plist"
170+
shell: bash
171+
230172
- name: Create a Universal macOS binary from aarch64 and x86_64
231173
run: |
232174
# Create Universal binary using lipo tool

.github/workflows/cicd_ubuntu.yaml

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
build:
1616
timeout-minutes: 60
1717

18-
env: # Use the latest Lazarus source code. Copied from: https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/
19-
LAZARUS_URL_TAR_GZ: "https://github.com/GerryFerdinandus/bittorrent-tracker-editor/releases/download/V1.32.0/lazarus.tar.gz"
20-
2118
strategy:
2219
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
2320
fail-fast: false
@@ -64,25 +61,15 @@ jobs:
6461
with:
6562
submodules: true
6663

64+
- name: Install Lazarus IDE
65+
uses: ./.github/actions/install_lazarus
66+
with:
67+
qt_version_ci: ${{ matrix.QT_VERSION_CI }}
68+
6769
- name: Install dependency for all build
6870
run: |
6971
sudo apt-get update
70-
sudo apt-get install -y fpc xvfb
71-
shell: bash
72-
73-
- name: Install dependency for gtk2
74-
if: matrix.QT_VERSION_CI == ''
75-
run: sudo apt-get install -y libgtk2.0-dev
76-
shell: bash
77-
78-
- name: Install dependency for qt5
79-
if: matrix.QT_VERSION_CI == '5'
80-
run: sudo apt-get install -y libqt5x11extras5-dev
81-
shell: bash
82-
83-
- name: Install dependency for qt6
84-
if: matrix.QT_VERSION_CI == '6'
85-
run: sudo apt-get install -y qt6-base-dev
72+
sudo apt-get install -y xvfb
8673
shell: bash
8774

8875
- name: Install dependency for AppImage
@@ -97,35 +84,6 @@ jobs:
9784
chmod +x linuxdeploy-*.AppImage
9885
shell: bash
9986

100-
- name: Download Lazarus source code into temp folder
101-
run: |
102-
#Download lazarus source code. Directory 'lazarus' will be created in the temp folder.
103-
cd ${RUNNER_TEMP}
104-
curl -L -O ${{ env.LAZARUS_URL_TAR_GZ }}
105-
tar -xzf *.tar.gz
106-
shell: bash
107-
108-
- name: Build libQTpas.so
109-
if: matrix.QT_VERSION_CI != ''
110-
run: |
111-
cd "${RUNNER_TEMP}/lazarus/lcl/interfaces/qt${{ matrix.QT_VERSION_CI }}/cbindings/"
112-
/usr/lib/qt${{ matrix.QT_VERSION_CI }}/bin/qmake
113-
make -j$(nproc)
114-
sudo make install
115-
shell: bash
116-
117-
- name: Build lazbuild from Lazarus source code
118-
run: |
119-
# make lazbuild and put the link with extra parameter in the temp folder.
120-
LAZARUS_DIR=${RUNNER_TEMP}/lazarus
121-
cd "$LAZARUS_DIR"
122-
make lazbuild
123-
echo "$LAZARUS_DIR/lazbuild --primary-config-path=$LAZARUS_DIR --lazarusdir=$LAZARUS_DIR \$*" > ${RUNNER_TEMP}/lazbuild
124-
chmod +x ${RUNNER_TEMP}/lazbuild
125-
# Add lazbuild to the PATH variable. So it can be used in the next steps.
126-
echo ${RUNNER_TEMP} >> $GITHUB_PATH
127-
shell: bash
128-
12987
- name: Build trackereditor
13088
# Build trackereditor project (Release mode)
13189
run: lazbuild --build-all --build-mode=Release ${{ matrix.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi

.github/workflows/cicd_windows.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
build:
16-
runs-on: windows-2025
16+
runs-on: windows-latest
1717
timeout-minutes: 60
1818
env:
1919
LAZBUILD_WITH_PATH: c:/lazarus/lazbuild
@@ -26,7 +26,7 @@ jobs:
2626
submodules: true
2727

2828
- name: Install Lazarus IDE
29-
run: winget install lazarus --disable-interactivity --accept-source-agreements --silent
29+
uses: ./.github/actions/install_lazarus
3030

3131
- name: Download OpenSSL *.dll
3232
run: |

0 commit comments

Comments
 (0)