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
5 changes: 5 additions & 0 deletions .github/workflows/objective-c-xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
brew install clang-format
Scripts/format.sh --check

# The project's version and CHANGELOG.md's newest version should match
- name: Check Version
run: |
Scripts/check_version.py

- name: Prepare Keychain For Signing
env:
SECRET_MACOS_CERTIFICATE_B64: ${{ secrets.MACOS_CERTIFICATE }}
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

# When a version tag like v0.1.0 is pushed, publish a GitHub release for it, with
# that version's CHANGELOG.md entry as its notes. The tag has to be on main,
# whose commits CI has built and tested, and has to name the version that the
# project and CHANGELOG.md give.
on:
push:
tags: [ "v*" ]

permissions:
contents: write

jobs:
release:
name: Publish a release for a version tag
runs-on: ubuntu-latest

steps:
# All of the history, to see whether main contains the tag
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Check Tag
run: |
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::$GITHUB_REF_NAME isn't on main. Tag a commit from main instead."
exit 1
fi
Scripts/check_version.py --tag "$GITHUB_REF_NAME"

- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
Scripts/check_version.py --notes > notes.md
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag \
--title "CoreZen ${GITHUB_REF_NAME#v}" --notes-file notes.md
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

Notable changes to CoreZen, newest first. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Until 1.0.0, a version that breaks the API raises the middle number, and any other version raises the last.

To note a change, add a line under Unreleased, in a group such as Added, Changed or Fixed. The README says how to release a version.

## Unreleased

## 0.1.0 - 2026-11-19

The first tagged version, with the persistence layer, media playback and frame rendering, and utilities that the README describes. Changes made before it are in the git history.
6 changes: 2 additions & 4 deletions CoreZen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@
"$(PROJECT_DIR)/Dependencies/lib",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zdnelson.CoreZen;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1514,7 +1514,7 @@
"$(PROJECT_DIR)/Dependencies/lib",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zdnelson.CoreZen;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1537,7 +1537,6 @@
);
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zdnelson.CoreZenTests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1560,7 +1559,6 @@
);
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zdnelson.CoreZenTests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
6 changes: 4 additions & 2 deletions CoreZen/CoreZen.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

#import <Foundation/Foundation.h>

//! Project version number for CoreZen.
// CoreZen's version, such as 0.1.0, is its bundle's CFBundleShortVersionString.
// These two come from Xcode's build number for the framework instead, which
// stays 1 (CURRENT_PROJECT_VERSION).

FOUNDATION_EXPORT double CoreZenVersionNumber;

//! Project version string for CoreZen.
FOUNDATION_EXPORT const unsigned char CoreZenVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <CoreZen/PublicHeader.h>
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ CoreZen logs to the unified log, under the subsystem `com.zdnelson.CoreZen`, in
log stream --level info --predicate 'subsystem == "com.zdnelson.CoreZen"'
```

### Versions

CoreZen follows [Semantic Versioning](https://semver.org). Each release is a git tag such as `v0.1.0`, with a [GitHub release](https://github.com/znelson/CoreZen/releases) whose notes come from [`CHANGELOG.md`](https://github.com/znelson/CoreZen/blob/main/CHANGELOG.md). Until 1.0.0, a release that breaks the API raises the middle number (0.1.0 to 0.2.0), and any other release raises the last (0.1.0 to 0.1.1). At run time, the framework bundle's `CFBundleShortVersionString` is its version.

To release a version:
1. In a pull request, rename CHANGELOG.md's Unreleased section to the version and date, such as `## 0.2.0 - 2026-12-01`, and add an empty Unreleased section above it. Set the CoreZen target's Version in Xcode (`MARKETING_VERSION`) to the same number. CI runs `Scripts/check_version.py`, which checks that the two match.
2. Once it's merged, tag the merge commit on main and push the tag: `git tag v0.2.0 && git push origin v0.2.0`. The Release workflow checks the tag against both, then publishes the GitHub release.

## What's In CoreZen.framework?

`CoreZen` has three parts: a persistence layer for a domain model stored in SQLite, media playback and frame rendering built on mpv and FFmpeg, and smaller AppKit and Foundation helpers. The public headers say which values can be `nil`.
Expand Down
133 changes: 133 additions & 0 deletions Scripts/check_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/usr/bin/env python3
"""
Check that CoreZen's version is the same everywhere it's written down.

The version is the CoreZen target's MARKETING_VERSION in CoreZen.xcodeproj,
which the framework reports as its CFBundleShortVersionString. CHANGELOG.md has a
section for each released version, newest first, below an Unreleased section for
changes since. A release is the commit tagged with its version, like v0.1.0.

Usage:
./check_version.py # Check the project's version is CHANGELOG.md's newest
./check_version.py --tag v0.1.0 # Also check a release tag names that version
./check_version.py --notes # Print that version's CHANGELOG.md entry, after checking

CI runs it for every change, and with --tag when a version tag is pushed. It needs
only Python 3, including the one that comes with Xcode.
"""

