Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ jobs:
chmod +x build/macos/build_pkg.sh
./build/macos/build_pkg.sh "${VERSION}" "${{ matrix.macos_arch }}"

- name: Sign and verify macOS installer
if: runner.os == 'macOS'
shell: bash
env:
MAC_INSTALLER_P12_BASE64: ${{ secrets.MAC_INSTALLER_P12_BASE64 }}
MAC_INSTALLER_P12_PASSWORD: ${{ secrets.MAC_INSTALLER_P12_PASSWORD }}
run: bash build/macos/sign_installer.sh "dist/dataplicity-cli-${VERSION}-macos-${{ matrix.macos_arch }}.pkg"

- name: Stage macOS release artifacts
if: runner.os == 'macOS'
shell: bash
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ If you do have Python available and prefer `pipx`:
pipx install dataplicity-cli
```

### macOS installer signing in CI

The Release workflow signs the direct-download package with MachineForest Ltd’s
Developer ID Installer identity and checks the trusted signature and publisher
before generating checksums. Configure `MAC_INSTALLER_P12_BASE64` (the encrypted
PKCS#12 identity encoded as base64) and `MAC_INSTALLER_P12_PASSWORD` in the
protected `release-signing` environment. A qualification-only run performs the
same check. A failed signing or verification step blocks publication.

## Quick start

Guided setup (recommended):
Expand Down
34 changes: 34 additions & 0 deletions build/macos/sign_installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

# The release workflow calls this on an ephemeral macOS runner, before checksumming.
package="${1:?expected package path}"
[[ -f "$package" ]]
: "${MAC_INSTALLER_P12_BASE64:?Missing Developer ID Installer certificate in the release-signing environment}"
: "${MAC_INSTALLER_P12_PASSWORD:?Missing Developer ID Installer certificate password}"

export LC_ALL=C
umask 077
work=$(mktemp -d)
keychain="$work/installer.keychain-db"
cleanup() {
security delete-keychain "$keychain" >/dev/null 2>&1 || true
rm -rf "$work"
}
trap cleanup EXIT
identity='Developer ID Installer: MachineForest Ltd (82FBZ5BYTV)'
keychain_password=$(openssl rand -hex 32)
security create-keychain -p "$keychain_password" "$keychain"
security unlock-keychain -p "$keychain_password" "$keychain"
printf '%s' "$MAC_INSTALLER_P12_BASE64" | base64 -D > "$work/installer.p12"
security import "$work/installer.p12" -k "$keychain" -P "$MAC_INSTALLER_P12_PASSWORD" -T /usr/bin/productsign
rm "$work/installer.p12"
unset MAC_INSTALLER_P12_BASE64 MAC_INSTALLER_P12_PASSWORD
security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" >/dev/null

productsign --timestamp --keychain "$keychain" --sign "$identity" "$package" "$work/signed.pkg"
signature=$(pkgutil --check-signature "$work/signed.pkg")
printf '%s\n' "$signature"
grep -Eq '^[[:space:]]*Status: signed by (a developer certificate issued by Apple for distribution|a certificate trusted by )' <<< "$signature"
grep -Fq "1. $identity" <<< "$signature"
mv "$work/signed.pkg" "$package"
12 changes: 10 additions & 2 deletions tests/test_release_qualification.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,22 @@ def test_entire_release_and_distribution_write_dependency_closure_is_guarded():
assert 'Verify Windows MSI signature' in blocks['build']


def test_original_build_sign_upload_and_release_bytes_except_reviewed_runner_migration():
def test_original_build_sign_upload_and_release_bytes_except_reviewed_macos_changes():
source = WORKFLOW.read_text()
assert source.count(INPUT) == 1 and source.count(GUARD) == 1
# GitHub retired macOS 14 on 2026-11-02. Permit only this exact build-runner
# replacement; retain the original digest over every other workflow byte.
# replacement and the installer signing step; pin the other workflow bytes.
runner = ' - name: macos-universal2\n os: macos-15-intel\n'
assert source.count(runner) == 1
assert 'macos-14' not in source
signing_start = source.index(' - name: Sign and verify macOS installer')
staging_start = source.index(' - name: Stage macOS release artifacts')
assert source.index(' - name: Build macOS pkg') < signing_start < staging_start
signing = source[signing_start:staging_start]
assert signing.splitlines()[1].strip() == "if: runner.os == 'macOS'"
assert 'continue-on-error' not in signing
assert 'run: bash build/macos/sign_installer.sh' in signing
source = source[:signing_start] + source[staging_start:]
original = source.replace(INPUT, '', 1).replace(GUARD, '', 1).replace(
runner, runner.replace('macos-15-intel', 'macos-14'), 1).encode()
digest = hashlib.sha1(b'blob ' + str(len(original)).encode() + b'\0' + original).hexdigest()
Expand Down
Loading