Skip to content

Commit ef03d3f

Browse files
author
rsora
committed
Disable code signing when workflows run from forks
- Skip Mac/Win code signing and Apple notarization only if PR comes from a fork - Disable workflows entirely if the user enabled Github Actions in their fork repo - Add steps to help Mac users to test their forked code in BUILDING.md
1 parent 5c8669d commit ef03d3f

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

Diff for: .github/workflows/build.yml

+21-15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
jobs:
1717

1818
build:
19+
if: github.repository == 'arduino/arduino-ide'
1920
strategy:
2021
matrix:
2122
config:
@@ -50,21 +51,26 @@ jobs:
5051
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5152
IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
5253
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
54+
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
5355
run: |
5456
# See: https://www.electron.build/code-signing
55-
if [ "${{ runner.OS }}" = "macOS" ]; then
56-
export CSC_LINK="${{ runner.temp }}/signing_certificate.p12"
57-
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
58-
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
59-
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE_P12 }}" | base64 --decode > "$CSC_LINK"
60-
61-
export CSC_KEY_PASSWORD="${{ secrets.KEYCHAIN_PASSWORD }}"
62-
63-
elif [ "${{ runner.OS }}" = "Windows" ]; then
64-
export CSC_LINK="${{ runner.temp }}/signing_certificate.pfx"
65-
echo "${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PFX }}" | base64 --decode > "$CSC_LINK"
66-
67-
export CSC_KEY_PASSWORD="${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PASSWORD }}"
57+
if [ $IS_FORK = true ]; then
58+
echo "Skipping the app signing: building from a fork."
59+
else
60+
if [ "${{ runner.OS }}" = "macOS" ]; then
61+
export CSC_LINK="${{ runner.temp }}/signing_certificate.p12"
62+
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
63+
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
64+
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE_P12 }}" | base64 --decode > "$CSC_LINK"
65+
66+
export CSC_KEY_PASSWORD="${{ secrets.KEYCHAIN_PASSWORD }}"
67+
68+
elif [ "${{ runner.OS }}" = "Windows" ]; then
69+
export CSC_LINK="${{ runner.temp }}/signing_certificate.pfx"
70+
echo "${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PFX }}" | base64 --decode > "$CSC_LINK"
71+
72+
export CSC_KEY_PASSWORD="${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PASSWORD }}"
73+
fi
6874
fi
6975
7076
yarn --cwd ./electron/packager/
@@ -120,7 +126,7 @@ jobs:
120126

121127
publish:
122128
needs: changelog
123-
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
129+
if: github.repository == 'arduino/arduino-ide' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'))
124130
runs-on: ubuntu-latest
125131
steps:
126132
- name: Download [GitHub Actions]
@@ -141,7 +147,7 @@ jobs:
141147

142148
release:
143149
needs: changelog
144-
if: startsWith(github.ref, 'refs/tags/')
150+
if: github.repository == 'arduino/arduino-ide' && startsWith(github.ref, 'refs/tags/')
145151
runs-on: ubuntu-latest
146152
steps:
147153
- name: Download [GitHub Actions]

Diff for: .github/workflows/check-certificates.yml

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ env:
1515

1616
jobs:
1717
check-certificates:
18+
# Only run when the workflow will have access to the certificate secrets.
19+
if: >
20+
(github.event_name != 'pull_request' && github.repository == 'arduino/arduino-ide') ||
21+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'arduino/arduino-ide')
22+
1823
runs-on: ubuntu-latest
1924

2025
strategy:

Diff for: BUILDING.md

+16
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ This project is built on [GitHub Actions](https://github.com/arduino/arduino-ide
7373
git push origin 1.2.3
7474
```
7575

76+
## Notes for macOS contributors
77+
Beginning in macOS 10.14.5, the software [must be notarized to run](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution). The signing and notarization processes for the Arduino IDE are managed by our Continuous Integration (CI) workflows, implemented with GitHub Actions. On every push and pull request, the Arduino IDE is built and saved to a workflow artifact. These artifacts can be used by contributors and beta testers who don't want to set up a build system locally.
78+
For security reasons, signing and notarization are disabled for workflow runs for pull requests from forks of this repository. This means that macOS will block you from running those artifacts.
79+
Due to this limitation, Mac users have two options for testing contributions from forks:
80+
81+
### The Safe approach (recommended)
82+
83+
Follow [the instructions above](#build-from-source) to create the build environment locally, then build the code you want to test.
84+
85+
### The Risky approach
86+
87+
*Please note that this approach is risky as you are lowering the security on your system, therefore we strongly discourage you from following it.*
88+
1. Use [this guide](https://help.apple.com/xcode/mac/10.2/index.html?localePath=en.lproj#/dev9b7736b0e), in order to disable Gatekeeper (at your own risk!).
89+
1. Download the unsigned artifact provided by the CI workflow run related to the Pull Request at each push.
90+
1. Re-enable Gatekeeper after tests are done, following the guide linked above.
91+
7692
### Creating a release
7793
7894
You will not need to create a new release yourself as the Arduino team takes care of this on a regular basis, but we are documenting the process here. Let's assume the current version is `0.1.3` and you want to release `0.2.0`.

Diff for: electron/build/scripts/notarize.js

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ exports.default = async function notarizing(context) {
66
console.log('Skipping notarization: not on CI.');
77
return;
88
}
9+
if (process.env.IS_FORK === 'true') {
10+
console.log('Skipping the app notarization: building from a fork.');
11+
return;
12+
}
913
const { electronPlatformName, appOutDir } = context;
1014
if (electronPlatformName !== 'darwin') {
1115
return;

0 commit comments

Comments
 (0)