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
3 changes: 3 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ jobs:
with:
version: 2026.8.6
install: false
- id: calver
run: mise run release:calver
- id: release
uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
release-as: ${{ steps.calver.outputs.version }}
target-branch: main
- name: Approve release PR CI
if: ${{ steps.release.outputs.prs_created == 'true' }}
Expand Down
4 changes: 4 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ file = "scripts/ci/release-app.sh"
description = "Detect the release component from the Git tag"
file = "scripts/ci/detect-release.sh"

[tasks."release:calver"]
description = "Calculate the next SemVer-compatible CalVer release"
file = "scripts/ci/calver.sh"

[tasks."release:approve-ci"]
description = "Approve CI for the trusted Release Please PR"
file = "scripts/ci/approve-release-ci.sh"
2 changes: 2 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"component": "cli"
}
},
"always-update": true,
"group-pull-request-title-pattern": "chore: release ${version}",
"changelog-sections": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
Expand Down
38 changes: 38 additions & 0 deletions scripts/ci/calver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail

manifest="${CALVER_MANIFEST:-$MISE_PROJECT_ROOT/.release-please-manifest.json}"
calendar="${CALVER_DATE:-$(date -u +%Y-%m)}"

if [[ ! "$calendar" =~ ^([0-9]{4})-([0-9]{2})$ ]]; then
echo "CALVER_DATE must use YYYY-MM" >&2
exit 1
fi

year="${BASH_REMATCH[1]}"
month=$((10#${BASH_REMATCH[2]}))
patch=-1

while IFS= read -r version; do
if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
version_year="${BASH_REMATCH[1]}"
version_month="${BASH_REMATCH[2]}"
version_patch="${BASH_REMATCH[3]}"

if (( version_year > year || (version_year == year && version_month > month) )); then
echo "Manifest version $version is ahead of calendar $year.$month" >&2
exit 1
fi

if (( version_year == year && version_month == month && version_patch > patch )); then
patch="$version_patch"
fi
fi
done < <(jq -r '.[]' "$manifest")

version="$year.$month.$((patch + 1))"
echo "$version"

if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "version=$version" >> "$GITHUB_OUTPUT"
fi