Files
iriz/.github/workflows/macos-release.yml
T
2026-09-15 03:34:13 +03:00

249 lines
12 KiB
YAML

name: macOS release draft
on:
workflow_dispatch:
inputs:
build_only:
description: Build, test and upload artifacts without creating a release draft
type: boolean
default: false
push:
tags:
- 'v*'
# This workflow is inert in the private working repository and in forks.
permissions:
contents: read
concurrency:
group: macos-release
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
build:
if: github.repository == 'zarubinvibe/iriz' && github.event.repository.visibility == 'public'
# Standard ARM64 runner, not the paid macos-*-large/xlarge variants.
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners
runs-on: macos-26
timeout-minutes: 90
permissions:
contents: read
env:
# Match the compiler that built the verified release; SDK 26 alone is insufficient.
DEVELOPER_DIR: /Applications/Xcode_26.6.app/Contents/Developer
SMLTLK_SIGN_IDENTITY: '-'
IRIZ_NOTARY_PROFILE: ''
IRIZ_DMG_HEADLESS: '1'
IRIZ_RELEASE_VARIANTS: arm64
outputs:
version: ${{ steps.version.outputs.version }}
source_sha: ${{ steps.version.outputs.source_sha }}
artifact_id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Check out the selected commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Validate version, Xcode 26 and macOS SDK
id: version
run: |
set -euo pipefail
version=$(<RELEASE_VERSION)
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo 'Invalid RELEASE_VERSION'; exit 1; }
if [[ "$GITHUB_REF_TYPE" == tag && "$GITHUB_REF_NAME" != "v$version" ]]; then
echo 'The tag must match RELEASE_VERSION.'
exit 1
fi
[[ "$(uname -m)" == arm64 ]] || { echo 'An ARM64 runner is required.'; exit 1; }
xcode_version=$(xcodebuild -version)
printf '%s\n' "$xcode_version"
[[ "$xcode_version" == $'Xcode 26.6\nBuild version 17F113' ]] \
|| { echo 'Xcode 26.6 build 17F113 is required.'; exit 1; }
swift_version=$(xcrun swift --version)
printf '%s\n' "$swift_version"
[[ "$swift_version" =~ Swift[[:space:]]version[[:space:]]6\.3\.3([[:space:]]|$) ]] \
|| { echo 'Swift 6.3.3 is required.'; exit 1; }
sdk_version=$(xcrun --sdk macosx --show-sdk-version)
printf 'macOS SDK: %s\n' "$sdk_version"
[[ "$sdk_version" =~ ^([0-9]+)(\.[0-9]+){0,2}$ ]] && (( 10#${BASH_REMATCH[1]} >= 26 )) \
|| { echo 'macOS SDK 26 or newer is required.'; exit 1; }
printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"
printf 'source_sha=%s\n' "$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Check workflow guards offline
run: ruby scripts/macos_release_workflow_test.rb --selftest
- name: Verify generated GitHub Release notes
env:
RELEASE_VERSION: ${{ steps.version.outputs.version }}
run: node scripts/render_github_release_notes.mjs --check --version "$RELEASE_VERSION"
- name: Prepare hosted macOS integration environment
run: |
set -euo pipefail
[[ "${GITHUB_ACTIONS:-}" == true && "${RUNNER_ENVIRONMENT:-}" == github-hosted && "${RUNNER_OS:-}" == macOS ]] \
|| { echo 'Fixture writes require a GitHub-hosted macOS runner.'; exit 1; }
xcrun swift scripts/macos_ci_environment.swift --prepare-hosted
xcrun swift scripts/macos_ci_environment.swift --check
- name: Run tests without parallel test execution
run: swift test --no-parallel --jobs 2
- name: Check packaging and installer failure paths
run: |
bash scripts/make_release_test.sh --selftest
bash scripts/build_app_test.sh --selftest
- name: Build and verify the ad-hoc signed DMG
run: bash scripts/make_release.sh
- name: Verify the exact release files
env:
RELEASE_VERSION: ${{ steps.version.outputs.version }}
working-directory: release/dist
run: |
set -euo pipefail
for file in "iriz-$RELEASE_VERSION-arm64.dmg" iriz-macos-arm64.dmg SHA256SUMS.txt release-manifest.json; do
[[ -f "$file" && ! -L "$file" && -s "$file" ]] || { echo "Missing release file: $file"; exit 1; }
done
shasum -a 256 -c SHA256SUMS.txt
cmp "iriz-$RELEASE_VERSION-arm64.dmg" iriz-macos-arm64.dmg
- name: Stage release notes for the draft
env:
RELEASE_VERSION: ${{ steps.version.outputs.version }}
run: cp ".github/release-notes/v$RELEASE_VERSION.md" "release/dist/release-notes-v$RELEASE_VERSION.md"
- name: Keep the release inputs
id: upload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: iriz-${{ steps.version.outputs.version }}-arm64-${{ github.run_id }}-${{ github.run_attempt }}
path: |
release/dist/iriz-${{ steps.version.outputs.version }}-arm64.dmg
release/dist/iriz-macos-arm64.dmg
release/dist/SHA256SUMS.txt
release/dist/release-manifest.json
release/dist/release-notes-v${{ steps.version.outputs.version }}.md
if-no-files-found: error
compression-level: 0
retention-days: 14
overwrite: false
draft:
needs: build
if: github.repository == 'zarubinvibe/iriz' && github.event.repository.visibility == 'public' && !(github.event_name == 'workflow_dispatch' && inputs.build_only)
runs-on: ubuntu-24.04
timeout-minutes: 15
# No checkout or repository scripts run with this write token.
permissions:
contents: write
env:
RELEASE_VERSION: ${{ needs.build.outputs.version }}
SOURCE_SHA: ${{ needs.build.outputs.source_sha }}
steps:
- name: Download only this build's artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.build.outputs.artifact_id }}
path: release-files
merge-multiple: true
digest-mismatch: error
- name: Verify release metadata and checksums
working-directory: release-files
run: |
set -euo pipefail
[[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
[[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]]
for file in "iriz-$RELEASE_VERSION-arm64.dmg" iriz-macos-arm64.dmg SHA256SUMS.txt release-manifest.json "release-notes-v$RELEASE_VERSION.md"; do
[[ -f "$file" && ! -L "$file" && -s "$file" ]]
done
jq -e --arg version "$RELEASE_VERSION" --arg sha "$SOURCE_SHA" '
.version == $version and .source_sha == $sha and
.source_dirty == false and .notarized == false and
.signing.mode == "ad-hoc" and .signing.identity == "-"
' release-manifest.json
sha256sum --check --strict SHA256SUMS.txt
cmp "iriz-$RELEASE_VERSION-arm64.dmg" iriz-macos-arm64.dmg
- name: Create a new draft or leave the published release unchanged
working-directory: release-files
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: zarubinvibe/iriz
run: |
set -euo pipefail
[[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
[[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]]
tag="v$RELEASE_VERSION"
# List all pages, including drafts. Any API failure stops the job.
releases=$(gh api --paginate --slurp "repos/$GH_REPO/releases?per_page=100")
matching=$(jq -cse --arg tag "$tag" '
if length == 1 then .[0] else error("Expected one JSON document") end |
if type == "array" and length > 0 and all(.[];
type == "array" and all(.[]; type == "object" and
(.tag_name | type == "string") and (.draft | type == "boolean")))
then [.[][] | select(.tag_name == $tag)] else error("Invalid releases response") end
' <<< "$releases")
release_count=$(jq -r 'length' <<< "$matching")
case "$release_count" in
0) ;;
1)
jq -e '.[0].draft == false' <<< "$matching" > /dev/null \
|| { echo "Release $tag is a draft; nothing was changed."; exit 1; }
# target_commitish is not proof: resolve the exact real Git ref.
reference=$(gh api --method GET "repos/$GH_REPO/git/ref/tags/$tag")
object=$(jq -cse --arg ref "refs/tags/$tag" '
if length == 1 then .[0] else error("Expected one JSON document") end |
if type == "object" and .ref == $ref then .object
else error("Invalid tag reference") end
' <<< "$reference")
# Annotated tags may point to other tags. Bound the walk, including cycles.
for ((depth = 0; depth < 16; depth++)); do
object_type=$(jq -er '.type | select(. == "commit" or . == "tag")' <<< "$object")
tagged_sha=$(jq -er '.sha | select(type == "string" and length == 40 and test("^[0-9a-f]{40}$"))' <<< "$object")
[[ "$object_type" != commit ]] || break
annotation=$(gh api --method GET "repos/$GH_REPO/git/tags/$tagged_sha")
object=$(jq -cse --arg sha "$tagged_sha" '
if length == 1 then .[0] else error("Expected one JSON document") end |
if type == "object" and .sha == $sha then .object
else error("Invalid annotated tag") end
' <<< "$annotation")
done
[[ "$object_type" == commit && "$tagged_sha" == "$SOURCE_SHA" ]] \
|| { echo "Tag $tag does not resolve to the expected source commit; nothing was changed."; exit 1; }
printf 'Release %s already published, left unchanged. Existing assets were not verified by this no-op.\n' "$tag" \
| tee -a "$GITHUB_STEP_SUMMARY"
exit 0
;;
*) echo 'Ambiguous releases response; nothing was changed.'; exit 1 ;;
esac
# An existing tag must identify the commit that produced these files.
tags=$(gh api --paginate --slurp "repos/$GH_REPO/tags?per_page=100")
tagged_sha=$(jq -ers --arg tag "$tag" '
if length == 1 then .[0] else error("Expected one JSON document") end |
if type == "array" and length > 0 and all(.[];
type == "array" and all(.[]; type == "object" and
(.name | type == "string") and (.commit.sha | type == "string" and length == 40 and test("^[0-9a-f]{40}$"))))
then [.[][] | select(.name == $tag) | .commit.sha]
| if length == 0 then "" elif length == 1 then .[0] else error("Duplicate tag") end
else error("Invalid tags response") end
' <<< "$tags")
if [[ -n "$tagged_sha" && "$tagged_sha" != "$SOURCE_SHA" ]]; then
echo "Tag $tag points to a different commit; nothing was changed."
exit 1
fi
gh release create "$tag" \
"iriz-$RELEASE_VERSION-arm64.dmg" iriz-macos-arm64.dmg \
SHA256SUMS.txt release-manifest.json \
--repo "$GH_REPO" --target "$SOURCE_SHA" --draft --latest=false \
--title "iriz $RELEASE_VERSION" \
--notes-file "release-notes-v$RELEASE_VERSION.md"
printf 'Created draft %s. Publishing and marking Latest require manual review.\n' "$tag" >> "$GITHUB_STEP_SUMMARY"