Browse Source

ci: sign macOS binaries after the release is published

Notarizing inside GoReleaser meant any Apple-side problem failed the whole
release (3000.23.0 failed on FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED).
Darwin archives are now built unsigned and excluded from the release, like
Windows, and a new sign-macos job signs/notarizes them with quill, then
uploads them and their checksums. A failure leaves the release published
without macOS assets until the job is re-run.

The checksums.txt update is shared by both sign jobs, which now use one
concurrency group so they do not overwrite each other's changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 1 day ago
parent
commit
b795c59d3e

+ 60 - 12
.github/workflows/build-and-release.yml

@@ -22,6 +22,7 @@ on:
       - 'var/entities/**'
       - 'var/helper-actions/**'
       - 'var/macos/**'
+      - 'var/release/**'
       - 'var/sbom/**'
       - 'var/windows/**'
   workflow_dispatch:
@@ -51,6 +52,7 @@ on:
       - 'var/entities/**'
       - 'var/helper-actions/**'
       - 'var/macos/**'
+      - 'var/release/**'
       - 'var/sbom/**'
       - 'var/windows/**'
 
@@ -173,13 +175,6 @@ jobs:
         if: env.WILL_PUBLISH == 'true'
         uses: docker/setup-buildx-action@v4
 
-      - name: Verify macOS signing certificate chain
-        if: env.WILL_PUBLISH == 'true'
-        env:
-          MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
-          MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
-        run: ./var/macos/verify-macos-sign-p12.sh
-
       - name: Authenticate git for release
         if: env.WILL_PUBLISH == 'true'
         env:
@@ -206,11 +201,6 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
           GH_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
-          MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
-          MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
-          MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
-          MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
-          MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
 
       - name: Upload unsigned Windows zip for SignPath
         id: upload-windows-zip
@@ -232,6 +222,14 @@ jobs:
           archive: false
           if-no-files-found: error
 
+      - name: Upload unsigned macOS archives for signing
+        if: steps.release.outputs.new_release_published == 'true'
+        uses: actions/upload-artifact@v7
+        with:
+          name: unsigned-darwin
+          path: dist/OliveTin-darwin-*.tar.gz
+          if-no-files-found: error
+
       - name: Archive binaries
         if: env.WILL_PUBLISH == 'true'
         uses: actions/upload-artifact@v7
@@ -244,6 +242,10 @@ jobs:
     needs: build
     if: needs.build.outputs.new_release_published == 'true'
     runs-on: ubuntu-latest
+    # Shared with sign-macos: both read-modify-write the release's checksums.txt.
+    concurrency:
+      group: release-signed-assets-${{ github.run_id }}
+      cancel-in-progress: false
     permissions:
       actions: read
       contents: write
@@ -320,3 +322,49 @@ jobs:
             "${{ needs.build.outputs.new_release_git_tag }}" \
             "${zip_path}" \
             "${msi_path}"
+
+  # Runs after the release is published, like sign-windows, so an Apple-side
+  # failure (expired agreement, notary outage, cert problem) does not fail the
+  # release: it only leaves the macOS assets missing until this job is re-run.
+  sign-macos:
+    name: Sign macOS artifacts (quill)
+    needs: build
+    if: needs.build.outputs.new_release_published == 'true'
+    runs-on: ubuntu-latest
+    permissions:
+      actions: read
+      contents: write
+    concurrency:
+      group: release-signed-assets-${{ github.run_id }}
+      cancel-in-progress: false
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v6
+        with:
+          persist-credentials: false
+
+      - name: Setup Go
+        uses: actions/setup-go@v6
+        with:
+          go-version-file: 'service/go.mod'
+          cache: false
+
+      - name: Download unsigned macOS archives
+        uses: actions/download-artifact@v8
+        with:
+          name: unsigned-darwin
+          path: unsigned-darwin
+
+      - name: Sign, notarize and upload macOS archives
+        env:
+          GH_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
+          GITHUB_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
+          MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
+          MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
+          MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
+          MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
+          MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
+        run: |
+          ./var/macos/sign-and-publish.sh \
+            "${{ needs.build.outputs.new_release_git_tag }}" \
+            unsigned-darwin

