-
Notifications
You must be signed in to change notification settings - Fork 1
268 lines (242 loc) · 10.6 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
on:
push:
pull_request:
name: CI
# Note: Windows ARM64 builds are currently disabled as GTK4 and its dependencies
# are not yet available for this platform in vcpkg
jobs:
flatpak:
name: "Flatpak"
runs-on: ubuntu-24.04
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-47
options: --privileged
strategy:
matrix:
arch: [x86_64, aarch64]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install deps
if: ${{ matrix.arch != 'x86_64' }}
run: |
dnf -y install docker
- name: Set up QEMU
if: ${{ matrix.arch != 'x86_64' }}
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: aardvark.flatpak
manifest-path: org.p2panda.aardvark.json
cache-key: flatpak-builder-${{ hashFiles('org.p2panda.aardvark.json') }}-${{ matrix.arch }}
arch: ${{ matrix.arch }}
macos:
name: "macOS"
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
arch: x86_64
- target: aarch64-apple-darwin
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
# Cache Homebrew packages
- uses: actions/cache@v4
with:
path: |
~/Library/Caches/Homebrew
/usr/local/Homebrew
/opt/homebrew
key: ${{ runner.os }}-${{ matrix.arch }}-brew-${{ hashFiles('.github/workflows/build.yml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-brew-
- name: Setup x86_64 Homebrew
if: matrix.arch == 'x86_64'
run: |
HOMEBREW_PREFIX="/usr/local"
sudo mkdir -p /usr/local
sudo chown -R $(whoami) /usr/local
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/usr/local/bin/brew shellenv)"
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/opt/pango/lib/pkgconfig:/usr/local/opt/cairo/lib/pkgconfig:/usr/local/opt/gdk-pixbuf/lib/pkgconfig:/usr/local/opt/graphene/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/gtk4/lib/pkgconfig:/usr/local/opt/libadwaita/lib/pkgconfig" >> $GITHUB_ENV
- name: Install pkg-config (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install pkg-config || echo ERROR
- name: Install GDK-Pixbuf (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install gdk-pixbuf || echo ERROR
- name: Install Cairo (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install cairo || echo ERROR
- name: Install Pango (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install pango || echo ERROR
- name: Install AT-SPI2-Core (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install at-spi2-core || echo ERROR
- name: Install Graphene (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install graphene || echo ERROR
- name: Install GTK4 (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install gtk4 || echo ERROR
- name: Install Libadwaita (x86_64)
if: matrix.arch == 'x86_64'
run: arch -x86_64 /usr/local/bin/brew install -v libadwaita
- name: Verify and link x86_64 packages
if: matrix.arch == 'x86_64'
run: |
# Verify installations
arch -x86_64 /usr/local/bin/brew list pango
arch -x86_64 /usr/local/bin/brew list cairo
arch -x86_64 /usr/local/bin/brew list gdk-pixbuf
arch -x86_64 /usr/local/bin/brew list gtk4
arch -x86_64 /usr/local/bin/brew list libadwaita
# Link packages individually with error handling
for package in pango cairo gdk-pixbuf gtk4 libadwaita; do
arch -x86_64 /usr/local/bin/brew link --force $package || true
done
- name: Install ARM64 dependencies
if: matrix.arch == 'arm64'
run: |
brew install pkg-config gtk4 pango cairo gdk-pixbuf at-spi2-core graphene libadwaita || true
brew upgrade pkg-config gtk4 pango cairo gdk-pixbuf at-spi2-core graphene libadwaita || true
- name: Finalize ARM64 setup
if: matrix.arch == 'arm64'
run: |
echo "PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: Add target ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
- name: Build
env:
PKG_CONFIG_ALLOW_CROSS: "1"
CFLAGS: "-I/usr/local/include -I/usr/local/include/gtk-4.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include"
LDFLAGS: "-L/usr/local/lib -framework Cocoa -framework Security"
MACOSX_DEPLOYMENT_TARGET: "10.15"
PKG_CONFIG_SYSROOT_DIR: ""
PKG_CONFIG_PATH: "${{ env.PKG_CONFIG_PATH }}"
run: cargo build --release --target ${{ matrix.target }}
- name: Create App Bundle
run: |
mkdir -p Aardvark.app/Contents/MacOS
cp target/${{ matrix.target }}/release/aardvark Aardvark.app/Contents/MacOS/
# Create Info.plist - you'll need to customize this
cat > Aardvark.app/Contents/Info.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>aardvark</string>
<key>CFBundleIdentifier</key>
<string>org.p2panda.aardvark</string>
<key>CFBundleName</key>
<string>Aardvark</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
</dict>
</plist>
EOF
- name: Create DMG
run: |
hdiutil create -volname "Aardvark" -srcfolder Aardvark.app -ov -format UDZO aardvark-${{ matrix.arch }}.dmg
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: aardvark-macos-${{ matrix.arch }}
path: aardvark-${{ matrix.arch }}.dmg
windows:
name: "Windows"
runs-on: windows-latest
# Only build for x64 since GTK4 is not available for Windows ARM64 yet
strategy:
fail-fast: false
matrix:
arch: [x64]
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
- name: Install target
if: matrix.arch == 'arm64'
run: rustup target add aarch64-pc-windows-msvc
- name: Setup Windows build variables
run: |
$arch = "${{ matrix.arch }}"
$triplet = if ($arch -eq "x64") { "x64-windows" } else { "arm64-windows" }
echo "VCPKG_TRIPLET=$triplet" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "VCPKG_ROOT=C:\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
# Cache vcpkg packages
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: |
C:\vcpkg\installed
C:\vcpkg\packages
key: vcpkg-${{ matrix.arch }}-${{ hashFiles('**/vcpkg.json', '.github/workflows/install_vcpkg.ps1') }}
restore-keys: |
vcpkg-${{ matrix.arch }}-
- name: Install GTK4 and dependencies
run: . .\.github\workflows\install_vcpkg.ps1
shell: pwsh
- name: Configure pkg-config paths
run: |
$installPrefix = "$env:VCPKG_ROOT\installed\$env:VCPKG_TRIPLET"
# Set up pkg-config environment
$env:PKG_CONFIG = "$installPrefix\tools\pkgconf\pkg-config.ps1"
$env:PKG_CONFIG_PATH = "$installPrefix\lib\pkgconfig"
$env:PKG_CONFIG_LIBDIR = "$installPrefix\lib\pkgconfig"
$env:PKG_CONFIG_ALLOW_CROSS = "1"
$env:PKG_CONFIG_ALLOW_SYSTEM_CFLAGS = "1"
$env:PKG_CONFIG_ALLOW_SYSTEM_LIBS = "1"
# Add required paths to system PATH
$env:Path = "$installPrefix\bin;$installPrefix\tools\pkgconf;$env:Path"
# Export variables to GITHUB_ENV
"PKG_CONFIG=$env:PKG_CONFIG" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"PKG_CONFIG_PATH=$env:PKG_CONFIG_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"PKG_CONFIG_LIBDIR=$env:PKG_CONFIG_LIBDIR" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"PKG_CONFIG_ALLOW_CROSS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"PKG_CONFIG_ALLOW_SYSTEM_LIBS=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Add to PATH for subsequent steps
"$installPrefix\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$installPrefix\tools\pkgconf" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: Verify pkg-config setup
run: |
Write-Host "Verifying pkg-config installation..."
pkg-config --version
Write-Host "Checking library configurations..."
pkg-config --debug --print-errors --cflags --libs glib-2.0
pkg-config --debug --print-errors --cflags --libs gtk4 libadwaita-1
shell: pwsh
- name: Build
run: |
$arch = "${{ matrix.arch }}"
$target = if ($arch -eq "x64") { "x86_64-pc-windows-msvc" } else { "aarch64-pc-windows-msvc" }
cargo build --release --target $target
shell: pwsh
- name: Package
run: |
mkdir aardvark-${{ matrix.arch }}
copy target/${{ matrix.arch == 'x64' && 'x86_64-pc-windows-msvc' || 'aarch64-pc-windows-msvc' }}/release/aardvark.exe aardvark-${{ matrix.arch }}/
# Add any additional DLLs or resources here
- name: Create ZIP
run: Compress-Archive -Path aardvark-${{ matrix.arch }} -DestinationPath aardvark-windows-${{ matrix.arch }}.zip
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: aardvark-windows-${{ matrix.arch }}
path: aardvark-windows-${{ matrix.arch }}.zip