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"