Skip to content

Commit

Permalink
feat: enable use of cog verify in action
Browse files Browse the repository at this point in the history
Signed-off-by: Mark S <the@wondersmith.dev>
  • Loading branch information
the-wondersmith authored and oknozor committed May 14, 2024
1 parent 5464e06 commit 8847c89
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 28 deletions.
44 changes: 29 additions & 15 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
name: 'Conventional commit cocogitto action'
description: 'Check conventional commits compliance and/or automatically release new version'
---
name: Conventional commit cocogitto action

description: |
Check conventional commits compliance and/or automatically release new version
branding:
icon: 'git-commit'
color: 'red'
author: 'Paul Delafosse'
icon: git-commit
color: red

author: Paul Delafosse

inputs:
release:
description: 'Perform a release with cog bump --auto'
description: Perform a release with cog bump --auto
required: false
default: 'false'
check:
description: 'Perform a conventional commit check with cog --check'
description: Perform a conventional commit check with cog --check
required: false
default: 'true'
check-latest-tag-only:
description: 'Check commit history from latest tag to HEAD'
description: Check commit history from latest tag to HEAD
required: false
default: 'false'
git-user:
description: 'Git user.name configuration'
description: Git user.name configuration
required: false
default: 'cog-bot'
git-user-email:
description: 'Git user.email configuration'
description: Git user.email configuration
required: false
default: 'cog@demo.org'
verify:
description: |-
Check an arbitrary input string against the conventional
commit specification but do not create any commit.
required: false
default: 'false'

outputs:
version:
description: "Version released"
description: Version released
value: ${{ steps.cog.outputs.version }}

runs:
using: "composite"
using: composite
steps:
- run: echo Installing cocogitto
shell: bash
Expand All @@ -49,11 +62,12 @@ runs:
echo "$HOME/.local/bin" >> $GITHUB_PATH
- id: cog
shell: bash
run: |
${{ github.action_path }}/cog.sh \
${{ inputs.check }} \
${{ inputs.check }} \
${{ inputs.check-latest-tag-only }} \
${{ inputs.release }} \
${{ inputs.git-user }} \
${{ inputs.git-user-email }}
shell: bash
${{ inputs.git-user-email }} \
${{ inputs.verify }}
31 changes: 18 additions & 13 deletions cog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,42 @@

set -a

CHECK=$1
LATEST_TAG_ONLY=$2
RELEASE=$3
GIT_USER=$4
GIT_USER_EMAIL=$5
CHECK="${1}"
LATEST_TAG_ONLY="${2}"
RELEASE="${3}"
GIT_USER="${4}"
GIT_USER_EMAIL="${5}"
VERIFY="${7}"

echo "Setting git user : $GIT_USER"
git config --global user.name "$GIT_USER"
echo "Setting git user : ${GIT_USER}"
git config --global user.name "${GIT_USER}"

echo "Settings git user email $GIT_USER_EMAIL"
git config --global user.email "$GIT_USER_EMAIL"
echo "Settings git user email ${GIT_USER_EMAIL}"
git config --global user.email "${GIT_USER_EMAIL}"

cog --version

if [ "$CHECK" = "true" ]; then
if [ "$LATEST_TAG_ONLY" = "true" ]; then
if [ "${CHECK}" = "true" ]; then
if [ "${LATEST_TAG_ONLY}" = "true" ]; then
if [ "$(git describe --tags --abbrev=0)" ]; then
message="Checking commits from $(git describe --tags --abbrev=0)"
else
message="No tag found checking history from first commit"
fi
echo "$message"
echo "${message}"
cog check --from-latest-tag || exit 1
else
echo "Checking all commits"
cog check || exit 1
fi
fi

if [ "$RELEASE" = "true" ]; then
if [ "${RELEASE}" = "true" ]; then
cog bump --auto || exit 1
VERSION="$(git describe --tags "$(git rev-list --tags --max-count=1)")"
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi

if ( echo "${VERIFY}" | grep -Eiv '^([01]|(true)|(false))$' > /dev/null ) ; then
cog verify "${VERIFY}" || exit 1
fi

0 comments on commit 8847c89

Please sign in to comment.