build-binary.yml 3.3 KB

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