Skip to content

Commit

Permalink
macos installer: convert to universal builds
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
  • Loading branch information
jeffhostetler committed Oct 18, 2023
1 parent bf5d26b commit b5902e9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 79 deletions.
54 changes: 19 additions & 35 deletions .github/macos-installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,17 @@ TARGET_FLAGS := -mmacosx-version-min=$(OSX_VERSION) -DMACOSX_DEPLOYMENT_TARGET=$

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})
ARCH_UNIV := universal
ARCH_FLAGS := -arch x86_64 -arch arm64

CFLAGS := $(TARGET_FLAGS) $(ARCH_FLAGS)
LDFLAGS := $(TARGET_FLAGS) $(ARCH_FLAGS)

PREFIX := /usr/local
GIT_PREFIX := $(PREFIX)/git

BUILD_CODE := $(ARCH_CODE)
BUILD_DIR := $(GITHUB_WORKSPACE)/payload
DESTDIR := $(PWD)/stage/git-$(BUILD_CODE)-$(VERSION)
DESTDIR := $(PWD)/stage/git-$(ARCH_UNIV)-$(VERSION)
ARTIFACTDIR := build_artifacts
SUBMAKE := $(MAKE) C_INCLUDE_PATH="$(C_INCLUDE_PATH)" CPLUS_INCLUDE_PATH="$(CPLUS_INCLUDE_PATH)" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" TARGET_FLAGS="$(TARGET_FLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" NO_GETTEXT=1 NO_DARWIN_PORTS=1 prefix=$(GIT_PREFIX) GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" DESTDIR=$(DESTDIR)
CORES := $(shell bash -c "sysctl hw.ncpu | awk '{print \$$2}'")
Expand All @@ -39,7 +28,7 @@ CORES := $(shell bash -c "sysctl hw.ncpu | awk '{print \$$2}'")

.SECONDARY:

$(DESTDIR)$(GIT_PREFIX)/VERSION-$(VERSION)-$(BUILD_CODE):
$(DESTDIR)$(GIT_PREFIX)/VERSION-$(VERSION)-$(ARCH_UNIV):
rm -f $(BUILD_DIR)/git-$(VERSION)/osx-installed*
mkdir -p $(DESTDIR)$(GIT_PREFIX)
touch $@
Expand Down Expand Up @@ -92,36 +81,31 @@ symlinks:
ruby ../scripts/symlink-git-hardlinks.rb $(ARTIFACTDIR)
touch $@

$(BUILD_DIR)/git-$(VERSION)/osx-installed: $(DESTDIR)$(GIT_PREFIX)/VERSION-$(VERSION)-$(BUILD_CODE) $(BUILD_DIR)/git-$(VERSION)/osx-installed-man $(BUILD_DIR)/git-$(VERSION)/osx-installed-assets $(BUILD_DIR)/git-$(VERSION)/osx-installed-subtree
$(BUILD_DIR)/git-$(VERSION)/osx-installed: $(DESTDIR)$(GIT_PREFIX)/VERSION-$(VERSION)-$(ARCH_UNIV) $(BUILD_DIR)/git-$(VERSION)/osx-installed-man $(BUILD_DIR)/git-$(VERSION)/osx-installed-assets $(BUILD_DIR)/git-$(VERSION)/osx-installed-subtree
find $(DESTDIR)$(GIT_PREFIX) -type d -exec chmod ugo+rx {} \;
find $(DESTDIR)$(GIT_PREFIX) -type f -exec chmod ugo+r {} \;
touch $@

$(BUILD_DIR)/git-$(VERSION)/osx-built-assert-$(ARCH_CODE): $(BUILD_DIR)/git-$(VERSION)/osx-built
ifeq ("$(ARCH_CODE)", "universal")
$(BUILD_DIR)/git-$(VERSION)/osx-built-assert-$(ARCH_UNIV): $(BUILD_DIR)/git-$(VERSION)/osx-built
File $(BUILD_DIR)/git-$(VERSION)/git
File $(BUILD_DIR)/git-$(VERSION)/contrib/credential/osxkeychain/git-credential-osxkeychain
else
[ "$$(File $(BUILD_DIR)/git-$(VERSION)/git | cut -f 5 -d' ')" == "$(ARCH_CODE)" ]
[ "$$(File $(BUILD_DIR)/git-$(VERSION)/contrib/credential/osxkeychain/git-credential-osxkeychain | cut -f 5 -d' ')" == "$(ARCH_CODE)" ]
endif
touch $@

disk-image/VERSION-$(VERSION)-$(ARCH_CODE):
disk-image/VERSION-$(VERSION)-$(ARCH_UNIV):
rm -f disk-image/*.pkg disk-image/VERSION-* disk-image/.DS_Store
mkdir disk-image
touch "$@"

disk-image/git-$(VERSION)-$(BUILD_CODE).pkg: disk-image/VERSION-$(VERSION)-$(ARCH_CODE) symlinks
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
disk-image/git-$(VERSION)-$(ARCH_UNIV).pkg: disk-image/VERSION-$(VERSION)-$(ARCH_UNIV) symlinks
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)-$(ARCH_UNIV).pkg

git-%-$(BUILD_CODE).dmg:
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
git-%-$(ARCH_UNIV).dmg:
hdiutil create git-$(VERSION)-$(ARCH_UNIV).uncompressed.dmg -fs HFS+ -srcfolder disk-image -volname "Git $(VERSION) $(ARCH_UNIV)" -ov
hdiutil convert -format UDZO -o $@ git-$(VERSION)-$(ARCH_UNIV).uncompressed.dmg
rm -f git-$(VERSION)-$(ARCH_UNIV).uncompressed.dmg

payload: $(BUILD_DIR)/git-$(VERSION)/osx-installed $(BUILD_DIR)/git-$(VERSION)/osx-built-assert-$(ARCH_CODE)
payload: $(BUILD_DIR)/git-$(VERSION)/osx-installed $(BUILD_DIR)/git-$(VERSION)/osx-built-assert-$(ARCH_UNIV)

pkg: disk-image/git-$(VERSION)-$(BUILD_CODE).pkg
pkg: disk-image/git-$(VERSION)-$(ARCH_UNIV).pkg

image: git-$(VERSION)-$(BUILD_CODE).dmg
image: git-$(VERSION)-$(ARCH_UNIV).dmg
68 changes: 24 additions & 44 deletions .github/workflows/build-git-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ jobs:
strategy:
matrix:
arch:
- name: x86_64
runner: macos-latest
- name: arm64
runner: macos-latest-xl-arm64
runs-on: ${{ matrix.arch.runner }}
Expand Down Expand Up @@ -348,19 +346,15 @@ 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
# # 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

# To make use of the catalogs...
export XML_CATALOG_FILES=$homebrew_prefix/etc/xml/catalog
# # 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

Expand All @@ -379,7 +373,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-${{ matrix.arch.name }}-$VERSION/ build_artifacts
cp -R stage/git-universal-$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 @@ -388,7 +382,7 @@ jobs:
- name: Upload macOS artifacts
uses: actions/upload-artifact@v3
with:
name: tmp.osx-${{ matrix.arch.name }}-build
name: tmp.osx-universal-build
path: |
build_artifacts
Expand Down Expand Up @@ -416,7 +410,7 @@ jobs:
- name: Download unsigned build artifacts
uses: actions/download-artifact@v3
with:
name: tmp.osx-${{ matrix.arch }}-build
name: tmp.osx-universal-build
path: build_artifacts

- name: Zip unsigned build artifacts
Expand Down Expand Up @@ -459,16 +453,14 @@ jobs:
- name: Upload signed payload
uses: actions/upload-artifact@v3
with:
name: osx-signed-${{ matrix.arch }}-payload
name: osx-signed-universal-payload
path: |
signed
osx_pack:
strategy:
matrix:
arch:
- name: x86_64
runner: macos-latest
- name: arm64
runner: macos-latest-xl-arm64
runs-on: ${{ matrix.arch.runner }}
Expand All @@ -482,7 +474,7 @@ jobs:
- name: Download signed artifacts
uses: actions/download-artifact@v3
with:
name: osx-signed-${{ matrix.arch.name }}-payload
name: osx-signed-universal-payload

- name: Download list of executable files
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -527,7 +519,7 @@ jobs:
osx_sign_and_notarize_pkg:
strategy:
matrix:
arch: [x86_64, arm64]
arch: [arm64]
# ESRP service requires signing to run on Windows
runs-on: windows-latest
environment: release
Expand All @@ -541,7 +533,7 @@ jobs:
- name: Download unsigned package
uses: actions/download-artifact@v3
with:
name: tmp.osx-${{ matrix.arch }}-pkg
name: tmp.osx-universal-pkg
path: pkg

- name: Zip unsigned package
Expand Down Expand Up @@ -593,16 +585,14 @@ jobs:
- name: Upload signed and notarized pkg
uses: actions/upload-artifact@v3
with:
name: osx-signed-${{ matrix.arch }}-pkg
name: osx-signed-universal-pkg
path: |
signed
osx_publish_dmg:
strategy:
matrix:
arch:
- name: x86_64
runner: macos-latest
- name: arm64
runner: macos-latest-xl-arm64
runs-on: ${{ matrix.arch.runner }}
Expand All @@ -616,7 +606,7 @@ jobs:
- name: Download signed package
uses: actions/download-artifact@v3
with:
name: osx-signed-${{ matrix.arch.name }}-pkg
name: osx-signed-universal-pkg
path: disk-image

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

Expand Down Expand Up @@ -772,10 +762,10 @@ jobs:
artifact: deb-package-signed
command: git
- os: macos-latest-xl-arm64
artifact: osx-signed-arm64-pkg
artifact: osx-signed-universal-pkg
command: git
- os: macos-latest
artifact: osx-signed-x86_64-pkg
artifact: osx-signed-universal-pkg
command: git
- os: windows-latest
artifact: win-installer-x86_64
Expand Down Expand Up @@ -838,25 +828,15 @@ jobs:
with:
name: win-installer-x86_64
path: win-installer-x86_64
- name: Download Mac x86_64 dmg
- name: Download Mac universal dmg
uses: actions/download-artifact@v3
with:
name: osx-x86_64-dmg
name: osx-universal-dmg
path: osx-dmg
- 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
- name: Download Mac universal pkg
uses: actions/download-artifact@v3
with:
name: osx-signed-arm64-pkg
name: osx-signed-universal-pkg
path: osx-pkg
- name: Download Ubuntu package (signed)
if: needs.prereqs.outputs.deb_signable == 'true'
Expand Down

0 comments on commit b5902e9

Please sign in to comment.