Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign and notarize macOS binaries #514

Merged
merged 3 commits into from
Jul 18, 2022

Conversation

ldennington
Copy link
Collaborator

@ldennington ldennington commented Jun 28, 2022

Update macOS portion of build-git-installers workflow to add signing and notarization. A few notes reviewers may find helpful:

  1. This change removes our dependency on the derrickstolee/git_osx_installer repo by migrating the Makefile and scripts we need into Microsoft Git's .github directory (or a subdirectory, if applicable). The following are notes on each of these files:

    1. .github/Makefile: This file was changed substantially (i.e. TODO comments, unneeded variables, and unneeded tasks were removed). Accordingly, it merits a robust review.
    2. The following files were taken as-is from the git_osx_installer repo and should not require a detailed review:
      • .github/macos-installer/assets/etc/gitconfig.default
      • .github/macos-installer/assets/etc/gitconfig.osxkeychain
      • .github/macos-installer/assets/git-components.plist
      • .github/macos-installer/assets/uninstall.sh
      • .github/macos-installer/assets/scripts/postinstall
      • .github/scripts/symlink-git-hardlinks.rb
  2. The ubuntu_build task was updated to also use the signing scripts added for the macOS workflow, allowing for removal of the sign-debian-packages.py script (which had hard-coded Linux values rather than OS-specific values passed as parameters).

  3. Compilation of contrib/credential/osxkeychain failed without the small change I made in contrib/credential/osxkeychain/git-credential-osxkeychain.c.

Finally, here is the latest workflow run in my fork testing these changes.

@derrickstolee
Copy link
Collaborator

  1. This change removes our dependency on the derrickstolee/git_osx_installer repo by migrating the Makefile and scripts we need into Microsoft Git's .github directory (or a subdirectory, if applicable). The following are notes on each of these files:

Love it! Great idea.

Copy link
Collaborator

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I approve, do you have an example run of this action so I can see what the signed install flow looks like on macOS?

Edit: Of course, you already supplied a link. Thanks! https://github.com/ldennington/git/actions/runs/2580040902

.github/Makefile Outdated Show resolved Hide resolved
.github/Makefile Outdated Show resolved Hide resolved
.github/workflows/build-git-installers.yml Show resolved Hide resolved
.github/workflows/build-git-installers.yml Outdated Show resolved Hide resolved
.github/workflows/build-git-installers.yml Show resolved Hide resolved
@derrickstolee
Copy link
Collaborator

Hm... I don't know how this happened:

$ git version
git version 2.32.1 (Apple Git-133)
$ which git
/usr/bin/git
$ /usr/local/bin/git
-bash: /usr/local/bin/git: Permission denied
$ ls -al /usr/local/bin/git
-rw-r--r--  1 root  wheel  4301248 Jun 28 21:13 /usr/local/bin/git

So... I've lost execute privileges on the Git binary! So the /usr/local/bin copy is skipped in favor of the Apple-installed one in /usr/bin.

@ldennington
Copy link
Collaborator Author

Hm... I don't know how this happened:

$ git version
git version 2.32.1 (Apple Git-133)
$ which git
/usr/bin/git
$ /usr/local/bin/git
-bash: /usr/local/bin/git: Permission denied
$ ls -al /usr/local/bin/git
-rw-r--r--  1 root  wheel  4301248 Jun 28 21:13 /usr/local/bin/git

So... I've lost execute privileges on the Git binary! So the /usr/local/bin copy is skipped in favor of the Apple-installed one in /usr/bin.

This was a great catch, thank you (and also a good reminder to me that simply making it through the install process is not enough)! I will investigate ASAP.

@ldennington
Copy link
Collaborator Author

ldennington commented Jul 14, 2022

@dscho @derrickstolee - I think we are good to go. Here is my latest successful run, and I'm currently running the version of microsoft/git I installed from the .dmg published by that run without issue.

Edit: Now we should be good - had to fix some whitespace and newline issues 😬.

@ldennington ldennington force-pushed the sign-macos branch 3 times, most recently from 7f458bd to 10600e3 Compare July 14, 2022 22:58
Copy link
Collaborator

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Sorry to bother you about it, but could you rebase onto vfs-2.37.1?

@@ -168,7 +168,7 @@ int main(int argc, const char **argv)
"usage: git credential-osxkeychain <get|store|erase>";

if (!argv[1])
die(usage);
die("%s", usage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you working on an upstream fix for this? ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Today 😆.

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add a step that mounts the .dmg, unpacks the .pkg and verifies that its git version works and shows the expected output? That would catch issues similar to the lost executable bit in the future.

@@ -0,0 +1,58 @@
[core]
excludesfile = ~/.gitignore
legacyheaders = false # >git 1.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any code to handle core.legacyHeaders at all anymore? I do not see any, it seems that this has been removed in v1.5.3-rc0~218^2...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually removed this file based on your comment here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't think we'll need to worry about the legacy headers...apologies if I'm overlooking something though.

@ldennington
Copy link
Collaborator Author

Looking good. Sorry to bother you about it, but could you rebase onto vfs-2.37.1?

Will do - it's no problem.

@ldennington
Copy link
Collaborator Author

Maybe we could add a step that mounts the .dmg, unpacks the .pkg and verifies that its git version works and shows the expected output? That would catch issues similar to the lost executable bit in the future.

I think this is a good idea. However, it seems like we should add this type of validation for all the installers we produce. I've opened a separate work item for this: https://github.com/github/git-fundamentals/issues/965.

@ldennington ldennington changed the base branch from vfs-2.37.0 to vfs-2.37.1 July 15, 2022 15:57
@ldennington ldennington merged commit c4a88d6 into microsoft:vfs-2.37.1 Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants