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
90 changes: 51 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,42 @@ jobs:
echo "version=$(python ./setup.py --version)" >> $GITHUB_OUTPUT
echo "Version detected: $(python ./setup.py --version)"

- name: Validate version alignment
run: |
VERSION="${{ steps.getversion.outputs.version }}"
ERRORS=0

# Check CHANGELOG.md has the version section
if ! grep -q "^## \[$VERSION\]" CHANGELOG.md; then
echo "::error file=CHANGELOG.md::CHANGELOG.md is missing a section for version [$VERSION]. The workflow extracts release notes from the CHANGELOG, so this section must exist before releasing. Expected format: '## [$VERSION] - YYYY-MM-DD'"
ERRORS=1
fi

# Check README.md has the version
if ! grep -q "rev: v$VERSION" README.md; then
CURRENT_README_VERSION=$(grep -m 1 "rev: v" README.md | sed -n 's/.*rev: v\([0-9.]*\).*/\1/p')
echo "::error file=README.md::README.md version (v$CURRENT_README_VERSION) does not match setup.py version ($VERSION). Update all 'rev: v' references in README.md to 'rev: v$VERSION' before releasing."
ERRORS=1
fi

# Check version link exists in CHANGELOG.md
if ! grep -q "^\[$VERSION\]:" CHANGELOG.md; then
echo "::error file=CHANGELOG.md::CHANGELOG.md is missing a version comparison link for [$VERSION]. Add '[$VERSION]: https://github.com/homebysix/pre-commit-macadmin/compare/vPREVIOUS...v$VERSION' at the bottom of CHANGELOG.md."
ERRORS=1
fi

if [ $ERRORS -gt 0 ]; then
echo ""
echo "❌ Version alignment check failed. Please ensure:"
echo " 1. CHANGELOG.md has a '## [$VERSION]' section with release notes"
echo " 2. README.md has 'rev: v$VERSION' in all examples"
echo " 3. CHANGELOG.md has a '[$VERSION]:' comparison link at the bottom"
echo ""
exit 1
fi

echo "✅ Version $VERSION is properly aligned across all files"

- name: Fetch tags
run: git fetch --tags origin

Expand Down Expand Up @@ -84,56 +120,32 @@ jobs:
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Next version will be: $NEXT_VERSION"

- name: Update setup.py version
- name: Merge main to dev
if: steps.tagcheck.outputs.should_release == 'true'
run: |
sed -i 's/version="${{ steps.getversion.outputs.version }}"/version="${{ steps.nextversion.outputs.next }}"/' setup.py
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin dev
git checkout dev
git merge origin/main --no-edit

- name: Update README.md version
- name: Update setup.py version on dev
if: steps.tagcheck.outputs.should_release == 'true'
run: |
sed -i 's/rev: v${{ steps.getversion.outputs.version }}/rev: v${{ steps.nextversion.outputs.next }}/g' README.md
sed -i 's/version="${{ steps.getversion.outputs.version }}"/version="${{ steps.nextversion.outputs.next }}"/' setup.py

- name: Update CHANGELOG.md
- name: Update README.md version on dev
if: steps.tagcheck.outputs.should_release == 'true'
run: |
CURRENT="${{ steps.getversion.outputs.version }}"
NEXT="${{ steps.nextversion.outputs.next }}"
TODAY=$(date +%Y-%m-%d)

# Create temp file with new changelog section
cat > /tmp/changelog_update.txt << 'ENDOFCHANGELOG'
## [Unreleased]

Nothing yet.

## [NEXT_VERSION] - TODAY_PLACEHOLDER
ENDOFCHANGELOG

# Replace placeholders
sed -i "s/NEXT_VERSION/$NEXT/g" /tmp/changelog_update.txt
sed -i "s/TODAY_PLACEHOLDER/$TODAY/g" /tmp/changelog_update.txt

# Insert new section after the first "## [Unreleased]" line
sed -i "/## \[Unreleased\]/r /tmp/changelog_update.txt" CHANGELOG.md
# Remove the old "## [Unreleased]" and "Nothing yet." lines
sed -i '1,/Nothing yet\./ { /## \[Unreleased\]/d; /Nothing yet\./d }' CHANGELOG.md

# Update version comparison links at bottom
# Update [Unreleased] link
sed -i "s|\[Unreleased\]:.*|[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v$NEXT...HEAD|" CHANGELOG.md
# Add new version link after [Unreleased]
sed -i "/\[Unreleased\]:/a [$NEXT]: https://github.com/homebysix/pre-commit-macadmin/compare/v$CURRENT...v$NEXT" CHANGELOG.md
sed -i 's/rev: v${{ steps.getversion.outputs.version }}/rev: v${{ steps.nextversion.outputs.next }}/g' README.md

- name: Commit version bump
- name: Commit version bump on dev
if: steps.tagcheck.outputs.should_release == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add setup.py README.md CHANGELOG.md
git commit -m "Bump to ${{ steps.nextversion.outputs.next }} [skip ci]"
git add setup.py README.md
git commit -m "Bump to ${{ steps.nextversion.outputs.next }}"

