gitea-actions/calver/action.yml
Cal Corum 4c31a04187 Add README and usage headers to all composite actions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 13:52:36 -05:00

62 lines
1.9 KiB
YAML

# CalVer Version Generator
# Generates YYYY.MM.BUILD version from git tags
# BUILD = count of tags matching current month + 1
#
# Usage:
# - uses: cal/gitea-actions/calver@main
# id: calver
#
# Outputs:
# version - CalVer version (e.g., 2026.3.5)
# sha_short - Short commit SHA (7 chars)
# version_sha - Version with SHA (e.g., 2026.3.5-abc1234)
# branch - Current branch name
# timestamp - UTC timestamp (ISO 8601)
name: CalVer Version
description: Generate a CalVer (YYYY.MM.BUILD) version from git tags
outputs:
version:
description: CalVer version (e.g., 2026.2.5)
value: ${{ steps.calver.outputs.version }}
sha_short:
description: Short commit SHA (7 chars)
value: ${{ steps.calver.outputs.sha_short }}
version_sha:
description: Version with SHA suffix (e.g., 2026.2.5-abc1234)
value: ${{ steps.calver.outputs.version_sha }}
branch:
description: Current branch name
value: ${{ steps.calver.outputs.branch }}
timestamp:
description: UTC timestamp in ISO 8601 format
value: ${{ steps.calver.outputs.timestamp }}
runs:
using: composite
steps:
- name: Generate CalVer version
id: calver
shell: bash
run: |
YEAR=$(date -u +%Y)
MONTH=$(date -u +%-m)
PREFIX="${YEAR}.${MONTH}."
# Count existing tags for this month
git fetch --tags
BUILD=$(git tag -l "${PREFIX}*" | wc -l)
BUILD=$((BUILD + 1))
VERSION="${PREFIX}${BUILD}"
SHA_SHORT=$(echo "$GITHUB_SHA" | cut -c1-7)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT
echo "version_sha=${VERSION}-${SHA_SHORT}" >> $GITHUB_OUTPUT
echo "branch=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "CalVer version: ${VERSION}"