From 429428e5d21aedcd83450484d791c22328918302 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Thu, 2 Dec 2021 10:11:41 -0500 Subject: [PATCH 1/3] dist: archive HEAD instead of HEAD^{tree} Update `git archive` tree-ish argument from `HEAD^{tree}` to `HEAD`. By using a commit (rather than tree) reference, the commit hash will be stored as an extended pax header, extractable git `git get-tar-commit-id`. The intended use-case for this change is building `git` from the output of `make dist` - in combination with the ability to specify a fallback `GIT_BUILT_FROM_COMMIT`, a user can extract the commit ID used to build the archive and set it as `GIT_BUILT_FROM_COMMIT`. The result is fully-populated information for the commit hash in `git version --build-options`. Signed-off-by: Victoria Dye --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bd1034b6f0a027..e01b6180404e7b 100644 --- a/Makefile +++ b/Makefile @@ -3706,7 +3706,7 @@ dist: git-archive$(X) configure @$(MAKE) -C git-gui TARDIR=../.dist-tmp-dir/git-gui dist-version ./git-archive --format=tar \ $(GIT_ARCHIVE_EXTRA_FILES) \ - --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar + --prefix=$(GIT_TARNAME)/ HEAD > $(GIT_TARNAME).tar @$(RM) -r .dist-tmp-dir gzip -f -9 $(GIT_TARNAME).tar From b7da19c4163968c967b2942e6e27fefff4e11097 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Thu, 2 Dec 2021 14:50:05 -0500 Subject: [PATCH 2/3] release: include GIT_BUILT_FROM_COMMIT in MacOS build Set the `GIT_BUILT_FROM_COMMIT` based on the version specified in the `make dist` output archive header. This ensures the commit hash is shown in `git version --build-options`. Signed-off-by: Victoria Dye --- .github/macos-installer/Makefile | 2 +- .github/workflows/build-git-installers.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/macos-installer/Makefile b/.github/macos-installer/Makefile index 3e1d60dcbeb2ef..1a06f6200e62dc 100644 --- a/.github/macos-installer/Makefile +++ b/.github/macos-installer/Makefile @@ -21,7 +21,7 @@ GIT_PREFIX := $(PREFIX)/git BUILD_DIR := $(GITHUB_WORKSPACE)/payload 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) DESTDIR=$(DESTDIR) +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}'") # Guard against environment variables diff --git a/.github/workflows/build-git-installers.yml b/.github/workflows/build-git-installers.yml index 8c890effb39309..4ce1f368c41da7 100644 --- a/.github/workflows/build-git-installers.yml +++ b/.github/workflows/build-git-installers.yml @@ -447,6 +447,9 @@ jobs: 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) || + die "Could not determine commit for build" + # Extract tarballs mkdir payload manpages tar -xvf git/git-$VERSION.tar.gz -C payload From fc4cf350d64d9648036bdc446d5cd2de9a5110d8 Mon Sep 17 00:00:00 2001 From: Lessley Dennington Date: Wed, 17 Aug 2022 10:58:25 -0700 Subject: [PATCH 3/3] release: add installer validation Add basic installer validation to release pipeline for Windows, macOS, and Linux (Debian package only). Validation runs the installers/any necessary setup and checks that the installed version matches the expected version. --- .github/workflows/build-git-installers.yml | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/.github/workflows/build-git-installers.yml b/.github/workflows/build-git-installers.yml index 4ce1f368c41da7..de13e7df7239eb 100644 --- a/.github/workflows/build-git-installers.yml +++ b/.github/workflows/build-git-installers.yml @@ -612,12 +612,83 @@ jobs: *.deb # End build and sign Debian package + # Validate installers + validate-installers: + name: Validate installers + strategy: + matrix: + component: + - os: ubuntu-latest + artifact: linux-artifacts + command: git + - os: macos-latest-xl-arm64 + artifact: macos-artifacts + command: git + - os: macos-latest + artifact: macos-artifacts + command: git + - os: windows-latest + artifact: win-installer-x86_64 + command: $PROGRAMFILES\Git\cmd\git.exe + - os: ['self-hosted', '1ES.Pool=github-arm64-pool'] + artifact: win-installer-aarch64 + command: $PROGRAMFILES\Git\cmd\git.exe + runs-on: ${{ matrix.component.os }} + needs: [prereqs, windows_artifacts, create-macos-artifacts, create-linux-artifacts] + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.component.artifact }} + + - name: Install Windows + if: contains(matrix.component.artifact, 'win-installer') + shell: pwsh + run: | + $exePath = Get-ChildItem -Path ./*.exe | %{$_.FullName} + Start-Process -Wait -FilePath "$exePath" -ArgumentList "/SILENT /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /ALLOWDOWNGRADE=1" + + - name: Install Linux + if: contains(matrix.component.artifact, 'linux') + run: | + debpath=$(find ./*.deb) + sudo apt install $debpath + + - name: Install macOS + if: contains(matrix.component.artifact, 'macos') + run: | + # avoid letting Homebrew's `git` in `/opt/homebrew/bin` override `/usr/local/bin/git` + arch="$(uname -m)" + test arm64 != "$arch" || + brew uninstall git + + pkgpath=$(find ./*universal*.pkg) + sudo installer -pkg $pkgpath -target / + + - name: Validate + shell: bash + run: | + "${{ matrix.component.command }}" --version | sed 's/git version //' >actual + echo ${{ needs.prereqs.outputs.tag_version }} >expect + cmp expect actual || exit 1 + + - name: Validate universal binary CPU architecture + if: contains(matrix.component.os, 'macos') + shell: bash + run: | + set -ex + git version --build-options >actual + cat actual + grep "cpu: $(uname -m)" actual + # End validate installers + create-github-release: runs-on: ubuntu-latest permissions: contents: write id-token: write # required for Azure login via OIDC needs: + - validate-installers - create-linux-artifacts - create-macos-artifacts - windows_artifacts