Files
actions/create-tag/action.yaml
Hugo Nijhuis 14d7cae864 Add reusable Forgejo Actions
Composite actions for CI/CD workflows:
- checkout: Clone repo with configurable depth
- docker-build: Build Docker images with multiple tags
- docker-push: Push to Forgejo Packages registry
- create-tag: Auto-increment semantic version tags
- create-issue: Create issues via Forgejo API
- create-pr: Create pull requests via Forgejo API
- comment-pr: Add comments to PRs via Forgejo API

All actions use shell scripts (no Node.js required).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 00:30:07 +01:00

50 lines
1.4 KiB
YAML

name: Create Tag
description: Auto-increment and create a version tag
inputs:
prefix:
description: Tag prefix (e.g., 'v', 'myapp-v')
default: 'v'
token:
description: Token for pushing tags
default: ${{ github.token }}
outputs:
tag:
description: The created tag name
value: ${{ steps.version.outputs.tag }}
version:
description: The version number without prefix
value: ${{ steps.version.outputs.version }}
runs:
using: composite
steps:
- id: version
shell: bash
run: |
PREFIX="${{ inputs.prefix }}"
# Find latest tag with this prefix
LATEST_TAG=$(git tag -l "${PREFIX}*" | sort -V | tail -1)
if [ -z "$LATEST_TAG" ]; then
NEXT_VERSION="${PREFIX}1.0.0"
else
# Extract version and increment patch
CURRENT_VERSION=${LATEST_TAG#$PREFIX}
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
NEXT_VERSION="${PREFIX}${MAJOR}.${MINOR}.$((PATCH + 1))"
fi
echo "tag=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "version=${NEXT_VERSION#$PREFIX}" >> $GITHUB_OUTPUT
# Configure git and create tag
git config user.name forgejo-actions
git config user.email forgejo-actions@code.flowmade.one
git tag "$NEXT_VERSION"
# Push tag using token
git push "https://oauth2:${{ inputs.token }}@code.flowmade.one/${{ github.repository }}.git" "$NEXT_VERSION"