veritas-kanban/.github/workflows/desktop-release.yml
Brad Groux 321a81b0dc
chore(deps): consolidate immutable workflow action updates
Consolidate reviewed workflow action revisions from #1584, #1643, #1644, #1645, and #1646. Local policy tests and static checks passed. GitHub Actions remains disabled.
2026-10-22 20:19:19 -07:00

326 lines
14 KiB
YAML

name: Desktop Release
on:
workflow_dispatch:
inputs:
channel:
description: Update channel to publish.
required: true
default: stable
type: choice
options:
- stable
- beta
- dev
promote_run_id:
description: Successful capture run to publish after its media is committed; leave blank to build/capture only.
required: false
type: string
permissions:
contents: write
actions: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
NODE_VERSION: '22'
VERITAS_BUILD_SHA: ${{ github.sha }}
VERITAS_UPDATE_CHANNEL: ${{ github.event.inputs.channel || 'stable' }}
jobs:
mac-signed:
name: Signed and Notarized macOS Artifact
if: inputs.promote_run_id == ''
runs-on: macos-15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Configure native capture display
run: |
swift scripts/native-ui/hosted-display.swift --configure-hosted
swift scripts/native-ui/hosted-display.swift --check
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Verify signing and notarization secrets are configured
id: notarization-secrets
env:
CSC_LINK: ${{ secrets.MACOS_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.MACOS_CSC_KEY_PASSWORD }}
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
errors=0
for name in CSC_LINK CSC_KEY_PASSWORD; do
if [ -z "${!name}" ]; then
echo "::error::$name is required for signed/notarized desktop releases"
errors=1
fi
done
api_key_count=0
for name in APPLE_API_KEY_BASE64 APPLE_API_KEY_ID APPLE_API_ISSUER; do
if [ -n "${!name}" ]; then
api_key_count=$((api_key_count + 1))
fi
done
apple_id_count=0
for name in APPLE_ID APPLE_APP_SPECIFIC_PASSWORD APPLE_TEAM_ID; do
if [ -n "${!name}" ]; then
apple_id_count=$((apple_id_count + 1))
fi
done
if [ "${api_key_count}" -gt 0 ] && [ "${api_key_count}" -lt 3 ]; then
echo "::error::App Store Connect API-key notarization requires APPLE_API_KEY_BASE64, APPLE_API_KEY_ID, and APPLE_API_ISSUER together"
errors=1
fi
if [ "${apple_id_count}" -gt 0 ] && [ "${apple_id_count}" -lt 3 ]; then
echo "::error::Apple ID notarization requires APPLE_ID, APPLE_APP_SPECIFIC_PASSWORD, and APPLE_TEAM_ID together"
errors=1
fi
if [ "${api_key_count}" -eq 3 ] && [ "${apple_id_count}" -eq 3 ]; then
echo "::error::Configure exactly one notarization credential set, not both App Store Connect API-key and Apple ID credentials"
errors=1
elif [ "${api_key_count}" -eq 3 ]; then
echo "notarization_mode=api-key" >> "${GITHUB_OUTPUT}"
elif [ "${apple_id_count}" -eq 3 ]; then
echo "notarization_mode=apple-id" >> "${GITHUB_OUTPUT}"
else
echo "::error::One complete notarization credential set is required: App Store Connect API key or Apple ID/app-specific password"
errors=1
fi
exit "${errors}"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build workspace
run: pnpm build
- name: Prepare desktop runtime payload
run: pnpm --filter @veritas-kanban/desktop package:prepare
- name: Write App Store Connect API key
id: notary-key
if: steps.notarization-secrets.outputs.notarization_mode == 'api-key'
env:
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
run: |
key_path="${RUNNER_TEMP}/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8"
umask 077
printf '%s' "${APPLE_API_KEY_BASE64}" | base64 --decode > "${key_path}"
if ! grep -q "BEGIN PRIVATE KEY" "${key_path}"; then
echo "::error::APPLE_API_KEY_BASE64 does not decode to an App Store Connect API private key"
exit 1
fi
echo "key_path=${key_path}" >> "${GITHUB_OUTPUT}"
- name: Build, sign, notarize, and stage macOS artifacts
working-directory: desktop
env:
CSC_LINK: ${{ secrets.MACOS_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.MACOS_CSC_KEY_PASSWORD }}
APPLE_API_KEY: ${{ steps.notary-key.outputs.key_path }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: node ./node_modules/electron-builder/cli.js --mac dmg zip --publish never
- name: Finalize notarized macOS release assets
env:
APPLE_API_KEY: ${{ steps.notary-key.outputs.key_path }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: node scripts/finalize-macos-release-assets.mjs
- name: Verify the distribution app in the native macOS matrix
id: native-ui
run: |
set -euo pipefail
version="$(node -p "require('./desktop/package.json').version")"
release_dir="${GITHUB_WORKSPACE}/desktop/release"
zip="${release_dir}/Veritas-Kanban-${version}-mac-arm64.zip"
dmg="${release_dir}/Veritas-Kanban-${version}-mac-arm64.dmg"
(cd "${release_dir}" && shasum -a 256 "$(basename "${zip}")" "$(basename "${dmg}")" "$(basename "${zip}").blockmap" "$(basename "${dmg}").blockmap" latest-mac.yml) > "${RUNNER_TEMP}/native-distribution.sha256"
candidate_dir="$(mktemp -d "${RUNNER_TEMP}/vk-distribution.XXXXXX")"
ditto -x -k "${zip}" "${candidate_dir}"
candidate_app="${candidate_dir}/veritas-kanban.app"
codesign --verify --deep --strict "${candidate_app}"
spctl --assess --type execute "${candidate_app}"
echo "app_path=${candidate_app}" >> "${GITHUB_OUTPUT}"
node scripts/native-ui/run.mjs "${candidate_app}" "${RUNNER_TEMP}/native-ui-evidence"
node scripts/native-ui/verify.mjs "${RUNNER_TEMP}/native-ui-evidence/evidence.json" "${candidate_app}"
- name: Capture candidate documentation media once
env:
VERIFIED_NATIVE_APP: ${{ steps.native-ui.outputs.app_path }}
run: |
set -euo pipefail
command -v ffmpeg >/dev/null || brew install ffmpeg
pnpm exec playwright install chromium
pnpm --dir server exec node --import tsx ../scripts/native-ui/board-performance.mjs "${VERIFIED_NATIVE_APP}" "${RUNNER_TEMP}/large-board-evidence"
node scripts/docs-media/run.mjs "${VERIFIED_NATIVE_APP}" "${RUNNER_TEMP}/documentation-media" capture "${RUNNER_TEMP}/large-board-evidence/report.json"
- name: Retain native macOS evidence even on failure
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: native-macos-ui-evidence
path: |
${{ runner.temp }}/native-ui-evidence
${{ runner.temp }}/native-distribution.sha256
${{ runner.temp }}/documentation-media
${{ runner.temp }}/large-board-evidence
if-no-files-found: warn
retention-days: 14
- name: Bundle verified candidate for later publication
run: |
set -euo pipefail
version="$(node -p "require('./desktop/package.json').version")"
(cd desktop/release && shasum -a 256 -c "${RUNNER_TEMP}/native-distribution.sha256")
node --input-type=module -e '
import { writeFileSync } from "node:fs";
import { join } from "node:path";
writeFileSync(join(process.env.RUNNER_TEMP, "release-candidate.json"), JSON.stringify({
schema: "retained-macos-candidate/v1", runId: process.env.GITHUB_RUN_ID,
commit: process.env.GITHUB_SHA, channel: process.env.VERITAS_UPDATE_CHANNEL
}) + "\n", { flag: "wx" });'
tar -czf "${RUNNER_TEMP}/signed-macos-candidate.tar.gz" \
-C desktop \
"release/Veritas-Kanban-${version}-mac-arm64.zip" \
"release/Veritas-Kanban-${version}-mac-arm64.dmg" \
"release/Veritas-Kanban-${version}-mac-arm64.zip.blockmap" \
"release/Veritas-Kanban-${version}-mac-arm64.dmg.blockmap" \
release/latest-mac.yml \
-C "${RUNNER_TEMP}" release-candidate.json native-distribution.sha256 native-ui-evidence documentation-media large-board-evidence
- name: Retain signed candidate without publishing
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: signed-macos-release-candidate
path: ${{ runner.temp }}/signed-macos-candidate.tar.gz
if-no-files-found: error
retention-days: 14
promote-mac:
name: Verify and publish retained macOS candidate
if: inputs.promote_run_id != ''
runs-on: macos-15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Retrieve the successful capture run
env:
GH_TOKEN: ${{ github.token }}
CAPTURE_RUN_ID: ${{ inputs.promote_run_id }}
run: node scripts/docs-media/restore-candidate.mjs
- name: Verify captured media against the publication commit
run: |
set -euo pipefail
version="$(node -p "require('./desktop/package.json').version")"
candidate_dir="${RUNNER_TEMP}/retained-macos-candidate"
(cd "${candidate_dir}/release" && shasum -a 256 -c "${candidate_dir}/native-distribution.sha256")
extracted="$(mktemp -d "${RUNNER_TEMP}/vk-promotion.XXXXXX")"
ditto -x -k "${candidate_dir}/release/Veritas-Kanban-${version}-mac-arm64.zip" "${extracted}"
candidate_app="${extracted}/veritas-kanban.app"
codesign --verify --deep --strict "${candidate_app}"
spctl --assess --type execute "${candidate_app}"
echo "VERIFIED_NATIVE_APP=${candidate_app}" >> "${GITHUB_ENV}"
node scripts/docs-media/publish.mjs "${candidate_dir}/documentation-media/evidence.json" "${candidate_app}" "${candidate_dir}/documentation-media/publication.json"
- name: Upload macOS release assets
working-directory: ${{ runner.temp }}/retained-macos-candidate
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
(cd release && shasum -a 256 -c ../native-distribution.sha256)
node "${GITHUB_WORKSPACE}/scripts/validate-release.mjs" --skip-build-output --native-evidence "${RUNNER_TEMP}/retained-macos-candidate/native-ui-evidence/evidence.json" --native-app "${VERIFIED_NATIVE_APP}" --media-evidence "${RUNNER_TEMP}/retained-macos-candidate/documentation-media/publication.json" --github
version="$(node -p "require('${GITHUB_WORKSPACE}/desktop/package.json').version")"
tag="v${version}"
dmg="release/Veritas-Kanban-${version}-mac-arm64.dmg"
zip="release/Veritas-Kanban-${version}-mac-arm64.zip"
for file in "${dmg}" "${zip}"; do
if [ ! -f "${file}" ]; then
echo "::error::Expected release asset missing: ${file}"
exit 1
fi
if [ "${file}" = "${dmg}" ]; then
codesign --verify --verbose=2 "${file}"
spctl -a -vvv -t open --context context:primary-signature "${file}"
fi
checksum="$(shasum -a 256 "${file}" | awk '{print $1}')"
printf '%s %s\n' "${checksum}" "$(basename "${file}")" > "${file}.sha256"
done
assets=(
"release/latest-mac.yml"
"${dmg}"
"${dmg}.blockmap"
"${dmg}.sha256"
"${zip}"
"${zip}.blockmap"
"${zip}.sha256"
)
for file in "${assets[@]}"; do
if [ ! -f "${file}" ]; then
echo "::error::Expected release asset missing: ${file}"
exit 1
fi
done
gh release upload "${tag}" "${assets[@]}" --clobber
- name: Retain publication evidence even on failure
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: macos-publication-evidence
path: ${{ runner.temp }}/retained-macos-candidate/documentation-media/publication.json
if-no-files-found: warn
retention-days: 14