Merge pull request #149 from nanox333/feat/release-shared-signing

Release: sign with the shared macOS import and Windows signing script
This commit is contained in:
FredApps authored and GitHub committed 2026-11-27 22:46:51 +01:00
commit 3fe7aa009c
4 files changed
+113 -10

No files matched your search

+15 -5
View File
@@ -330,11 +330,15 @@ jobs:
if: inputs.version != ''
run: cargo xtask version set "$VERSION"
- name: Import signing certificate
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: packaging/macos/import-cert.sh
# The shared import, not the app's packaging/macos/import-cert.sh: it exports the same
# MACOS_SIGN_IDENTITY and MACOS_KEYCHAIN that package.sh reads, from a private directory.
# $/ is this workflow's own repository and commit, so a release pinned to a commit signs
# with that commit's helpers; the same holds for setup-windows-signing below.
uses: $/actions/import-macos-certificate
with:
certificate: ${{ secrets.APPLE_CERTIFICATE }}
certificate-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
keychain-password: ${{ secrets.KEYCHAIN_PASSWORD }}
- name: Build, sign, notarize
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
@@ -472,6 +476,12 @@ jobs:
uses: storytold/craft-common-actions/actions/install-wix@main
with:
wix-version: ${{ inputs.wix-version }}
- name: Set up the shared signing script
# Exports CRAFT_SIGN_SCRIPT, CRAFT_SIGN_PRODUCT and CRAFT_SIGN_URL. An app's package.ps1
# signs with `& $env:CRAFT_SIGN_SCRIPT <files>` instead of its own sign.ps1.
uses: $/actions/setup-windows-signing
with:
product-name: ${{ inputs.app-title }}
- name: Build, sign, package
shell: pwsh
env:
+11
View File
@@ -11,6 +11,11 @@ on:
description: "Installation folder name inside ProgramFiles or LocalAppData (e.g. PhotoCraft)"
type: string
required: true
app-title:
description: "Application display name for the shared signing script (default: app-dir). This workflow has no signing secrets, so the package stays unsigned"
type: string
required: false
default: ""
install-relative-path:
description: "Install path below LocalAppData (per-user) or ProgramFiles (per-machine), independent of app-dir"
type: string
@@ -99,6 +104,12 @@ jobs:
uses: storytold/craft-common-actions/actions/install-wix@main
with:
wix-version: ${{ inputs.wix-version }}
- name: Set up the shared signing script
# package.ps1 calls the same CRAFT_SIGN_SCRIPT as in a release; without secrets it warns
# and leaves the files unsigned.
uses: $/actions/setup-windows-signing
with:
product-name: ${{ inputs.app-title || inputs.app-dir }}
- name: Build and package (unsigned)
shell: pwsh
env:
+11 -5
View File
@@ -226,7 +226,7 @@ Rust build code.
List every signing secret explicitly. The signing jobs run in the caller repo's `release` environment and read the values from there, but only for the names listed here: an unlisted name is empty. On the `release` branch the macOS and Windows jobs fail when their signing secrets are empty, rather than shipping unsigned builds.
macOS and Windows packages are signed by the app's own packaging scripts. `release.yml` does not request `id-token` or `attestations`, so existing callers keep building as they do now.
macOS and Windows packages are signed by the app's packaging scripts, with the shared certificate import and signing script (see "macOS code signing" and "Windows code signing"). `release.yml` does not request `id-token` or `attestations`, so existing callers keep building as they do now.
Build provenance, a CycloneDX SBOM, and a Sigstore signature of the published files are a second job. Add it only in an app that is ready to grant those permissions. `release.yml` does not call `supply-chain.yml`.
@@ -1140,8 +1140,11 @@ The certificate and keychain go in a fresh private directory with an unpredictab
decoded bundle is deleted as soon as it is imported, and a failed import also deletes the keychain.
Without a certificate it only warns and exits successfully, so unsigned test builds still work.
Existing callers are unaffected: the shared `release.yml` still runs each app's own
`packaging/macos/` script. Apps adopt the action one at a time, then delete their copy.
The shared `release.yml` imports the certificate with this action, so an app's own
`packaging/macos/import-cert.sh` is no longer run and can be deleted. It calls the action as
`$/actions/import-macos-certificate`, from the workflow's own repository and commit: an app that
calls `release.yml@main` gets main's action, and one that pins `release.yml` to a commit signs with
that commit's action.
## Job time limits
@@ -1261,8 +1264,11 @@ loading the Trusted Signing client it checks the downloaded package against a pi
upgrading the client means changing the version and hash together. With neither kind of secret it
warns and leaves the files unsigned.
Existing callers are unaffected: the shared `release.yml` still runs each app's own
`packaging/windows/` scripts. Apps adopt the action one at a time, then delete their copy.
The shared `release.yml` and `windows-arm64.yml` run this action before `package.ps1`, with the
app's `app-title` as the product name (`windows-arm64.yml` falls back to `app-dir`), so
`CRAFT_SIGN_SCRIPT` is always set there. Both call it as `$/actions/setup-windows-signing`, so the
script comes from the same commit as the workflow. An app switches by making `package.ps1` call it
instead of its own `sign.ps1`, then deletes its copy; until then nothing changes for it.
## Testing workflow failure paths
+76
View File
@@ -0,0 +1,76 @@
"""The release workflows sign with the shared macOS import and Windows signing script, not app copies."""
from pathlib import Path
import unittest
import yaml
ROOT = Path(__file__).resolve().parents[1]
WORKFLOWS = {name: yaml.load((ROOT / ".github/workflows" / name).read_text(), Loader=yaml.BaseLoader)
for name in ("release.yml", "windows-arm64.yml")}
# From the reusable workflow's own commit, not @main: a pinned release signs with that commit's helpers.
IMPORT = "$/actions/import-macos-certificate"
SETUP = "$/actions/setup-windows-signing"
def steps():
for workflow, doc in WORKFLOWS.items():
for job_name, job in doc["jobs"].items():
for index, step in enumerate(job.get("steps", [])):
yield workflow, job_name, job, index, step
class SharedSigningWiringTests(unittest.TestCase):
def test_no_job_runs_an_apps_own_certificate_import(self):
for workflow, job, _, _, step in steps():
with self.subTest(workflow=workflow, job=job, step=step.get("name")):
self.assertNotIn("import-cert.sh", step.get("run", ""))
def test_the_macos_job_imports_with_the_shared_action_before_packaging(self):
jobs = [job for _, _, job, _, step in steps() if "packaging/macos/package.sh" in step.get("run", "")]
self.assertTrue(jobs, "no job runs packaging/macos/package.sh")
for job in jobs:
names = [step.get("name", "") for step in job["steps"]]
importing = [i for i, step in enumerate(job["steps"]) if step.get("uses") == IMPORT]
self.assertEqual(len(importing), 1, names)
packaging = next(i for i, step in enumerate(job["steps"]) if "packaging/macos/package.sh" in step.get("run", ""))
self.assertLess(importing[0], packaging)
inputs = job["steps"][importing[0]]["with"]
self.assertEqual(inputs, {"certificate": "${{ secrets.APPLE_CERTIFICATE }}",
"certificate-password": "${{ secrets.APPLE_CERTIFICATE_PASSWORD }}",
"keychain-password": "${{ secrets.KEYCHAIN_PASSWORD }}"})
# A clean-up step deletes the keychain the action exports, even when packaging failed.
cleanup = [step for step in job["steps"][packaging:]
if 'security delete-keychain "$MACOS_KEYCHAIN"' in step.get("run", "")]
self.assertEqual(len(cleanup), 1, names)
self.assertEqual(cleanup[0].get("if"), "always()")
def test_every_windows_packaging_step_has_the_signing_script_set_up_first(self):
found = []
for workflow, job_name, job, index, step in steps():
if "packaging/windows/package.ps1" not in step.get("run", ""):
continue
found.append(workflow)
with self.subTest(workflow=workflow, job=job_name):
setup = [i for i, s in enumerate(job["steps"]) if s.get("uses") == SETUP]
self.assertEqual(len(setup), 1)
self.assertLess(setup[0], index)
expected = "${{ inputs.app-title }}" if workflow == "release.yml" else "${{ inputs.app-title || inputs.app-dir }}"
self.assertEqual(job["steps"][setup[0]]["with"], {"product-name": expected})
self.assertEqual(sorted(set(found)), ["release.yml", "windows-arm64.yml"])
def test_the_signing_helpers_come_from_the_workflows_own_commit(self):
for workflow, job, _, _, step in steps():
uses = step.get("uses", "")
if "import-macos-certificate" in uses or "setup-windows-signing" in uses:
with self.subTest(workflow=workflow, job=job, step=step.get("name")):
self.assertIn(uses, (IMPORT, SETUP))
def test_the_arm64_title_is_optional_so_callers_need_no_change(self):
app_title = WORKFLOWS["windows-arm64.yml"]["on"]["workflow_call"]["inputs"]["app-title"]
self.assertEqual(app_title["required"], "false")
self.assertEqual(app_title["default"], "")
self.assertEqual(WORKFLOWS["release.yml"]["on"]["workflow_call"]["inputs"]["app-title"]["required"], "true")
if __name__ == "__main__":
unittest.main()