Skip to content

Commit

Permalink
fixup! release: add Mac OSX installer build
Browse files Browse the repository at this point in the history
This prepares the `macos-installer` code for building on Apple Silicon.

The paths and a couple of flags need to be slightly different, but
nothing big.

The changes to the `build-git-installers` workflow:

- The keen reader will notice that `CFLAGS` & friends had to be moved
  from environment variables (which the ARM64 `make` apparently ignores)
  to `config.mak`.

- A couple of jobs needed to be turned into matrix jobs to handle both
  x86_64 and arm64 CPU architectures.

- Accommodate for Homebrew being installed into `/opt/homebrew` on Apple
  Silicon instead of `/usr/local`, with the `bin` directory of the
  former _overriding_ the latter.

- Homebrew on Apple Silicon apparently does not link `gcc` anymore, so
  let's just hard-code `gcc-13` for now.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Sep 22, 2023
1 parent f7a0ac0 commit 7df3458
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 27 deletions.
19 changes: 15 additions & 4 deletions .github/macos-installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ LD_LIBRARY_PATH := /usr/lib
OSX_VERSION := $(shell sw_vers -productVersion)
TARGET_FLAGS := -mmacosx-version-min=$(OSX_VERSION) -DMACOSX_DEPLOYMENT_TARGET=$(OSX_VERSION)

ARCH := x86_64
ARCH_CODE := x86_64
ARCH_FLAGS_x86_64 := -arch x86_64
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')

ifeq ($(uname_M),x86_64)
ARCH := x86_64
ARCH_CODE := x86_64
ARCH_FLAGS_x86_64 := -arch x86_64
CPU_VENDOR := Intel
endif
ifeq ($(uname_M),arm64)
ARCH := arm64
ARCH_CODE := arm64
ARCH_FLAGS_arm64 := -arch arm64
CPU_VENDOR := Apple Silicon
endif