import argparse
import datetime
import os
import re
import sys

ROOT_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CHANGELOG_PATH = os.path.join(ROOT_PATH, 'CHANGELOG.md')
PROJECT_PATH = os.path.join(ROOT_PATH, 'CoreZen.xcodeproj', 'project.pbxproj')

UNRELEASED_HEADING = 'Unreleased'
# A released version's heading, like "0.1.0 - 2026-11-19". Semantic Versioning
# doesn't allow leading zeros.
VERSION_HEADING = re.compile(r'(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*) - (\d{4}-\d{2}-\d{2})')
MARKETING_VERSION = re.compile(r'^\s*MARKETING_VERSION = "?([^";]*)"?;', re.MULTILINE)


##
def fail(message):
print(f'check_version.py: {message}', file=sys.stderr)
sys.exit(1)


##
def read(path):
try:
with open(path, encoding='utf-8') as f:
return f.read()
except FileNotFoundError:
fail(f'{os.path.relpath(path, ROOT_PATH)} is missing')


##
def changelog_sections(text):
"""CHANGELOG.md's "## " sections, in order, as (heading, body) pairs."""
sections = []
for line in text.splitlines():
if line.startswith('## '):
sections.append((line[3:].strip(), []))
elif sections:
sections[-1][1].append(line)
return [(heading, '\n'.join(body).strip()) for heading, body in sections]


##
def released_versions(sections):
"""
The released versions in CHANGELOG.md, newest first, as (version, entry) pairs.
Fails unless the first section is Unreleased and every other one is a version
with a date and an entry, each older than the one above it.
"""
if not sections or sections[0][0] != UNRELEASED_HEADING:
fail(f'CHANGELOG.md should start with a "## {UNRELEASED_HEADING}" section, for changes not yet released')

versions = []
newer = None
for heading, entry in sections[1:]:
match = VERSION_HEADING.fullmatch(heading)
if not match:
fail(f'CHANGELOG.md has a heading "## {heading}", but a version\'s should look like "## 1.2.3 - 2026-01-31"')
number = tuple(int(part) for part in match.group(1, 2, 3))
version = '.'.join(match.group(1, 2, 3))
try:
date = datetime.date.fromisoformat(match.group(4))
except ValueError:
fail(f'CHANGELOG.md\'s heading "## {heading}" has a date that doesn\'t exist')
if not entry:
fail(f'CHANGELOG.md has no entry for {version}')
if newer:
newer_version, newer_number, newer_date = newer
if number >= newer_number:
fail(f'CHANGELOG.md lists {version} below {newer_version}; versions should go newest first')
if date > newer_date:
fail(f'CHANGELOG.md dates {version} after {newer_version}, which is listed above it')
versions.append((version, entry))
newer = (version, number, date)

if not versions:
fail('CHANGELOG.md has no released versions')
return versions


##
def project_versions(text):
"""Every MARKETING_VERSION in the Xcode project, without repeats."""
return sorted(set(MARKETING_VERSION.findall(text)))


##
def main():
parser = argparse.ArgumentParser(description='Check that CoreZen\'s version is the same everywhere')
parser.add_argument('--tag', help='a release tag that should name the version, like v0.1.0')
parser.add_argument('--notes', action='store_true', help='print the version\'s CHANGELOG.md entry')
args = parser.parse_args()

version, entry = released_versions(changelog_sections(read(CHANGELOG_PATH)))[0]

found = project_versions(read(PROJECT_PATH))
if not found:
fail('CoreZen.xcodeproj sets no MARKETING_VERSION')
if found != [version]:
fail(f'CoreZen.xcodeproj\'s MARKETING_VERSION is {", ".join(found)}, '
f'but CHANGELOG.md\'s newest version is {version}')

if args.tag is not None and args.tag != f'v{version}':
fail(f'the tag is {args.tag}, but {version}\'s tag should be v{version}')

if args.notes:
print(entry)
else:
print(f'CoreZen {version}: CoreZen.xcodeproj and CHANGELOG.md agree')


if __name__ == '__main__':
main()