+ 38 - 24
.goreleaser.yml

@@ -6,7 +6,7 @@ before:
     - make windows-resources VERSION={{ .Version }}
 
 builds:
-  # id defaults to project_name (OliveTin) — required for notarize.macos defaults.
+  # id defaults to project_name (OliveTin).
   - skip: '{{ isEnvSet "GORELEASER_SKIP_BUILD" }}'
     env:
       - CGO_ENABLED=0
@@ -15,7 +15,6 @@ builds:
     dir: service
     goos:
       - linux
-      - darwin
       - freebsd
 
     goarch:
@@ -29,10 +28,23 @@ builds:
       - 6
       - 7
 
-    ignore:
-      - goos: darwin
-        goarch: arm # Mac does not work on [32bit] arm
+    ldflags:
+      - -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{ .CommitDate }}
 
+  # Built and archived unsigned, but excluded from the GitHub release upload.
+  # The sign-macos job signs/notarizes with quill and uploads them afterwards.
+  - id: darwin
+    skip: '{{ isEnvSet "GORELEASER_SKIP_BUILD" }}'
+    env:
+      - CGO_ENABLED=0
+    binary: OliveTin
+    main: .
+    dir: service
+    goos:
+      - darwin
+    goarch:
+      - amd64
+      - arm64
     ldflags:
       - -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{ .CommitDate }}
 
@@ -53,7 +65,8 @@ builds:
 
 checksum:
   name_template: 'checksums.txt'
-  # Exclude the windows archive; signed zip/MSI checksums are added after SignPath.
+  # Exclude the windows and darwin archives; their checksums are added by the
+  # sign-windows / sign-macos jobs once signed.
   ids:
     - default
     - openrc
@@ -115,6 +128,22 @@ archives:
     name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}{{ .Arm }}"
     wrap_in_directory: true
 
+  - id: darwin
+    ids:
+      - darwin
+    formats: tar.gz
+    files:
+      - config.yaml
+      - LICENSE
+      - README.md
+      - src: Dockerfile.singlearch
+        dst: Dockerfile
+      - examples/backupScript.sh
+      - webui
+      - var
+    name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}{{ .Arm }}"
+    wrap_in_directory: true
+
   - id: windows
     ids:
       - windows
@@ -224,25 +253,10 @@ nfpms:
       - src: var/manpage/OliveTin.1.gz
         dst: /usr/share/man/man1/OliveTin.1.gz
 
-# Sign and notarize darwin binaries via quill (no macOS runner required).
-# Skipped when MACOS_SIGN_P12 is unset so local/snapshot builds stay unsigned.
-notarize:
-  macos:
-    - enabled: '{{ isEnvSet "MACOS_SIGN_P12" }}'
-      # Defaults to project_name when omitted; must match builds[].id (also project_name).
-      sign:
-        certificate: "{{.Env.MACOS_SIGN_P12}}"
-        password: "{{.Env.MACOS_SIGN_PASSWORD}}"
-      notarize:
-        issuer_id: "{{.Env.MACOS_NOTARY_ISSUER_ID}}"
-        key_id: "{{.Env.MACOS_NOTARY_KEY_ID}}"
-        key: "{{.Env.MACOS_NOTARY_KEY}}"
-        wait: true
-        # Apple rejects notary auth tokens with lifetimes over 20m.
-        timeout: 20m
-
 release:
-  # Publish immediately without Windows assets; sign-windows uploads signed zip/MSI later.
+  # Publish immediately without Windows/macOS assets; sign-windows and sign-macos
+  # upload the signed zip/MSI and darwin tarballs later, so a signing outage
+  # cannot block a release.
   draft: false
   # semantic-release's github plugin creates a draft release first (for issue comments);
   # adopt it and replace its placeholder notes rather than creating a second release.

+ 17 - 8
docs/modules/dev/pages/signing.adoc

@@ -2,14 +2,22 @@
 
 OliveTin signs release binaries on two platforms:
 
