Skip to content

Integrate Apple notarization process into Github Actions release pipeline #578

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

Merged
merged 5 commits into from
Feb 12, 2020

Conversation

rsora
Copy link
Contributor

@rsora rsora commented Feb 11, 2020

What:

This PR Integrates the Notarization process in the Arduino CLI Relese pipeline.

Why:

As per Apple announcement:

Beginning in macOS 10.14.5, software signed with a new Developer ID certificate and all new or updated kernel extensions must be notarized to run. Beginning in macOS 10.15, all software built after June 1, 2019, and distributed with Developer ID must be notarized.

How:

The PR moves the responsibility of GitHub release creation and Arduino servers upload, from goreleaser to GH Actions steps, and adds the notarization step leveraging Gon (Thanks to @mitchellh and to @zmoog who discovered the tool 😄 )

The notarize-macos job must run on a macos-latest VM, in order to allow gon to orchestrate all the required notarization tools, this means that container steps cannot be used in the same job.
This is why the release pipeline is split in 3 jobs that share artifacts via the artifacts Github Actions feature.

A detailed explanation is required for the Notarize binary, re-package it and update checksum step, that configures the MacOs keychain with obscure osx commands and calls gon doing the following:

  1. Download keychain from GH secrets and decode it from base64
  2. Add the keychain to the system keychains and unlock it
  3. Call Gon to start notarization process (using AC_USERNAME and AC_PASSWORD secrets)
  4. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
  5. Recalculate package checksum and replace it in the goreleaser nnnnnn-checksums.txt file

Pros:

This way we do not lose:

  1. the "build reproducibility", because we still use goreleaser plus multiarch/crossbuild container to produce the artifacts
  2. the automatic changelog generation from goreleaser
  3. the automatic checksum file generation from goreleaser

Cons:

  • We add a bit of complexity to the release workflow (that is acceptable in the end, having handy GitHub actions ready to use).
  • We lost a portion of my mental health 😸

@gvarisco gvarisco self-requested a review February 11, 2020 16:18
Copy link
Contributor

@gvarisco gvarisco left a comment

Choose a reason for hiding this comment

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

LGTM

@rsora rsora self-assigned this Feb 11, 2020
@rsora rsora added this to the 0.8.0 milestone Feb 11, 2020
Copy link
Member

@cmaglie cmaglie left a comment

Choose a reason for hiding this comment

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

I've only some question about details but, besides that, looks great!

-C ../../ LICENSE.txt
CLI_CHECKSUM=$(shasum -a 256 dist/arduino-cli_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1)
perl -pi -w -e "s/.*arduino-cli_${TAG}_macOS_64bit.tar.gz/${CLI_CHECKSUM} arduino-cli_${TAG}_macOS_64bit.tar.gz/g;" dist/*-checksums.txt
rm -f apple-developer.keychain-db
Copy link
Member

Choose a reason for hiding this comment

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

this should be: rm -f ~/Library/Keychains/apple-developer.keychain-db?
BTW why deleting the file since the virtual machine is destroyed after the build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extra paranoia + Typo 😄 but you're right, as per Github Documentation:

You can specify the runner type for each job in a workflow. Each job in a workflow executes in a fresh instance of the virtual machine. All steps in the job execute in the same instance of the virtual machine, allowing the actions in that job to share information using the filesystem.

We can remove that step, I'll update also the PR description.

tag: ${{ github.ref }}
file_glob: true

- name: Downloads upload
Copy link
Member

Choose a reason for hiding this comment

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

WAT? 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll rename it!

gon.config.hcl Outdated

zip {
output_path = "arduino-cli.zip"
}
Copy link
Member

Choose a reason for hiding this comment

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

Since we are ignoring the output zip file, can't we just remove this section and not produce it in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right, I misread the documentation. I thought that at least one output format was mandatory 👍

@rsora
Copy link
Contributor Author

rsora commented Feb 12, 2020

varisco-notarize

@rsora rsora merged commit 1569a5f into master Feb 12, 2020
@rsora rsora deleted the rsora/notarization-ci branch February 12, 2020 09:52
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