Skip to content

Commit b2d92d3

Browse files
Merge pull request #9065 from ThomasWaldmann/build-binaries-on-gh-1.4
ci: add GitHub Actions workflow for building binaries on macOS
2 parents f9b23ca + 116c2ee commit b2d92d3

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

.github/workflows/build-binary.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build binaries
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.py'
7+
- '**.pyx'
8+
- '**.c'
9+
- '**.h'
10+
- '**.yml'
11+
- '**.toml'
12+
- '**.cfg'
13+
- '**.ini'
14+
- 'requirements.d/*'
15+
- 'scripts/**'
16+
pull_request:
17+
paths:
18+
- '**.py'
19+
- '**.pyx'
20+
- '**.c'
21+
- '**.h'
22+
- '**.yml'
23+
- '**.toml'
24+
- '**.cfg'
25+
- '**.ini'
26+
- 'requirements.d/*'
27+
- 'scripts/**'
28+
workflow_dispatch:
29+
30+
jobs:
31+
build-binary-macos:
32+
name: Build (macOS ${{ matrix.os }} / ${{ runner.arch }})
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
os: [macos-12, macos-14]
37+
runs-on: ${{ matrix.os }}
38+
timeout-minutes: 60
39+
40+
env:
41+
# Support both Homebrew locations (Intel and Apple Silicon)
42+
PKG_CONFIG_PATH: "/opt/homebrew/opt/[email protected]/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig:$PKG_CONFIG_PATH"
43+
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
with:
48+
# Just fetching one commit is not enough for setuptools-scm, so we fetch all
49+
fetch-depth: 0
50+
51+
- name: Set up Python 3.11
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.11'
55+
56+
- name: Cache pip
57+
uses: actions/cache@v4
58+
with:
59+
path: ~/.cache/pip
60+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.txt') }}
61+
restore-keys: |
62+
${{ runner.os }}-pip-
63+
${{ runner.os }}-
64+
65+
- name: Install macOS packages via Homebrew (see Brewfile)
66+
run: |
67+
brew bundle install
68+
69+
- name: Install Python requirements
70+
run: |
71+
python -m pip install --upgrade pip setuptools wheel
72+
pip install -r requirements.d/development.txt
73+
74+
- name: Build Borg to compile extensions
75+
env:
76+
# Set both paths again to be sure nothing overrides them
77+
PKG_CONFIG_PATH: "/opt/homebrew/opt/[email protected]/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig:${{ env.PKG_CONFIG_PATH }}"
78+
run: |
79+
pip install -ve .
80+
81+
- name: Build PyInstaller single-file binary
82+
run: |
83+
python -m pip install 'pyinstaller==6.7.0'
84+
mkdir -p dist/binary
85+
pyinstaller --clean --distpath=dist/binary scripts/borg.exe.spec
86+
pushd dist/binary
87+
tar -czvf borg.tgz borg-dir
88+
rm -rf borg-dir
89+
popd
90+
91+
- name: Smoke-test the built binary (borg -V)
92+
run: |
93+
pushd dist/binary
94+
ls -l
95+
# test single-file binary
96+
chmod +x borg.exe
97+
./borg.exe -V
98+
# test single-dir binary
99+
tar -xzvf borg.tgz
100+
chmod +x borg-dir/borg.exe
101+
./borg-dir/borg.exe -V
102+
popd
103+
104+
- name: Prepare artifacts
105+
run: |
106+
mkdir -p artifacts
107+
if [ -f dist/binary/borg.exe ]; then
108+
cp dist/binary/borg.exe artifacts/borg-${{ matrix.os }}-${{ runner.arch }}
109+
fi
110+
if [ -f dist/binary/borg.tgz ]; then
111+
cp dist/binary/borg.tgz artifacts/borg-dir-${{ matrix.os }}-${{ runner.arch }}.tgz
112+
fi
113+
114+
- name: Upload artifacts
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: borg-macos-${{ matrix.os }}-${{ runner.arch }}
118+
path: artifacts/*
119+
if-no-files-found: error

0 commit comments

Comments
 (0)