CFLAGS := $(TARGET_FLAGS) $(ARCH_FLAGS_${ARCH_CODE})
LDFLAGS := $(TARGET_FLAGS) $(ARCH_FLAGS_${ARCH_CODE})
Expand Down Expand Up @@ -105,7 +116,7 @@ disk-image/git-$(VERSION)-$(BUILD_CODE).pkg: disk-image/VERSION-$(VERSION)-$(ARC
pkgbuild --identifier com.git.pkg --version $(VERSION) --root $(ARTIFACTDIR)$(PREFIX) --scripts assets/scripts --install-location $(PREFIX) --component-plist ./assets/git-components.plist disk-image/git-$(VERSION)-$(BUILD_CODE).pkg

git-%-$(BUILD_CODE).dmg:
hdiutil create git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg -fs HFS+ -srcfolder disk-image -volname "Git $(VERSION) Intel $(ARCH)" -ov
hdiutil create git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg -fs HFS+ -srcfolder disk-image -volname "Git $(VERSION) $(CPU_VENDOR) $(ARCH)" -ov
hdiutil convert -format UDZO -o $@ git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg
rm -f git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg

Expand Down
100 changes: 77 additions & 23 deletions .github/workflows/build-git-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,16 @@ jobs:

# Build and sign Mac OSX installers & upload artifacts
osx_build:
runs-on: macos-latest
strategy:
matrix:
arch:
- name: x86_64
runner: macos-latest
- name: arm64
runner: macos-latest-xl-arm64
runs-on: ${{ matrix.arch.runner }}
needs: prereqs
env:
# `gettext` is keg-only
LDFLAGS: -L/usr/local/opt/gettext/lib
CFLAGS: -I/usr/local/opt/gettext/include
# To make use of the catalogs...
XML_CATALOG_FILES: /usr/local/etc/xml/catalog
VERSION: "${{ needs.prereqs.outputs.tag_version }}"
steps:
- name: Check out repository
Expand Down Expand Up @@ -345,6 +347,21 @@ jobs:
# Write to "version" file to force match with trigger payload version
echo "${{ needs.prereqs.outputs.tag_version }}" >>git/version
# Configure the Git build to pick up gettext
homebrew_prefix="$(brew --prefix)"
cat >git/config.mak <<EOF
LDFLAGS = -L$homebrew_prefix/lib -L/usr/local/opt/gettext/lib
CFLAGS = -I$homebrew_prefix/include -I/usr/local/opt/gettext/include
EOF
# On Apple Silicon, homebrew apparently does not install a `gcc` symlink
test x86_64 = '${{ matrix.arch.name }}' ||
echo 'CC = gcc-13' >>config.mak
# To make use of the catalogs...
export XML_CATALOG_FILES=$homebrew_prefix/etc/xml/catalog
make -C git -j$(sysctl -n hw.physicalcpu) GIT-VERSION-FILE dist dist-doc
export GIT_BUILT_FROM_COMMIT=$(gunzip -c git/git-$VERSION.tar.gz | git get-tar-commit-id) ||
Expand All @@ -362,7 +379,7 @@ jobs:
# environment variable or the tag_version output from the prereqs
# job in the upload-artifact task.
mkdir -p build_artifacts
cp -R stage/git-x86_64-$VERSION/ build_artifacts
cp -R stage/git-${{ matrix.arch.name }}-$VERSION/ build_artifacts
# We keep a list of executable files because their executable bits are
# removed when they are zipped, and we need to re-add.
Expand All @@ -371,7 +388,7 @@ jobs:
- name: Upload macOS artifacts
uses: actions/upload-artifact@v3
with:
name: tmp.osx-build
name: tmp.osx-${{ matrix.arch.name }}-build
path: |
build_artifacts
Expand All @@ -387,6 +404,9 @@ jobs:
runs-on: windows-latest
environment: release
needs: osx_build
strategy:
matrix:
arch: [x86_64, arm64]
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -396,7 +416,7 @@ jobs:
- name: Download unsigned build artifacts
uses: actions/download-artifact@v3
with:
name: tmp.osx-build
name: tmp.osx-${{ matrix.arch }}-build
path: build_artifacts

- name: Zip unsigned build artifacts
Expand Down Expand Up @@ -439,12 +459,19 @@ jobs:
- name: Upload signed payload
uses: actions/upload-artifact@v3
with:
name: osx-signed-payload
name: osx-signed-${{ matrix.arch }}-payload
path: |
signed
osx_pack:
runs-on: macos-latest
strategy:
matrix:
arch:
- name: x86_64
runner: macos-latest
- name: arm64
runner: macos-latest-xl-arm64
runs-on: ${{ matrix.arch.runner }}
needs: [prereqs, osx_sign_payload]
steps:
- name: Check out repository
Expand All @@ -455,7 +482,7 @@ jobs:
- name: Download signed artifacts
uses: actions/download-artifact@v3
with:
name: osx-signed-payload
name: osx-signed-${{ matrix.arch.name }}-payload

- name: Download list of executable files
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -493,11 +520,14 @@ jobs:
- name: Upload unsigned pkg
uses: actions/upload-artifact@v3
with:
name: tmp.osx-pkg
name: tmp.osx-${{ matrix.arch.name }}-pkg
path: |
git/.github/macos-installer/disk-image
osx_sign_and_notarize_pkg:
strategy:
matrix:
arch: [x86_64, arm64]
# ESRP service requires signing to run on Windows
runs-on: windows-latest
environment: release
Expand All @@ -511,7 +541,7 @@ jobs:
- name: Download unsigned package
uses: actions/download-artifact@v3
with:
name: tmp.osx-pkg
name: tmp.osx-${{ matrix.arch }}-pkg
path: pkg

- name: Zip unsigned package
Expand Down Expand Up @@ -563,12 +593,19 @@ jobs:
- name: Upload signed and notarized pkg
uses: actions/upload-artifact@v3
with:
name: osx-signed-pkg
name: osx-signed-${{ matrix.arch }}-pkg
path: |
signed
osx_publish_dmg:
runs-on: macos-latest
strategy:
matrix:
arch:
- name: x86_64
runner: macos-latest
- name: arm64
runner: macos-latest-xl-arm64
runs-on: ${{ matrix.arch.runner }}
needs: [prereqs, osx_sign_and_notarize_pkg]
steps:
- name: Check out repository
Expand All @@ -579,7 +616,7 @@ jobs:
- name: Download signed package
uses: actions/download-artifact@v3
with:
name: osx-signed-pkg
name: osx-signed-${{ matrix.arch.name }}-pkg
path: disk-image

- name: Build macOS disk image
Expand All @@ -602,7 +639,7 @@ jobs:
- name: Publish disk image
uses: actions/upload-artifact@v3
with:
name: osx-dmg
name: osx-${{ matrix.arch.name }}-dmg
path: git/.github/macos-installer/*.dmg
# End build and sign Mac OSX installers

Expand Down Expand Up @@ -734,8 +771,11 @@ jobs:
- os: ubuntu-latest
artifact: deb-package-signed
command: git
- os: macos-latest-xl-arm64
artifact: osx-signed-arm64-pkg
command: git
- os: macos-latest
artifact: osx-signed-pkg
artifact: osx-signed-x86_64-pkg
command: git
- os: windows-latest
artifact: win-installer-x86_64
Expand Down Expand Up @@ -764,6 +804,10 @@ jobs:
- name: Install macOS
if: contains(matrix.component.os, 'macos')
run: |
# avoid letting Homebrew's `git` in `/opt/homebrew/bin` override `/usr/local/bin/git`
test arm64 != "$(uname -m)" ||
brew uninstall git
pkgpath=$(find ./*.pkg)
sudo installer -pkg $pkgpath -target /
Expand Down Expand Up @@ -794,15 +838,25 @@ jobs:
with:
name: win-installer-x86_64
path: win-installer-x86_64
- name: Download Mac dmg
- name: Download Mac x86_64 dmg
uses: actions/download-artifact@v3
with:
name: osx-dmg
name: osx-x86_64-dmg
path: osx-dmg
- name: Download Mac pkg
- name: Download Mac ARM64 dmg
uses: actions/download-artifact@v3
with:
name: osx-arm64-dmg
path: osx-dmg
- name: Download Mac x86_64 pkg
uses: actions/download-artifact@v3
with:
name: osx-signed-x86_64-pkg
path: osx-pkg
- name: Download Mac ARM64 pkg
uses: actions/download-artifact@v3
with:
name: osx-signed-pkg
name: osx-signed-arm64-pkg
path: osx-pkg
- name: Download Ubuntu package (signed)
if: needs.prereqs.outputs.deb_signable == 'true'
Expand Down

0 comments on commit 7df3458

Please sign in to comment.