-* **macOS** — Developer ID + notarization via [quill](https://github.com/anchore/quill) inside GoReleaser (optional only when `MACOS_SIGN_P12` is unset).
+* **macOS** — Developer ID + notarization via [quill](https://github.com/anchore/quill) in a separate GitHub Actions job (signed darwin tarballs are uploaded after the release is published).
 * **Windows** — Authenticode via [SignPath Foundation](https://signpath.org/) in a separate GitHub Actions job (signed zip/MSI are uploaded after the release is published).
 
 ## macOS release signing
 
-Release builds can sign and notarize the `darwin` binaries using [quill](https://github.com/anchore/quill) via GoReleaser. This runs on the existing Linux CI runner; no macOS runner or Xcode is required.
+Release builds sign and notarize the `darwin` binaries using [quill](https://github.com/anchore/quill). This runs on a Linux CI runner; no macOS runner or Xcode is required.
 
-Signing is **optional** only when `MACOS_SIGN_P12` is unset — GoReleaser then skips macOS signing and publishes unsigned binaries. When `MACOS_SIGN_P12` is set, the companion macOS secrets below are required or the release fails.
+Like Windows signing, this happens **after** the release is published, so a problem on Apple's side cannot block a release:
+
+1. GoReleaser builds `OliveTin-darwin-{amd64,arm64}.tar.gz` unsigned and leaves them out of the GitHub release and `checksums.txt`. The `build` job uploads them as the `unsigned-darwin` workflow artifact.
+2. The `sign-macos` job checks the `.p12` chain, then signs and notarizes each binary with quill, repacks the tarballs and checks the designated requirement.
+3. The job uploads the signed tarballs to the release and adds their lines to `checksums.txt`.
+
+If `sign-macos` fails (for example an expired Apple agreement, a notary outage or a certificate problem), the release stays published without macOS assets. Fix the cause, then use **Re-run failed jobs** on that workflow run. The unsigned artifact must still be within its retention period.
+
+`sign-windows` and `sign-macos` share a concurrency group, so they never update `checksums.txt` at the same time.
 
 ### Prerequisites
 
@@ -99,7 +107,7 @@ In **Settings → Secrets and variables → Actions**, create:
 | `MACOS_NOTARY_KEY_ID` | Key ID from App Store Connect (e.g. `ABC123DEF4`) |
 | `MACOS_NOTARY_ISSUER_ID` | Issuer UUID from App Store Connect |
 
-All five must be present for signing to run. GoReleaser enables the step when `MACOS_SIGN_P12` is set; missing companion secrets will fail that release.
+All five must be present; `sign-macos` fails (without affecting the published release) if any are missing.
 
 ### Renewal
 
@@ -108,6 +116,7 @@ All five must be present for signing to run. GoReleaser enables the step when `M
 | Developer ID Application certificate | ~5 years | Create a new certificate in the Apple portal, export a new **full-chain** `.p12` (leaf + G2 intermediate + Apple Root CA), update `MACOS_SIGN_P12` and `MACOS_SIGN_PASSWORD`. |
 | App Store Connect API key | Does not expire, but can be revoked | Create a new key if compromised or lost; update `MACOS_NOTARY_KEY`, `MACOS_NOTARY_KEY_ID`, and optionally `MACOS_NOTARY_ISSUER_ID`. |
 | Apple Developer Program | Annual subscription | Renew membership before it lapses; existing certificates stop working if the account is inactive. |
+| Apple Developer agreements | Re-issued by Apple from time to time | When Apple publishes an updated Program License Agreement, the Account Holder must accept it at https://developer.apple.com/account. Until then notarization fails with `403 FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED`. |
 
 After updating secrets, the next release on `main` (via semantic-release) will use the new credentials automatically.
 
@@ -116,7 +125,7 @@ After updating secrets, the next release on `main` (via semantic-release) will u
 From any platform (no Mac required), check that quill did **not** emit the broken `certificate root[...]` designated requirement:
 
 ```sh
-go install github.com/anchore/quill/cmd/quill@latest
+go install github.com/anchore/quill/cmd/quill@v0.7.1
 quill describe OliveTin-darwin-arm64/OliveTin
 ```
 
@@ -134,11 +143,11 @@ spctl -a -vv -t execute OliveTin-darwin-arm64/OliveTin
 
 ### Configuration reference
 
-- GoReleaser: `notarize.macos` in link:https://github.com/OliveTin/OliveTin/blob/main/.goreleaser.yml[`.goreleaser.yml`]
-- CI secrets: link:https://github.com/OliveTin/OliveTin/blob/main/.github/workflows/build-and-release.yml[`.github/workflows/build-and-release.yml`] (`release` step)
+- GoReleaser: the `darwin` build and archive in link:https://github.com/OliveTin/OliveTin/blob/main/.goreleaser.yml[`.goreleaser.yml`]
+- CI job and secrets: link:https://github.com/OliveTin/OliveTin/blob/main/.github/workflows/build-and-release.yml[`.github/workflows/build-and-release.yml`] (`sign-macos` job)
+- Sign, notarize and upload: link:https://github.com/OliveTin/OliveTin/blob/main/var/macos/sign-and-publish.sh[`var/macos/sign-and-publish.sh`]
 - CI preflight (3-cert P12): link:https://github.com/OliveTin/OliveTin/blob/main/var/macos/verify-macos-sign-p12.sh[`var/macos/verify-macos-sign-p12.sh`]
 - CI post-sign check (designated requirement): link:https://github.com/OliveTin/OliveTin/blob/main/var/macos/verify-signed-darwin.sh[`var/macos/verify-signed-darwin.sh`]
-- link:https://goreleaser.com/customization/notarize/[GoReleaser notarization docs]
 
 ## Windows release signing (SignPath)
 

+ 91 - 0
var/macos/sign-and-publish.sh

@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+# Post-release: sign and notarize the darwin binaries inside the unsigned
+# OliveTin-darwin-*.tar.gz archives, repack them, check the designated
+# requirement, then upload them (and their checksums) to the GitHub release.
+#
+# Runs in the sign-macos job after GoReleaser has already published the
+# release, so an Apple-side problem (expired agreement, notary outage,
+# revoked cert) leaves the release out but missing its macOS assets instead
+# of failing it. Re-run the job once fixed.
+#
+# Usage: sign-and-publish.sh <release-tag> <unsigned-archive-dir>
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
+QUILL_VERSION="${QUILL_VERSION:-v0.7.1}"
+export QUILL_VERSION
+
+TAG="${1:-}"
+UNSIGNED_DIR="${2:-}"
+if [[ -z "${TAG}" || -z "${UNSIGNED_DIR}" ]]; then
+  echo "Usage: $(basename "$0") <release-tag> <unsigned-archive-dir>" >&2
+  exit 1
+fi
+
+missing=0
+for name in MACOS_SIGN_P12 MACOS_SIGN_PASSWORD MACOS_NOTARY_KEY MACOS_NOTARY_KEY_ID MACOS_NOTARY_ISSUER_ID; do
+  if [[ -z "${!name:-}" ]]; then
+    echo "Missing required macOS signing secret: ${name}" >&2
+    missing=1
+  fi
+done
+if [[ "${missing}" -ne 0 ]]; then
+  echo "macOS signing secrets are required to upload signed macOS assets. See docs/modules/dev/pages/signing.adoc." >&2
+  exit 1
+fi
+
+"${SCRIPT_DIR}/verify-macos-sign-p12.sh"
+
+if ! command -v quill >/dev/null 2>&1; then
+  echo "Installing quill ${QUILL_VERSION}..."
+  go install "github.com/anchore/quill/cmd/quill@${QUILL_VERSION}"
+  export PATH="$(go env GOPATH)/bin:${PATH}"
+fi
+
+shopt -s nullglob
+archives=("${UNSIGNED_DIR}"/OliveTin-darwin-*.tar.gz)
+if [[ "${#archives[@]}" -eq 0 ]]; then
+  echo "No OliveTin-darwin-*.tar.gz archives found under ${UNSIGNED_DIR}." >&2
+  exit 1
+fi
+
+workdir="$(mktemp -d)"
+trap 'rm -rf "${workdir}"' EXIT
+signed_dir="${workdir}/signed"
+mkdir -p "${signed_dir}"
+
+# Secrets can carry trailing newlines; quill wants clean base64 or a path.
+p12_path="${workdir}/sign.p12"
+key_path="${workdir}/notary.p8"
+printf '%s' "${MACOS_SIGN_P12}" | tr -d '\n\r' | base64 -d >"${p12_path}"
+printf '%s' "${MACOS_NOTARY_KEY}" | tr -d '\n\r' | base64 -d >"${key_path}"
+
+for archive in "${archives[@]}"; do
+  name="$(basename "${archive}" .tar.gz)"
+  extract_dir="${workdir}/${name}"
+  mkdir -p "${extract_dir}"
+  tar -xzf "${archive}" -C "${extract_dir}"
+
+  # GoReleaser wraps archives in a directory named after the archive.
+  binary="${extract_dir}/${name}/OliveTin"
+  if [[ ! -f "${binary}" ]] || ! file "${binary}" | grep -qi 'Mach-O'; then
+    echo "Mach-O binary not found at ${name}/OliveTin inside ${archive}." >&2
+    exit 1
+  fi
+
+  echo "Signing and notarizing ${name}/OliveTin..."
+  QUILL_SIGN_PASSWORD="${MACOS_SIGN_PASSWORD}" \
+    quill sign-and-notarize "${binary}" \
+      --p12 "${p12_path}" \
+      --notary-issuer "${MACOS_NOTARY_ISSUER_ID}" \
+      --notary-key-id "${MACOS_NOTARY_KEY_ID}" \
+      --notary-key "${key_path}"
+
+  tar --sort=name --owner=0 --group=0 --numeric-owner \
+    -czf "${signed_dir}/${name}.tar.gz" -C "${extract_dir}" "${name}"
+done
+
+"${SCRIPT_DIR}/verify-signed-darwin.sh" "${signed_dir}"
+
+"${REPO_ROOT}/var/release/publish-signed-assets.sh" "${TAG}" "${signed_dir}"/OliveTin-darwin-*.tar.gz

+ 5 - 3
var/macos/verify-signed-darwin.sh

@@ -1,6 +1,8 @@
 #!/usr/bin/env bash
 # Post-sign: fail if quill embedded the broken designated requirement
 # certificate root[field.1.2.840.113635.100.6.2.6] (missing Apple Root in P12).
+#
+# Usage: verify-signed-darwin.sh [archive-dir]   (default: dist/)
 set -euo pipefail
 
 if [[ -z "${MACOS_SIGN_P12:-}" ]]; then
@@ -10,14 +12,15 @@ fi
 
 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
-DIST_DIR="${REPO_ROOT}/dist"
+DIST_DIR="${1:-${REPO_ROOT}/dist}"
+QUILL_VERSION="${QUILL_VERSION:-v0.7.1}"
 
 BAD_REQ='certificate root\[field\.1\.2\.840\.113635\.100\.6\.2\.6\]'
 GOOD_REQ='certificate 1\[field\.1\.2\.840\.113635\.100\.6\.2\.6\]'
 
 if ! command -v quill >/dev/null 2>&1; then
   echo "Installing quill..."
-  go install github.com/anchore/quill/cmd/quill@latest
+  go install "github.com/anchore/quill/cmd/quill@${QUILL_VERSION}"
   export PATH="$(go env GOPATH)/bin:${PATH}"
 fi
 
@@ -52,7 +55,6 @@ for archive in "${archives[@]}"; do
     exit 1
   fi
 
-
   echo "Checking designated requirement in ${archive}..."
   describe_out="$(quill describe "${binary}")"
   if echo "${describe_out}" | grep -qE "${BAD_REQ}"; then

+ 88 - 0
var/release/publish-signed-assets.sh

@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+# Upload signed assets to an already-published GitHub release and add/replace
+# their lines in the release's checksums.txt.
+#
+# Used by the post-release signing jobs (sign-windows, sign-macos). Those jobs
+# share a concurrency group so two of them never read-modify-write
+# checksums.txt at the same time.
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
+DIST_DIR="${DIST_DIR:-${REPO_ROOT}/dist}"
+CHECKSUMS_NAME="checksums.txt"
+
+usage() {
+  echo "Usage: $(basename "$0") <release-tag> <signed-file> [<signed-file>...]" >&2
+  echo "Each file is uploaded under its basename." >&2
+  exit 1
+}
+
+TAG="${1:-}"
+[[ -n "${TAG}" && "$#" -ge 2 ]] || usage
+shift
+
+if ! command -v gh >/dev/null; then
+  echo "gh is required to update the GitHub release" >&2
+  exit 1
+fi
+
+mkdir -p "${DIST_DIR}"
+
+names=()
+for src in "$@"; do
+  if [[ ! -f "${src}" ]]; then
+    echo "Signed file not found: ${src}" >&2
+    exit 1
+  fi
+  name="$(basename "${src}")"
+  if [[ "$(realpath "${src}")" != "$(realpath -m "${DIST_DIR}/${name}")" ]]; then
+    cp -f "${src}" "${DIST_DIR}/${name}"
+  fi
+  names+=("${name}")
+done
+
+checksums_path="${DIST_DIR}/${CHECKSUMS_NAME}"
+checksums_backup="${DIST_DIR}/${CHECKSUMS_NAME}.orig"
+if ! gh release download "${TAG}" --pattern "${CHECKSUMS_NAME}" --dir "${DIST_DIR}" --clobber; then
+  echo "Failed to download ${CHECKSUMS_NAME} from release ${TAG}" >&2
+  exit 1
+fi
+if [[ ! -f "${checksums_path}" ]]; then
+  echo "${CHECKSUMS_NAME} not found after download from release ${TAG}" >&2
+  exit 1
+fi
+cp -f "${checksums_path}" "${checksums_backup}"
+
+update_checksum() {
+  local file_name="${1}"
+  local new_checksum
+  new_checksum="$(cd "${DIST_DIR}" && sha256sum "${file_name}")"
+
+  local tmp
+  tmp="$(mktemp)"
+  grep -vF " ${file_name}" "${checksums_path}" > "${tmp}" || true
+  printf '%s\n' "${new_checksum}" >> "${tmp}"
+  mv "${tmp}" "${checksums_path}"
+}
+
+upload_paths=()
+for name in "${names[@]}"; do
+  update_checksum "${name}"
+  upload_paths+=("${DIST_DIR}/${name}")
+done
+
+# Upload binaries first so a failed checksums upload can restore the previous file.
+# --clobber overwrites same-named assets (needed if the sign job is re-run).
+gh release upload "${TAG}" "${upload_paths[@]}" --clobber
+
+if ! gh release upload "${TAG}" "${checksums_path}" --clobber; then
+  echo "Failed to upload updated ${CHECKSUMS_NAME}; restoring previous asset" >&2
+  restore_dir="$(mktemp -d)"
+  cp -f "${checksums_backup}" "${restore_dir}/${CHECKSUMS_NAME}"
+  gh release upload "${TAG}" "${restore_dir}/${CHECKSUMS_NAME}" --clobber
+  rm -rf "${restore_dir}"
+  exit 1
+fi
+
+echo "Uploaded signed ${names[*]} to release ${TAG}"

+ 0 - 3
var/windows/goreleaser-release-with-msi.sh

@@ -51,6 +51,3 @@ done
 wait_for_stable_file "${ZIP_PATH}"
 "${SCRIPT_DIR}/build-msi.sh"
 wait "${goreleaser_pid}"
-
-# Fail the release job if macOS signing produced an unsatisfiable designated requirement.
-"${REPO_ROOT}/var/macos/verify-signed-darwin.sh"

+ 9 - 62
var/windows/signpath-publish-signed.sh

@@ -7,7 +7,6 @@ DIST_DIR="${DIST_DIR:-${REPO_ROOT}/dist}"
 ARCH="${ARCH:-amd64}"
 ZIP_NAME="OliveTin-windows-${ARCH}.zip"
 MSI_NAME="OliveTin-windows-${ARCH}.msi"
-CHECKSUMS_NAME="checksums.txt"
 
 usage() {
   echo "Usage: $(basename "$0") <release-tag> <signed-zip-path> <signed-msi-path>" >&2
@@ -22,70 +21,18 @@ if [[ -z "${TAG}" || -z "${SIGNED_ZIP}" || -z "${SIGNED_MSI}" ]]; then
   usage
 fi
 
-if [[ ! -f "${SIGNED_ZIP}" ]]; then
-  echo "Signed zip not found: ${SIGNED_ZIP}" >&2
-  exit 1
-fi
-
-if [[ ! -f "${SIGNED_MSI}" ]]; then
-  echo "Signed MSI not found: ${SIGNED_MSI}" >&2
-  exit 1
-fi
-
-if ! command -v gh >/dev/null; then
-  echo "gh is required to update the GitHub release" >&2
-  exit 1
-fi
+for f in "${SIGNED_ZIP}" "${SIGNED_MSI}"; do
+  if [[ ! -f "${f}" ]]; then
+    echo "Signed file not found: ${f}" >&2
+    exit 1
+  fi
+done
 
+# SignPath output names are not guaranteed; publish under the canonical names.
 mkdir -p "${DIST_DIR}"
 cp -f "${SIGNED_ZIP}" "${DIST_DIR}/${ZIP_NAME}"
 cp -f "${SIGNED_MSI}" "${DIST_DIR}/${MSI_NAME}"
 
-checksums_path="${DIST_DIR}/${CHECKSUMS_NAME}"
-checksums_backup="${DIST_DIR}/${CHECKSUMS_NAME}.orig"
-if ! gh release download "${TAG}" --pattern "${CHECKSUMS_NAME}" --dir "${DIST_DIR}" --clobber; then
-  echo "Failed to download ${CHECKSUMS_NAME} from release ${TAG}" >&2
-  exit 1
-fi
-if [[ ! -f "${checksums_path}" ]]; then
-  echo "${CHECKSUMS_NAME} not found after download from release ${TAG}" >&2
-  exit 1
-fi
-cp -f "${checksums_path}" "${checksums_backup}"
-
-update_checksum() {
-  local file_name="${1}"
-  local new_checksum
-  new_checksum="$(cd "${DIST_DIR}" && sha256sum "${file_name}")"
-
-  if [[ -f "${checksums_path}" ]] && grep -qF " ${file_name}" "${checksums_path}"; then
-    local tmp
-    tmp="$(mktemp)"
-    grep -vF " ${file_name}" "${checksums_path}" > "${tmp}" || true
-    printf '%s\n' "${new_checksum}" >> "${tmp}"
-    mv "${tmp}" "${checksums_path}"
-  else
-    printf '%s\n' "${new_checksum}" >> "${checksums_path}"
-  fi
-}
-
-update_checksum "${ZIP_NAME}"
-update_checksum "${MSI_NAME}"
-
-# Upload binaries first so a failed checksums upload can restore the previous file.
-# --clobber overwrites same-named assets (needed if the sign job is re-run).
-gh release upload "${TAG}" \
+DIST_DIR="${DIST_DIR}" "${REPO_ROOT}/var/release/publish-signed-assets.sh" "${TAG}" \
   "${DIST_DIR}/${ZIP_NAME}" \
-  "${DIST_DIR}/${MSI_NAME}" \
-  --clobber
-
-if ! gh release upload "${TAG}" "${checksums_path}" --clobber; then
-  echo "Failed to upload updated ${CHECKSUMS_NAME}; restoring previous asset" >&2
-  restore_dir="$(mktemp -d)"
-  cp -f "${checksums_backup}" "${restore_dir}/${CHECKSUMS_NAME}"
-  gh release upload "${TAG}" "${restore_dir}/${CHECKSUMS_NAME}" --clobber
-  rm -rf "${restore_dir}"
-  exit 1
-fi
-
-echo "Uploaded signed ${ZIP_NAME} and ${MSI_NAME} to release ${TAG}"
+  "${DIST_DIR}/${MSI_NAME}"