- name: Push changes
- name: Push dev branch
if: steps.tagcheck.outputs.should_release == 'true'
run: |
git push origin main
git push origin dev
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ All notable changes to this project will be documented in this file. This projec

Nothing yet.

## [1.24.1] - 2026-04-12

### Changed

- Skipped AutoPkg recipe type convention checks when type is unknown. (#55)
- Updated release documentation to reflect new automated workflow.
- Built error handling into release automation workflow.

## [1.24.0] - 2026-04-12

### Added
Expand Down Expand Up @@ -468,7 +476,8 @@ Nothing yet.

- Initial release

[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.24.0...HEAD
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.24.1...HEAD
[1.24.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.24.0...v1.24.1
[1.24.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.23.0...v1.24.0
[1.23.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.22.0...v1.23.0
[1.22.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.21.0...v1.22.0
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.24.0
rev: v1.24.1
hooks:
- id: check-plists
# - id: ...
Expand Down Expand Up @@ -147,7 +147,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.24.0
rev: v1.24.1
hooks:
- id: check-munki-pkgsinfo
args: ['--catalogs', 'testing', 'stable', '--']
Expand All @@ -157,7 +157,7 @@ But if you also use the `--categories` argument, you would move the trailing `--

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.24.0
rev: v1.24.1
hooks:
- id: check-munki-pkgsinfo
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
Expand All @@ -169,7 +169,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.24.0
rev: v1.24.1
hooks:
- id: check-munki-pkgsinfo
args: [
Expand Down
55 changes: 49 additions & 6 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
# Releasing new versions of pre-commit-macadmin

1. Update the versions in __README.md__ and __setup.py__.
Releases are largely automated via GitHub Actions. The workflow triggers when `setup.py` is pushed to `main`, creating a GitHub release and automatically preparing the `dev` branch for the next release.

1. Check unit tests:
## Release Process

1. On the `dev` branch, check unit tests:

.venv/bin/python -m coverage run -m unittest discover -vs tests

1. Update the change log.
1. Prepare CHANGELOG.md for release by moving `[Unreleased]` changes to a new version section:

## [Unreleased]

Nothing yet.

## [X.Y.Z] - YYYY-MM-DD

### Added/Changed/Fixed/Removed (separate sections as applicable)
- New features, changes, fixes, or removals

The release workflow will extract this section for the GitHub release notes.

1. Add the version comparison link at the bottom of CHANGELOG.md:

[X.Y.Z]: https://github.com/homebysix/pre-commit-macadmin/compare/vPREVIOUS...vX.Y.Z

1. Update the version in `setup.py` to match the CHANGELOG version (e.g., `2.3.6`).

1. Update the version in `README.md` examples to match (e.g., `rev: v2.3.6`).

1. Commit these changes to `dev` and push.

1. Merge `dev` branch to `main`.

1. The release workflow will automatically:
- Detect the version from `setup.py` (e.g., `2.3.6`)
- Create a GitHub release with tag `v2.3.6`
- Extract release notes from CHANGELOG.md
- Merge `main` back to `dev`
- Bump `dev` versions to the next patch version (e.g., `2.3.7`) in `setup.py` and `README.md`
- Commit and push the updated version to `dev`

Note: CHANGELOG.md is NOT automatically updated on `dev`. Add entries to the `[Unreleased]` section as you make changes.

1. Pull the updated `dev` branch to continue development at the new version.

1. As you make changes, add entries to the `[Unreleased]` section of CHANGELOG.md. When ready for the next release, simply promote those changes to a new version section (repeat from step 2) - no need to manually bump versions unless you want to change to a minor or major version.

1. After each release, verify on GitHub and run `pre-commit autoupdate` on a test repo to confirm it updates correctly.

## Version Numbering

1. Merge development branch to main.
The workflow automatically bumps the **patch** version (X.Y.Z → X.Y.Z+1). If you need to bump the **minor** or **major** version, manually update the version numbers in `setup.py`, `README.md`, and CHANGELOG.md before merging to `main`.

1. Create a GitHub release with version tag, prefixed with `v`. (For example: `v2.3.4`)
## Pre-releases

1. Run `pre-commit autoupdate` on a test repo and confirm it updates to the new version.
If a pre-release is desired for testing purposes, it must be done manually.
13 changes: 13 additions & 0 deletions pre_commit_macadmin_hooks/check_autopkg_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,19 @@ def validate_proc_type_conventions(process, filename):
],
}

# Extract all known recipe types from conventions
all_known_types = []
for recipe_group in proc_type_conventions:
for recipe_type in recipe_group:
all_known_types.append(f".{recipe_type}.")

# Skip validation if filename doesn't contain any known recipe type
if not any(known_type in filename for known_type in all_known_types):
print(
f"{filename}: WARNING: Unknown recipe type. Skipping processor convention checks."
)
return True

passed = True
processors = [x.get("Processor") for x in process]
for recipe_group in proc_type_conventions:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name="pre-commit-macadmin",
description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.",
url="https://github.com/homebysix/pre-commit-macadmin",
version="1.24.0",
version="1.24.1",
author="Elliot Jordan",
author_email="elliot@elliotjordan.com",
packages=["pre_commit_macadmin_hooks"],
Expand Down
Loading
Loading