Skip to content

Commit

Permalink
macos: update macos installer to create universal binaries
Browse files Browse the repository at this point in the history
Update macos workflow to create universal DMG and PKG releases.

Signed-off-by: Jeff Hostetler <[email protected]>
  • Loading branch information
jeffhostetler committed Oct 24, 2023
1 parent 089d87d commit 1d512b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 61 deletions.
28 changes: 7 additions & 21 deletions .github/macos-installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@ 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 := universal
ARCH_CODE := 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
Expand Down Expand Up @@ -98,13 +89,8 @@ $(BUILD_DIR)/git-$(VERSION)/osx-installed: $(DESTDIR)$(GIT_PREFIX)/VERSION-$(VER
touch $@

$(BUILD_DIR)/git-$(VERSION)/osx-built-assert-$(ARCH_CODE): $(BUILD_DIR)/git-$(VERSION)/osx-built
ifeq ("$(ARCH_CODE)", "universal")
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):
Expand All @@ -116,7 +102,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) $(CPU_VENDOR) $(ARCH)" -ov
hdiutil create git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg -fs HFS+ -srcfolder disk-image -volname "Git $(VERSION) $(ARCH)" -ov
hdiutil convert -format UDZO -o $@ git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg
rm -f git-$(VERSION)-$(BUILD_CODE).uncompressed.dmg

Expand Down
57 changes: 17 additions & 40 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 @@ -347,10 +345,6 @@ jobs:
# Write to "version" file to force match with trigger payload version
echo "${{ needs.prereqs.outputs.tag_version }}" >>git/version
# 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...
homebrew_prefix="$(brew --prefix)"
export XML_CATALOG_FILES=$homebrew_prefix/etc/xml/catalog
Expand All @@ -372,7 +366,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 @@ -381,7 +375,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 All @@ -399,7 +393,7 @@ jobs:
needs: osx_build
strategy:
matrix:
arch: [x86_64, arm64]
arch: [arm64]
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -409,7 +403,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 @@ -452,16 +446,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 @@ -475,7 +467,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 @@ -513,14 +505,14 @@ jobs:
- name: Upload unsigned pkg
uses: actions/upload-artifact@v3
with:
name: tmp.osx-${{ matrix.arch.name }}-pkg
name: tmp.osx-universal-pkg
path: |
git/.github/macos-installer/disk-image
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 @@ -534,7 +526,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 @@ -586,16 +578,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 @@ -609,7 +599,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 @@ -632,7 +622,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 @@ -765,10 +755,7 @@ jobs:
artifact: deb-package-signed
command: git
- os: macos-latest-xl-arm64
artifact: osx-signed-arm64-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 @@ -831,25 +818,15 @@ jobs:
with:
name: win-installer-x86_64
path: win-installer-x86_64
- name: Download Mac x86_64 dmg
uses: actions/download-artifact@v3
with:
name: osx-x86_64-dmg
path: osx-dmg
- name: Download Mac ARM64 dmg
- name: Download Mac universal dmg
uses: actions/download-artifact@v3
with:
name: osx-arm64-dmg
name: osx-universal-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 1d512b1

Please sign in to comment.